use of pcgen.cdom.base.CategorizedAbilitySelectionChooseInformation in project pcgen by PCGen.
the class AbilitySelectionToken method parseTokenWithSeparator.
protected ParseResult parseTokenWithSeparator(LoadContext context, ReferenceManufacturer<Ability> rm, CDOMSingleRef<AbilityCategory> acRef, CDOMObject obj, String value) {
int pipeLoc = value.lastIndexOf('|');
String activeValue;
String title;
if (pipeLoc == -1) {
activeValue = value;
title = getDefaultTitle();
} else {
String titleString = value.substring(pipeLoc + 1);
if (titleString.startsWith("TITLE=")) {
title = titleString.substring(6);
if (title.startsWith("\"")) {
title = title.substring(1, title.length() - 1);
}
if (title == null || title.isEmpty()) {
return new ParseResult.Fail(getParentToken() + Constants.COLON + getTokenName() + " had TITLE= but no title: " + value, context);
}
activeValue = value.substring(0, pipeLoc);
} else {
activeValue = value;
title = getDefaultTitle();
}
}
PrimitiveCollection<Ability> prim = context.getChoiceSet(rm, activeValue);
if (prim == null) {
return ParseResult.INTERNAL_ERROR;
}
if (!prim.getGroupingState().isValid()) {
return new ParseResult.Fail("Non-sensical " + getFullName() + ": Contains ANY and a specific reference: " + value, context);
}
CollectionToAbilitySelection pcs = new CollectionToAbilitySelection(acRef, prim);
CategorizedAbilitySelectionChooseInformation tc = new CategorizedAbilitySelectionChooseInformation(getTokenName(), pcs);
tc.setTitle(title);
tc.setChoiceActor(this);
context.getObjectContext().put(obj, ObjectKey.CHOOSE_INFO, tc);
return ParseResult.SUCCESS;
}
Aggregations