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

Method parseStatLine

code/src/java/pcgen/io/PCGVer2Parser.java:4192–4244  ·  view source on GitHub ↗
(final String line)

Source from the content-addressed store, hash-verified

4190 * ###############################################################
4191 */
4192 private void parseStatLine(final String line) throws PCGParseException
4193 {
4194 final PCGTokenizer tokens;
4195
4196 try
4197 {
4198 tokens = new PCGTokenizer(line);
4199 }
4200 catch (PCGParseException pcgpex)
4201 {
4202 /*
4203 * Ability scores are critical for characters,
4204 * need to stop the load process
4205 *
4206 * Thomas Behr 09-09-02
4207 */
4208 throw new PCGParseException("parseStatLine", line, pcgpex.getMessage(), pcgpex); //$NON-NLS-1$
4209 }
4210
4211 final Iterator<PCGElement> it = tokens.getElements().iterator();
4212
4213 if (it.hasNext())
4214 {
4215 PCGElement element = it.next();
4216 final String statName = element.getText();
4217 PCStat stat =
4218 Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCStat.class, statName);
4219
4220 if ((stat != null) && seenStats.add(statName.toUpperCase()) && (it.hasNext()))
4221 {
4222 element = it.next();
4223
4224 try
4225 {
4226 thePC.setStat(stat, Integer.parseInt(element.getText()));
4227 }
4228 catch (NumberFormatException nfe)
4229 {
4230 throw new PCGParseException("parseStatLine", line, nfe.getMessage(), nfe); //$NON-NLS-1$
4231 }
4232 }
4233 else
4234 {
4235 final String message = "Invalid attribute specification. " + "Cannot load character.";
4236 throw new PCGParseException("parseStatLine", line, message, null); //$NON-NLS-1$
4237 }
4238 }
4239 else
4240 {
4241 final String message = "Invalid attribute specification. " + "Cannot load character.";
4242 throw new PCGParseException("parseStatLine", line, message, null); //$NON-NLS-1$
4243 }
4244 }
4245
4246 private void parseTabNameLine(final String line)
4247 {

Callers 1

parseCachedLinesMethod · 0.95

Calls 12

getElementsMethod · 0.95
getTextMethod · 0.95
getContextMethod · 0.95
setStatMethod · 0.80
parseIntMethod · 0.80
getMessageMethod · 0.65
getReferenceContextMethod · 0.65
addMethod · 0.65
iteratorMethod · 0.45
hasNextMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected