use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class SourceLoader method parseLine.
public static void parseLine(LoadContext context, String lstLine, URI sourceFile) {
final StringTokenizer colToken = new StringTokenizer(lstLine, SystemLoader.TAB_DELIM);
while (colToken.hasMoreTokens()) {
String colString = colToken.nextToken().trim();
try {
if (context.addStatefulToken(colString)) {
context.commit();
} else {
context.rollback();
Logging.replayParsedMessages();
}
Logging.clearParseMessages();
} catch (PersistenceLayerException e) {
Logging.errorPrint("Error parsing source: " + colString + " in: " + sourceFile);
}
}
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class CodeControlLoader method parseLine.
@Override
public void parseLine(LoadContext context, String inputLine, URI sourceURI) throws PersistenceLayerException {
int sepLoc = inputLine.indexOf('\t');
if (sepLoc != -1) {
Logging.errorPrint("Unsure what to do with line with multiple tokens: " + inputLine + " in file: " + sourceURI);
return;
}
try {
AbstractReferenceContext refContext = context.getReferenceContext();
CodeControl controller = refContext.constructNowIfNecessary(CodeControl.class, "Controller");
LstUtils.processToken(context, controller, sourceURI, inputLine);
} catch (PersistenceLayerException ple) {
Logging.errorPrint("Exception in Load: ", ple);
}
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class PreParserFactory method parse.
public static List<Prerequisite> parse(final List<String> preStrings) {
final List<Prerequisite> ret = new ArrayList<>(preStrings.size());
for (String prestr : preStrings) {
try {
final PreParserFactory factory = PreParserFactory.getInstance();
final Prerequisite prereq = factory.parse(prestr);
ret.add(prereq);
} catch (PersistenceLayerException ple) {
//The message is now produced at a lower level, and thus has to be localised there.
Logging.errorPrint(ple.getMessage(), ple);
//Logging.errorPrintLocalised(PropertyFactory.getString("PrereqHandler.Unable_to_parse"), object); //$NON-NLS-1$
}
}
return ret;
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class AbstractPrerequisiteParser method parse.
/**
* Parses the PreRequisite.
*
* @param kind the kind of the prerequisite (less the "PRE" prefix).
* @param formula The body of the prerequisite.
* @param invertResult Whether the prerequisite should invert the result.
* @param overrideQualify
* if set true, this prerequisite will be enforced in spite
* of any "QUALIFY" tag that may be present.
* @return PreReq
* @throws PersistenceLayerException
*/
@Override
public Prerequisite parse(String kind, String formula, boolean invertResult, boolean overrideQualify) throws PersistenceLayerException {
// Check to make sure that this class can parse this token
boolean foundTag = false;
for (int i = 0; i < kindsHandled().length; i++) {
String arrayElement = kindsHandled()[i];
if (arrayElement.equalsIgnoreCase(kind)) {
foundTag = true;
break;
}
}
if (!foundTag) {
throw new PersistenceLayerException(this.getClass().getName() + " can not parse a Prerequisite tag of '" + kind + ":" + formula + "'");
}
// If we can parse this token then set the kind and invert flag.
Prerequisite prereq = new Prerequisite();
prereq.setKind(kind);
prereq.setOverrideQualify(overrideQualify);
return prereq;
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class AbstractPrerequisiteWriter method checkValidOperator.
protected void checkValidOperator(Prerequisite prereq, PrerequisiteOperator[] comparators) throws PersistenceLayerException {
StringBuilder comparatorString = new StringBuilder(25);
for (int i = 0; i < comparators.length; i++) {
PrerequisiteOperator comparator = comparators[i];
if (prereq.getOperator().equals(comparators[i])) {
return;
}
if (i > 0) {
comparatorString.append(", ");
}
comparatorString.append(comparator);
}
String kind = prereq.getKind();
if (kind == null) {
kind = "<NULL>";
}
throw new PersistenceLayerException("Cannot write token: LST syntax only supports " + comparatorString.toString() + " operators for PRE" + kind.toUpperCase() + ": " + prereq.toString());
}
Aggregations