use of pcgen.cdom.base.ChooseDriver in project pcgen by PCGen.
the class SAProcessor method act.
@Override
public SpecialAbility act(SpecialAbility sa, Object source) {
final String key = sa.getKeyName();
final int idx = key.indexOf("%CHOICE");
if (idx == -1) {
return sa;
}
StringBuilder sb = new StringBuilder(100);
sb.append(key.substring(0, idx));
if (source instanceof ChooseDriver) {
ChooseDriver object = (ChooseDriver) source;
if (pc.hasAssociations(object)) {
List<String> associationList = pc.getAssociationList(object);
Collections.sort(associationList);
sb.append(StringUtil.joinToStringBuilder(associationList, ", "));
}
} else {
Logging.errorPrint("In SpecialAbility resolution, " + "Error using object of type: " + source.getClass().getName() + " because " + "%CHOICE" + " was requested but the object does not support CHOOSE");
sb.append("<undefined>");
}
sb.append(key.substring(idx + 7));
return new SpecialAbility(sb.toString(), sa.getSADesc());
}
Aggregations