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

Method subParse

code/src/java/plugin/lsttokens/SpellknownLst.java:143–211  ·  view source on GitHub ↗

Parse the tag contents after the SPELLKNOWN:CLASS| section. @param context the context under which the tag is being parsed. @param obj the obj The object owning the tag. @param tagType the type of object the tag creates @param tokString the tok string The string defining the caster type/class and s

(LoadContext context, CDOMObject obj,
		Class<CL> tagType, String tokString, String spellString, List<Prerequisite> prereqs)

Source from the content-addressed store, hash-verified

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