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

Method parse

code/src/java/plugin/lsttokens/gamemode/IconToken.java:44–84  ·  view source on GitHub ↗
(GameMode gameMode, String value, URI source)

Source from the content-addressed store, hash-verified

42 }
43
44 @Override
45 public boolean parse(GameMode gameMode, String value, URI source)
46 {
47 final StringTokenizer aTok = new StringTokenizer(value, Constants.PIPE, false);
48
49 if (aTok.countTokens() < 2)
50 {
51 Logging.log(Logging.LST_ERROR,
52 getTokenName() + " expecting '|', format is: " + "EquipType|IconPath was: " + value);
53 return false;
54 }
55
56 if (aTok.countTokens() > 3)
57 {
58 Logging.log(Logging.LST_ERROR,
59 getTokenName() + " too many '|', format is: " + "EquipType|IconPath|Priority was: " + value);
60 return false;
61 }
62
63 final String equipType = aTok.nextToken();
64 final String iconPath = aTok.nextToken();
65 int priority = 10;
66 if (aTok.hasMoreElements())
67 {
68 String priorityToken = aTok.nextToken();
69 try
70 {
71 priority = Integer.parseInt(priorityToken);
72 }
73 catch (NumberFormatException ex)
74 {
75 Logging.log(Logging.LST_ERROR,
76 getTokenName() + " expected an integer priority . Found: " + priorityToken + " in " + value);
77 return false;
78 }
79
80 }
81
82 gameMode.setEquipTypeIcon(equipType.intern(), iconPath.intern(), priority);
83 return true;
84 }
85
86}

Callers 2

testValidSyntaxMethod · 0.95
testInValidSyntaxMethod · 0.95

Calls 5

logMethod · 0.95
getTokenNameMethod · 0.95
nextTokenMethod · 0.80
parseIntMethod · 0.80
setEquipTypeIconMethod · 0.80

Tested by 2

testValidSyntaxMethod · 0.76
testInValidSyntaxMethod · 0.76