New chooser plugin, handles feats.
| 45 | * New chooser plugin, handles feats. |
| 46 | */ |
| 47 | public class ChooseFeatToken extends AbstractTokenWithSeparator<CDOMObject> |
| 48 | implements CDOMSecondaryToken<CDOMObject>, Chooser<Ability> |
| 49 | { |
| 50 | |
| 51 | @Override |
| 52 | public String getParentToken() |
| 53 | { |
| 54 | return "CHOOSE"; |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | protected char separator() |
| 59 | { |
| 60 | return '|'; |
| 61 | } |
| 62 | |
| 63 | protected ParseResult parseTokenWithSeparator(LoadContext context, ReferenceManufacturer<Ability> rm, |
| 64 | CDOMObject obj, String value) |
| 65 | { |
| 66 | int pipeLoc = value.lastIndexOf('|'); |
| 67 | String activeValue; |
| 68 | String title; |
| 69 | if (pipeLoc == -1) |
| 70 | { |
| 71 | activeValue = value; |
| 72 | title = getDefaultTitle(); |
| 73 | } |
| 74 | else |
| 75 | { |
| 76 | String titleString = value.substring(pipeLoc + 1); |
| 77 | if (titleString.startsWith("TITLE=")) |
| 78 | { |
| 79 | title = titleString.substring(6); |
| 80 | if (title.startsWith("\"")) |
| 81 | { |
| 82 | title = title.substring(1, title.length() - 1); |
| 83 | } |
| 84 | activeValue = value.substring(0, pipeLoc); |
| 85 | if (title.isEmpty()) |
| 86 | { |
| 87 | return new ParseResult.Fail( |
| 88 | getParentToken() + Constants.COLON + getTokenName() + " had TITLE= but no title: " + value); |
| 89 | } |
| 90 | } |
| 91 | else |
| 92 | { |
| 93 | activeValue = value; |
| 94 | title = getDefaultTitle(); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | PrimitiveCollection<Ability> coll = context.getChoiceSet(rm, activeValue); |
| 99 | if (coll == null) |
| 100 | { |
| 101 | return ParseResult.INTERNAL_ERROR; |
| 102 | } |
| 103 | if (!coll.getGroupingState().isValid()) |
| 104 | { |
nothing calls this directly
no outgoing calls
no test coverage detected