use of pcgen.gui2.converter.event.TokenProcessorPlugin in project pcgen by PCGen.
the class TokenConverter method process.
public static String process(TokenProcessEvent tpe) {
Class<?> cl = tpe.getPrimary().getClass();
String key = tpe.getKey();
ensureCategoryExists(tpe);
List<TokenProcessorPlugin> tokens = getTokens(cl, key);
String error = "";
try {
if (tokens != null) {
for (TokenProcessorPlugin converter : tokens) {
error += converter.process(tpe);
if (tpe.isConsumed()) {
break;
}
}
}
if (!tpe.isConsumed()) {
error += defaultProc.process(tpe);
}
} catch (Exception ex) {
Logging.errorPrint("Parse of " + tpe.getKey() + ":" + tpe.getValue() + " failed");
ex.printStackTrace();
}
return tpe.isConsumed() ? null : error;
}
use of pcgen.gui2.converter.event.TokenProcessorPlugin in project pcgen by PCGen.
the class TokenConverter method getTokens.
public static List<TokenProcessorPlugin> getTokens(Class<?> cl, String name) {
List<TokenProcessorPlugin> list = tokenCache.getListFor(cl, name);
if (!cached.containsKey(cl, name)) {
for (Iterator<TokenProcessorPlugin> it = new ConverterIterator(cl, name); it.hasNext(); ) {
TokenProcessorPlugin token = it.next();
tokenCache.addToListFor(cl, name, token);
}
list = tokenCache.getListFor(cl, name);
cached.put(cl, name, Boolean.TRUE);
}
return list;
}
Aggregations