use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class BonusConvertPlugin method processBonus.
private String processBonus(TokenProcessEvent tpe, String key, String value) {
try {
LoadContext context = tpe.getContext();
CDOMObject obj = tpe.getPrimary();
if (context.processToken(obj, key, value)) {
context.commit();
} else {
context.rollback();
Logging.replayParsedMessages();
}
Logging.clearParseMessages();
Collection<String> output = context.unparse(obj);
if (output == null || output.isEmpty()) {
// Uh Oh
return ("Unable to unparse: " + key + ':' + value);
}
boolean needTab = false;
for (String s : output) {
if (needTab) {
tpe.append('\t');
}
needTab = true;
tpe.append(s);
}
tpe.consume();
} catch (PersistenceLayerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class AbstractListInputTokenTestCase method testRoundRobinTestEqualThree.
@Test
public void testRoundRobinTestEqualThree() throws PersistenceLayerException {
if (isTypeLegal()) {
CDOMObject a = (CDOMObject) construct(primaryContext, "Typed1");
a.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
a.addToListFor(ListKey.TYPE, Type.getConstant("TestAltType"));
a.addToListFor(ListKey.TYPE, Type.getConstant("TestThirdType"));
CDOMObject c = (CDOMObject) construct(secondaryContext, "Typed1");
c.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
c.addToListFor(ListKey.TYPE, Type.getConstant("TestAltType"));
c.addToListFor(ListKey.TYPE, Type.getConstant("TestThirdType"));
runRoundRobin("TYPE=TestAltType.TestThirdType.TestType");
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class AbstractQualifierTokenTestCase method testRoundRobinQualifiedFourAndOr.
@Test
public void testRoundRobinQualifiedFourAndOr() throws PersistenceLayerException {
CDOMObject a = construct(primaryContext, "Typed1");
a.addToListFor(ListKey.TYPE, Type.getConstant("Type1"));
CDOMObject b = construct(primaryContext, "Typed2");
b.addToListFor(ListKey.TYPE, Type.getConstant("Type2"));
CDOMObject c = construct(secondaryContext, "Typed1");
c.addToListFor(ListKey.TYPE, Type.getConstant("Type1"));
CDOMObject d = construct(secondaryContext, "Typed2");
d.addToListFor(ListKey.TYPE, Type.getConstant("Type2"));
CDOMObject e = construct(primaryContext, "Typed3");
e.addToListFor(ListKey.TYPE, Type.getConstant("Type3"));
CDOMObject f = construct(primaryContext, "Typed4");
f.addToListFor(ListKey.TYPE, Type.getConstant("Type4"));
CDOMObject g = construct(secondaryContext, "Typed3");
g.addToListFor(ListKey.TYPE, Type.getConstant("Type3"));
CDOMObject h = construct(secondaryContext, "Typed4");
h.addToListFor(ListKey.TYPE, Type.getConstant("Type4"));
runRoundRobin(getSubTokenName() + '|' + qualifier + "[!TYPE=Type1,TYPE=Type2|!TYPE=Type3,TYPE=Type4]");
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class AbstractQualifierTokenTestCase method testRoundRobinNotQualifierTestEqualThree.
@Test
public void testRoundRobinNotQualifierTestEqualThree() throws PersistenceLayerException {
if (allowsNotQualifier()) {
CDOMObject a = construct(primaryContext, "Typed1");
a.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
a.addToListFor(ListKey.TYPE, Type.getConstant("TestThirdType"));
a.addToListFor(ListKey.TYPE, Type.getConstant("TestAltType"));
CDOMObject c = construct(secondaryContext, "Typed1");
c.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
c.addToListFor(ListKey.TYPE, Type.getConstant("TestThirdType"));
c.addToListFor(ListKey.TYPE, Type.getConstant("TestAltType"));
runRoundRobin(getSubTokenName() + '|' + "!" + qualifier + "[TYPE=TestAltType.TestThirdType.TestType]");
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class AbstractQualifierTokenTestCase method testRoundRobinNotQualifierWithEqualType.
@Test
public void testRoundRobinNotQualifierWithEqualType() throws PersistenceLayerException {
if (allowsNotQualifier()) {
construct(primaryContext, getTargetClass(), "TestWP1");
construct(primaryContext, getTargetClass(), "TestWP2");
construct(secondaryContext, getTargetClass(), "TestWP1");
construct(secondaryContext, getTargetClass(), "TestWP2");
CDOMObject a = construct(primaryContext, "Typed1");
a.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
CDOMObject b = construct(primaryContext, "Typed2");
b.addToListFor(ListKey.TYPE, Type.getConstant("OtherTestType"));
CDOMObject c = construct(secondaryContext, "Typed1");
c.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
CDOMObject d = construct(secondaryContext, "Typed2");
d.addToListFor(ListKey.TYPE, Type.getConstant("OtherTestType"));
runRoundRobin(getSubTokenName() + '|' + "!" + qualifier + "[TestWP1|TestWP2|TYPE=OtherTestType|TYPE=TestType]");
}
}
Aggregations