New chooser plugin, handles Spell Level.
| 46 | * New chooser plugin, handles Spell Level. |
| 47 | */ |
| 48 | public class SpellLevelToken extends AbstractTokenWithSeparator<CDOMObject> |
| 49 | implements CDOMSecondaryToken<CDOMObject>, Chooser<SpellLevel> |
| 50 | { |
| 51 | |
| 52 | @Override |
| 53 | public String getParentToken() |
| 54 | { |
| 55 | return "CHOOSE"; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | protected char separator() |
| 60 | { |
| 61 | return '|'; |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public ParseResult parseTokenWithSeparator(LoadContext context, CDOMObject obj, String value) |
| 66 | { |
| 67 | int pipeLoc = value.lastIndexOf('|'); |
| 68 | String activeValue; |
| 69 | String title; |
| 70 | if (pipeLoc == -1) |
| 71 | { |
| 72 | activeValue = value; |
| 73 | title = getDefaultTitle(); |
| 74 | } |
| 75 | else |
| 76 | { |
| 77 | String titleString = value.substring(pipeLoc + 1); |
| 78 | if (titleString.startsWith("TITLE=")) |
| 79 | { |
| 80 | title = titleString.substring(6); |
| 81 | if (title.startsWith("\"")) |
| 82 | { |
| 83 | title = title.substring(1, title.length() - 1); |
| 84 | } |
| 85 | activeValue = value.substring(0, pipeLoc); |
| 86 | } |
| 87 | else |
| 88 | { |
| 89 | activeValue = value; |
| 90 | title = getDefaultTitle(); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | pipeLoc = value.indexOf('|'); |
| 95 | |
| 96 | ParsingSeparator sep = new ParsingSeparator(activeValue, '|'); |
| 97 | sep.addGroupingPair('[', ']'); |
| 98 | sep.addGroupingPair('(', ')'); |
| 99 | |
| 100 | if (!sep.hasNext()) |
| 101 | { |
| 102 | return new ParseResult.Fail("Found no arguments in " + getFullName() + ": " + value); |
| 103 | } |
| 104 | List<SpellLevelInfo> sliList = new ArrayList<>(); |
| 105 | while (sep.hasNext()) |
nothing calls this directly
no outgoing calls
no test coverage detected