use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.
the class GlobalMoveTest method processToken.
@Override
public void processToken(CDOMObject source) {
ParseResult result = token.parseToken(context, source, "Fly,30");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
finishLoad();
}
use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.
the class GlobalQualifyTest method testFromEqMod.
@Override
@Test
public void testFromEqMod() throws PersistenceLayerException {
EquipmentModifier source = create(EquipmentModifier.class, "Source");
ParseResult result = token.parseToken(context, source, "RACE|Dwarf");
assertFalse(result.passed());
}
use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.
the class ExchangelevelToken method parseTokenWithSeparator.
@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, PCClass pcc, String value) {
final StringTokenizer tok = new StringTokenizer(value, Constants.PIPE);
if (tok.countTokens() != 4) {
return new ParseResult.Fail(getTokenName() + " must have 4 | delimited arguments : " + value, context);
}
String classString = tok.nextToken();
CDOMSingleRef<PCClass> cl = context.getReferenceContext().getCDOMReference(PCClass.class, classString);
String mindlString = tok.nextToken();
int mindl;
try {
mindl = Integer.parseInt(mindlString);
} catch (NumberFormatException nfe) {
return new ParseResult.Fail(getTokenName() + " expected an integer: " + mindlString, context);
}
String maxdlString = tok.nextToken();
int maxdl;
try {
maxdl = Integer.parseInt(maxdlString);
} catch (NumberFormatException nfe) {
return new ParseResult.Fail(getTokenName() + " expected an integer: " + maxdlString, context);
}
String minremString = tok.nextToken();
int minrem;
try {
minrem = Integer.parseInt(minremString);
} catch (NumberFormatException nfe) {
return new ParseResult.Fail(getTokenName() + " expected an integer: " + minremString, context);
}
try {
LevelExchange le = new LevelExchange(cl, mindl, maxdl, minrem);
context.getObjectContext().put(pcc, ObjectKey.EXCHANGE_LEVEL, le);
return ParseResult.SUCCESS;
} catch (IllegalArgumentException e) {
ComplexParseResult pr = new ComplexParseResult();
pr.addErrorMessage("Error in " + getTokenName() + ' ' + e.getMessage());
pr.addErrorMessage(" Token contents: " + value);
return pr;
}
}
use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.
the class RankToken method parseNonEmptyToken.
@Override
protected ParseResult parseNonEmptyToken(LoadContext context, KitSkill kitSkill, String value) {
try {
BigDecimal rank = new BigDecimal(value);
if (rank.compareTo(BigDecimal.ZERO) < 0) {
return new ParseResult.Fail(getTokenName() + " must be a positive number: " + value, context);
}
kitSkill.setRank(rank);
return ParseResult.SUCCESS;
} catch (NumberFormatException e) {
return new ParseResult.Fail(getTokenName() + " expected a number: " + value, context);
}
}
use of pcgen.rules.persistence.token.ParseResult in project pcgen by PCGen.
the class ApplyToken method parseNonEmptyToken.
@Override
protected ParseResult parseNonEmptyToken(LoadContext context, Kit kit, String value) {
try {
KitApply ka = KitApply.valueOf(value);
kit.put(ObjectKey.APPLY_MODE, ka);
return ParseResult.SUCCESS;
} catch (IllegalArgumentException e) {
return new ParseResult.Fail(getTokenName() + " encountered unexpected application type: " + value, context);
}
}
Aggregations