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

Method getToken

code/src/java/plugin/exporttokens/VarToken.java:47–100  ·  view source on GitHub ↗
(String tokenSource, PlayerCharacter pc, ExportHandler eh)

Source from the content-addressed store, hash-verified

45 }
46
47 @Override
48 public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh)
49 {
50 boolean isMin = tokenSource.lastIndexOf(".MINVAL") >= 0;
51 boolean isInt = tokenSource.lastIndexOf(".INTVAL") >= 0;
52 boolean isSign = (tokenSource.lastIndexOf(".SIGN") >= 0);
53 if (tokenSource.lastIndexOf(".NOSIGN") >= 0)
54 {
55 isSign = false;
56 Logging.errorPrint(".NOSIGN in output token " + tokenSource + " is deprecated. "
57 + "The default output format is unsigned.");
58 }
59
60 String workingSource = tokenSource;
61 // clear out the gunk
62 if (isMin)
63 {
64 workingSource = workingSource.replaceAll(".MINVAL", "");
65 }
66 if (isInt)
67 {
68 workingSource = workingSource.replaceAll(".INTVAL", "");
69 }
70 workingSource = workingSource.replaceAll(".NOSIGN", "");
71 workingSource = workingSource.replaceAll(".SIGN", "");
72
73 StringTokenizer aTok = new StringTokenizer(workingSource, ".");
74 aTok.nextToken(); //this should be VAR
75
76 StringBuilder varName = new StringBuilder();
77
78 if (aTok.hasMoreElements())
79 {
80 varName.append(aTok.nextToken());
81 }
82 while (aTok.hasMoreElements())
83 {
84 varName.append('.').append(aTok.nextToken());
85 }
86
87 if (isInt)
88 {
89 if (isSign)
90 {
91 return Delta.toString(pc.getVariable(varName.toString(), !isMin).intValue());
92 }
93 return String.valueOf(pc.getVariable(varName.toString(), !isMin).intValue());
94 }
95 if (isSign)
96 {
97 return Delta.toString((float) pc.getVariable(varName.toString(), !isMin));
98 }
99 return String.valueOf(pc.getVariable(varName.toString(), !isMin));
100 }
101}

Callers

nothing calls this directly

Calls 10

errorPrintMethod · 0.95
toStringMethod · 0.95
nextTokenMethod · 0.80
intValueMethod · 0.80
lastIndexOfMethod · 0.65
getVariableMethod · 0.65
toStringMethod · 0.65
replaceAllMethod · 0.45
appendMethod · 0.45
valueOfMethod · 0.45

Tested by

no test coverage detected