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

Method parse

code/src/java/plugin/lsttokens/eqslot/ContainsToken.java:22–66  ·  view source on GitHub ↗
(EquipSlot eqSlot, String value, String gameMode)

Source from the content-addressed store, hash-verified

20 }
21
22 @Override
23 public boolean parse(EquipSlot eqSlot, String value, String gameMode)
24 {
25 if (value == null || value.isEmpty())
26 {
27 Logging.log(Logging.LST_ERROR, "Invalid empty " + getTokenName() + " value.");
28 return false;
29 }
30
31 final StringTokenizer token = new StringTokenizer(value, Constants.EQUALS);
32
33 if (token.countTokens() < 2)
34 {
35 Logging.log(Logging.LST_ERROR,
36 "Missing = in value '" + value + "' of " + getTokenName() + Constants.COLON + value);
37 return false;
38 }
39 else if (token.countTokens() > 2)
40 {
41 Logging.log(Logging.LST_ERROR,
42 "Too many = in value '" + value + "' of " + getTokenName() + Constants.COLON + value);
43 return false;
44 }
45
46 final String type = token.nextToken();
47 final String numString = token.nextToken();
48 final int num;
49
50 if (numString.equals("*"))
51 {
52 num = 9999;
53 }
54 else
55 {
56 num = Integer.parseInt(numString);
57 }
58
59 final String[] types = type.split(",");
60 for (String pair : types)
61 {
62 eqSlot.addContainedType(pair.intern());
63 }
64 eqSlot.setContainNum(num);
65 return true;
66 }
67}

Callers

nothing calls this directly

Calls 9

logMethod · 0.95
getTokenNameMethod · 0.95
nextTokenMethod · 0.80
parseIntMethod · 0.80
addContainedTypeMethod · 0.80
setContainNumMethod · 0.80
isEmptyMethod · 0.65
equalsMethod · 0.65
splitMethod · 0.45

Tested by

no test coverage detected