use of pcgen.cdom.inst.ObjectCache in project pcgen by PCGen.
the class PlayerCharacter method setDirty.
/**
* Sets the character changed since last save.
* NB: This is not a 'safe' call - its use should be considered carefully and in
* particular it should not be called from a method used as part of PlayerCharacter
* cloning as this can mean conditional abilities get dropped when they are actually
* qualified for, just not at that point in the clone.
*
* @param dirtyState the new "dirty" value (may be false to indicate no change)
*/
public void setDirty(final boolean dirtyState) {
if (dirtyState) {
serial++;
cache = new ObjectCache();
variableProcessor.setSerial(serial);
cabFacet.update(id);
cAvSpellFacet.update(id);
cKnSpellFacet.update(id);
condLangFacet.update(id);
bonusSkillRankChangeFacet.reset(id);
}
dirtyFlag = dirtyState;
}
use of pcgen.cdom.inst.ObjectCache in project pcgen by PCGen.
the class AbstractPreRoundRobin method runSimpleRoundRobin.
public static void runSimpleRoundRobin(String s, String d) {
try {
Prerequisite p = PreParserFactory.getInstance().parse(s);
PrerequisiteWriterInterface writer = PrerequisiteWriterFactory.getInstance().getWriter(p.getKind());
if (writer == null) {
fail("Could not find Writer for: " + p.getKind());
}
StringWriter w = new StringWriter();
writer.write(w, p);
assertEquals(d, w.toString());
/*
* Now try new system
*/
LoadContext context = new EditorLoadContext();
CDOMObject obj = new ObjectCache();
int colonLoc = s.indexOf(':');
String key = s.substring(0, colonLoc);
String value = s.substring(colonLoc + 1);
if (context.processToken(obj, key, value)) {
context.commit();
} else {
context.rollback();
Logging.replayParsedMessages();
fail();
}
Logging.clearParseMessages();
Collection<String> output = context.unparse(obj);
if (output == null || output.isEmpty()) {
// Uh Oh
fail("Unable to unparse: " + key + ":" + value);
}
assertEquals(1, output.size());
assertEquals(d, output.iterator().next());
} catch (PersistenceLayerException e) {
e.printStackTrace();
fail(e.getLocalizedMessage());
}
}
use of pcgen.cdom.inst.ObjectCache in project pcgen by PCGen.
the class BonusConvertPlugin method process.
private String process(EditorLoadContext context, ConversionDecider decider, String objectName, String token) {
final int colonLoc = token.indexOf(':');
if (colonLoc == -1) {
Logging.errorPrint("Invalid Token - does not contain a colon: " + token);
return null;
} else if (colonLoc == 0) {
Logging.errorPrint("Invalid Token - starts with a colon: " + token);
return null;
}
String key = token.substring(0, colonLoc);
String value = (colonLoc == token.length() - 1) ? null : token.substring(colonLoc + 1);
CDOMObject cdo = new ObjectCache();
cdo.setName("BONUS" + bonusCount++);
TokenProcessEvent tpe = new TokenProcessEvent(context, decider, key, value, objectName, cdo);
String error = TokenConverter.process(tpe);
context.purge(cdo);
TokenConverter.clearConstants();
if (tpe.isConsumed()) {
return tpe.getResult();
} else {
Logging.errorPrint(error);
}
return null;
}
Aggregations