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

Method parseTokenWithSeparator

code/src/java/plugin/lsttokens/MoveLst.java:54–86  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj, String value)

Source from the content-addressed store, hash-verified

52 }
53
54 @Override
55 protected ParseResult parseTokenWithSeparator(LoadContext context, CDOMObject obj, String value)
56 {
57 if (obj instanceof Ungranted)
58 {
59 return new ParseResult.Fail(
60 "Cannot use " + getTokenName() + " on an Ungranted object type: " + obj.getClass().getSimpleName());
61 }
62 StringTokenizer moves = new StringTokenizer(value, Constants.COMMA);
63
64 while (moves.countTokens() > 1)
65 {
66 MovementType type = MovementType.getConstant(moves.nextToken());
67 String mod = moves.nextToken();
68 try
69 {
70 SimpleMovement cm =
71 new SimpleMovement(type, Integer.parseInt(mod));
72 context.getObjectContext().addToList(obj,
73 ListKey.SIMPLEMOVEMENT, cm);
74 }
75 catch (NumberFormatException e)
76 {
77 return new ParseResult.Fail(
78 "Movement must be a number, found: " + mod);
79 }
80 }
81 if (moves.countTokens() != 0)
82 {
83 return new ParseResult.Fail("Badly formed MOVE token " + "(extra value at end of list): " + value);
84 }
85 return ParseResult.SUCCESS;
86 }
87
88 @Override
89 public String[] unparse(LoadContext context, CDOMObject obj)

Callers

nothing calls this directly

Calls 7

getTokenNameMethod · 0.95
getConstantMethod · 0.95
getSimpleNameMethod · 0.80
nextTokenMethod · 0.80
parseIntMethod · 0.80
addToListMethod · 0.65
getObjectContextMethod · 0.65

Tested by

no test coverage detected