use of pcgen.core.ChronicleEntry in project pcgen by PCGen.
the class CampaignHistoryToken method getToken.
@Override
public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
StringTokenizer aTok = new StringTokenizer(tokenSource, ".");
aTok.nextToken();
Visibility visibility = Visibility.VISIBLE;
String entryIndex = aTok.nextToken();
if (!StringUtils.isNumeric(entryIndex)) {
if (entryIndex.equals("ALL")) {
visibility = Visibility.ALL;
} else if (entryIndex.equals("HIDDEN")) {
visibility = Visibility.HIDDEN;
} else if (!entryIndex.equals("VISIBLE")) {
Logging.log(Logging.LST_ERROR, "Invalid visibility entry '" + entryIndex + "'. Should be one of ALL, VISIBLE or HIDDEN. Token was " + tokenSource);
return "";
}
entryIndex = aTok.nextToken();
}
if (!StringUtils.isNumeric(entryIndex)) {
Logging.log(Logging.LST_ERROR, "Invalid position entry '" + entryIndex + "', it should be a number. Token was " + tokenSource);
return "";
}
int index = Integer.parseInt(entryIndex);
ChronicleEntry entry = getTargetChronicleEntry(index, visibility, pc.getDisplay());
if (entry == null) {
return "";
}
String token = (aTok.hasMoreTokens()) ? aTok.nextToken() : "TEXT";
String value = getChronicleValue(entry, token.toUpperCase());
if (value == null) {
Logging.log(Logging.LST_ERROR, "Invalid property '" + token + "'. Token was " + tokenSource);
return "";
}
return value;
}
Aggregations