|
From: <nu...@us...> - 2011-05-29 20:05:16
|
Revision: 15062
http://pcgen.svn.sourceforge.net/pcgen/?rev=15062&view=rev
Author: nuance
Date: 2011-05-29 20:05:07 +0000 (Sun, 29 May 2011)
Log Message:
-----------
CheckStyle updates.
Modified Paths:
--------------
Trunk/pcgen/code/src/java/pcgen/cdom/base/Constants.java
Trunk/pcgen/code/src/java/pcgen/core/bonus/BonusObj.java
Trunk/pcgen/code/src/java/plugin/bonustokens/Checks.java
Modified: Trunk/pcgen/code/src/java/pcgen/cdom/base/Constants.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/cdom/base/Constants.java 2011-05-29 18:29:56 UTC (rev 15061)
+++ Trunk/pcgen/code/src/java/pcgen/cdom/base/Constants.java 2011-05-29 20:05:07 UTC (rev 15062)
@@ -416,6 +416,9 @@
String LST_DOT_CLEAR_DOT = ".CLEAR.";
/** A snippet of List code as a constant. */
+ String LST_BASE = "BASE.";
+
+ /** A snippet of List code as a constant. */
String LST_TYPE_OLD = "TYPE.";
/** A snippet of List code as a constant. */
@@ -595,6 +598,10 @@
int ARBITRARY_END_SKILL_INDEX = 999;
/**
+ * The length of the string "BASE.". */
+ int LENGTH_OF_BASE_SUBSTRING = 5;
+
+ /**
* The length of both the LST_TYPE and LST_TYPE_OLD constants. */
int LENGTH_OF_TYPE_SUBSTRING = 5;
Modified: Trunk/pcgen/code/src/java/pcgen/core/bonus/BonusObj.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/core/bonus/BonusObj.java 2011-05-29 18:29:56 UTC (rev 15061)
+++ Trunk/pcgen/code/src/java/pcgen/core/bonus/BonusObj.java 2011-05-29 20:05:07 UTC (rev 15062)
@@ -50,17 +50,20 @@
**/
public abstract class BonusObj extends ConcretePrereqObject implements Serializable, Cloneable, QualifyingObject
{
- private List<Object> bonusInfo = new ArrayList<Object>();
- private Map<String, String> dependMap = new HashMap<String, String>();
+ private List<Object> bonusInfo = new ArrayList<Object>();
+ private Map<String, String> dependMap = new HashMap<String, String>();
private Formula bonusFormula = FormulaFactory.ZERO;
+
/** The name of the bonus e.g. STAT or COMBAT */
- private String bonusName = Constants.EMPTY_STRING;
+ private String bonusName = Constants.EMPTY_STRING;
+
/** The type of the bonus e.g. Enhancement or Dodge */
- private String bonusType = Constants.EMPTY_STRING;
- private String varPart = Constants.EMPTY_STRING;
- private String typeOfBonus = Bonus.BONUS_UNDEFINED;
- private String stringRepresentation = null;
- private String tokenSource = null;
+ private String bonusType = Constants.EMPTY_STRING;
+ private String varPart = Constants.EMPTY_STRING;
+ private String typeOfBonus = Bonus.BONUS_UNDEFINED;
+ private String stringRepresentation = null;
+ private String tokenSource = null;
+
private boolean saveToPCG = true;
/** An enum for the possible stacking modifiers a bonus can have */
Modified: Trunk/pcgen/code/src/java/plugin/bonustokens/Checks.java
===================================================================
--- Trunk/pcgen/code/src/java/plugin/bonustokens/Checks.java 2011-05-29 18:29:56 UTC (rev 15061)
+++ Trunk/pcgen/code/src/java/plugin/bonustokens/Checks.java 2011-05-29 20:05:07 UTC (rev 15062)
@@ -26,13 +26,14 @@
package plugin.bonustokens;
import pcgen.cdom.base.CDOMReference;
+import pcgen.cdom.base.Constants;
import pcgen.cdom.reference.CDOMDirectSingleRef;
import pcgen.core.PCCheck;
import pcgen.core.bonus.BonusObj;
import pcgen.rules.context.LoadContext;
/**
- * <code>Checks</code>
+ * <code>Checks</code>.
*
* @author Greg Bingleman <by...@ho...>
*/
@@ -44,9 +45,9 @@
boolean isBase = false;
final String token;
- if (argToken.startsWith("BASE."))
+ if (argToken.startsWith(Constants.LST_BASE))
{
- token = argToken.substring(5);
+ token = argToken.substring(Constants.LENGTH_OF_BASE_SUBSTRING);
isBase = true;
}
else
@@ -57,7 +58,7 @@
if ("%LIST".equals(token))
{
// Special case of: BONUS:CHECKS|%LIST|x
- addBonusInfo(LIST_CHECK);
+ addBonusInfo(listCheck);
}
else if ("ALL".equals(token))
{
@@ -67,17 +68,14 @@
* CHECKS are established need to test both CHECKS|Blah and
* CHECKS|ALL
*/
- for (PCCheck check : context.ref
- .getConstructedCDOMObjects(PCCheck.class))
+ for (PCCheck check : context.ref.getConstructedCDOMObjects(PCCheck.class))
{
- addBonusInfo(new CheckInfo(CDOMDirectSingleRef.getRef(check),
- isBase));
+ addBonusInfo(new CheckInfo(CDOMDirectSingleRef.getRef(check), isBase));
}
}
else
{
- CDOMReference<PCCheck> aCheck = context.ref
- .getCDOMReference(PCCheck.class, token);
+ CDOMReference<PCCheck> aCheck = context.ref.getCDOMReference(PCCheck.class, token);
//Invalid name is caught by Unconstructed Reference system
addBonusInfo(new CheckInfo(aCheck, isBase));
}
@@ -85,46 +83,68 @@
return true;
}
+ /**
+ * Unparse the bonus token.
+ * @param obj The object to unparse
+ * @return The unparsed string.
+ */
@Override
protected String unparseToken(final Object obj)
{
- String token = "";
- if (obj.equals(LIST_CHECK))
+ if (obj.equals(listCheck))
{
- return token + "%LIST";
+ return Constants.LST_PERCENT_LIST;
}
- else if (((CheckInfo) obj).isBase)
- {
- token = "BASE.";
- }
- return token + ((CheckInfo) obj).pobj.getLSTformat(false);
+ String token = ((CheckInfo) obj).isBase()
+ ? Constants.LST_BASE
+ : Constants.EMPTY_STRING;
+
+ return token + ((CheckInfo) obj).getPobj().getLSTformat(false);
}
/**
- * Deals with the CheckInfo
+ * Deals with the CheckInfo.
*/
public static class CheckInfo
{
- /** The PObject */
- public final CDOMReference<PCCheck> pobj;
- /** whether this is a base check, True or False */
- public final boolean isBase;
+ private final CDOMReference<PCCheck> pobj;
+ private final boolean isBase;
+
/**
- * Constructor
- * @param argPobj
- * @param argIsBase
+ * Constructor.
+ * @param argPobj The PObject.
+ * @param argIsBase Whether this is a base check.
*/
public CheckInfo(final CDOMReference<PCCheck> argPobj, final boolean argIsBase)
{
pobj = argPobj;
isBase = argIsBase;
}
+
+ /**
+ * The PObject.
+ * @return the stored PObject.
+ */
+ public CDOMReference<PCCheck> getPobj()
+ {
+ return pobj;
+ }
+
+ /**
+ * Whether this is a base check.
+ *
+ * @return True or False.
+ */
+ public boolean isBase()
+ {
+ return isBase;
+ }
}
- public static CheckInfo LIST_CHECK = new CheckInfo(null, false);
+ private static CheckInfo listCheck = new CheckInfo(null, false);
@Override
public String getBonusHandled()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|