MCPcopy Create free account
hub / github.com/PCGen/pcgen / parseNonEmptyToken

Method parseNonEmptyToken

code/src/java/plugin/lsttokens/TypeLst.java:44–132  ·  view source on GitHub ↗
(LoadContext context, CDOMObject cdo, String value)

Source from the content-addressed store, hash-verified

42 }
43
44 @Override
45 protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject cdo, String value)
46 {
47 if (value.startsWith(Constants.LST_DOT_CLEAR))
48 {
49 context.getObjectContext().removeList(cdo, ListKey.TYPE);
50 if (value.length() == 6)
51 {
52 return ParseResult.SUCCESS;
53 }
54 else if (value.charAt(6) == '.')
55 {
56 value = value.substring(7);
57 ParseResult pr = checkNonEmpty(value);
58 if (!pr.passed())
59 {
60 return new ParseResult.Fail(
61 getTokenName() + "started with .CLEAR. but expected to have a Type after .: " + value);
62 }
63 }
64 else
65 {
66 return new ParseResult.Fail(
67 getTokenName() + "started with .CLEAR but expected next character to be .: " + value);
68 }
69 }
70 ParseResult pr = checkForIllegalSeparator('.', value);
71 if (!pr.passed())
72 {
73 return pr;
74 }
75
76 StringTokenizer aTok = new StringTokenizer(value, Constants.DOT);
77
78 boolean bRemove = false;
79 boolean bAdd = false;
80 while (aTok.hasMoreTokens())
81 {
82 final String aType = aTok.nextToken();
83 if ("ADD".equals(aType))
84 {
85 if (bRemove)
86 {
87 return new ParseResult.Fail("Non-sensical use of .REMOVE.ADD. in " + getTokenName() + ": " + value);
88 }
89 bRemove = false;
90 bAdd = true;
91 }
92 else if ("REMOVE".equals(aType))
93 {
94 if (bAdd)
95 {
96 return new ParseResult.Fail("Non-sensical use of .ADD.REMOVE. in " + getTokenName() + ": " + value);
97 }
98 bRemove = true;
99 }
100 else if ("CLEAR".equals(aType))
101 {

Callers

nothing calls this directly

Calls 15

passedMethod · 0.95
getTokenNameMethod · 0.95
getConstantMethod · 0.95
checkNonEmptyMethod · 0.80
hasMoreTokensMethod · 0.80
nextTokenMethod · 0.80
removeListMethod · 0.65
getObjectContextMethod · 0.65
equalsMethod · 0.65
removeFromListMethod · 0.65
getListChangesMethod · 0.65
getAddedMethod · 0.65

Tested by

no test coverage detected