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

Method subParse

code/src/java/plugin/lsttokens/SpelllevelLst.java:132–199  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj,
		Class<CL> tagType, String tokString, String spellString, List<Prerequisite> prereqs)

Source from the content-addressed store, hash-verified

130 }
131
132 private <CL extends Loadable & CDOMList<Spell>> ParseResult subParse(LoadContext context, CDOMObject obj,
133 Class<CL> tagType, String tokString, String spellString, List<Prerequisite> prereqs)
134 {
135 int equalLoc = tokString.indexOf(Constants.EQUALS);
136 if (equalLoc == -1)
137 {
138 return new ParseResult.Fail("Expected an = in SPELLLEVEL " + "definition: " + tokString);
139 }
140
141 String casterString = tokString.substring(0, equalLoc);
142 String spellLevel = tokString.substring(equalLoc + 1);
143 Integer splLevel;
144 try
145 {
146 splLevel = Integer.decode(spellLevel);
147 }
148 catch (NumberFormatException nfe)
149 {
150 return new ParseResult.Fail("Expected a number for SPELLLEVEL, found: " + spellLevel);
151 }
152
153 ParseResult pr = checkSeparatorsAndNonEmpty(',', casterString);
154 if (!pr.passed())
155 {
156 return pr;
157 }
158
159 StringTokenizer clTok = new StringTokenizer(casterString, Constants.COMMA);
160 List<CDOMReference<? extends CDOMList<Spell>>> slList = new ArrayList<>();
161 while (clTok.hasMoreTokens())
162 {
163 String classString = clTok.nextToken();
164 CDOMReference<CL> ref;
165 if (classString.startsWith("SPELLCASTER."))
166 {
167 /*
168 * This is actually a TYPE
169 */
170 ref = context.getReferenceContext().getCDOMTypeReference(tagType, classString.substring(12));
171 }
172 else
173 {
174 ref = context.getReferenceContext().getCDOMReference(tagType, classString);
175 }
176 slList.add(ref);
177 }
178
179 pr = checkForIllegalSeparator(',', spellString);
180 if (!pr.passed())
181 {
182 return pr;
183 }
184
185 StringTokenizer spTok = new StringTokenizer(spellString, ",");
186
187 while (spTok.hasMoreTokens())
188 {
189 String spellName = spTok.nextToken();

Callers 1

Calls 15

passedMethod · 0.95
getTokenNameMethod · 0.95
hasMoreTokensMethod · 0.80
nextTokenMethod · 0.80
getCDOMTypeReferenceMethod · 0.80
getCDOMReferenceMethod · 0.80
indexOfMethod · 0.65
getReferenceContextMethod · 0.65
addMethod · 0.65
addToListMethod · 0.65
getListContextMethod · 0.65

Tested by

no test coverage detected