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

Method parseToken

code/src/java/plugin/lsttokens/pcclass/HdToken.java:39–57  ·  view source on GitHub ↗
(LoadContext context, PCClass pcc, String value)

Source from the content-addressed store, hash-verified

37 }
38
39 @Override
40 public ParseResult parseToken(LoadContext context, PCClass pcc, String value)
41 {
42 try
43 {
44 int in = Integer.parseInt(value);
45 if (in <= 0)
46 {
47 return new ParseResult.Fail(getTokenName() + " must be an integer > 0");
48 }
49 context.getObjectContext().put(pcc, ObjectKey.LEVEL_HITDIE, new HitDie(in));
50 return ParseResult.SUCCESS;
51 }
52 catch (NumberFormatException nfe)
53 {
54 return new ParseResult.Fail(
55 getTokenName() + " expected an integer. Tag must be of the form: " + getTokenName() + ":<int>");
56 }
57 }
58
59 @Override
60 public String[] unparse(LoadContext context, PCClass pcc)

Callers

nothing calls this directly

Calls 4

getTokenNameMethod · 0.95
parseIntMethod · 0.80
putMethod · 0.65
getObjectContextMethod · 0.65

Tested by

no test coverage detected