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

Method getToken

code/src/java/plugin/exporttokens/deprecated/MiscToken.java:24–77  ·  view source on GitHub ↗
(String tokenSource, PlayerCharacter pc, ExportHandler eh)

Source from the content-addressed store, hash-verified

22 }
23
24 @Override
25 public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh)
26 {
27 String[] tokens = tokenSource.split(",", 2);
28 String tokenHead = tokens[0];
29 String sourceText = "\n";
30
31 if (tokens.length == 2)
32 {
33 sourceText = tokens[1];
34 }
35
36 String[] headTokens = tokenHead.split("\\.");
37 String subToken = headTokens[1];
38
39 PCStringKey key;
40 if ("FUNDS".equals(subToken))
41 {
42 key = PCStringKey.ASSETS;
43 }
44 else if ("COMPANIONS".equals(subToken))
45 {
46 key = PCStringKey.COMPANIONS;
47 }
48 else if ("MAGIC".equals(subToken))
49 {
50 key = PCStringKey.MAGIC;
51 }
52 else
53 {
54 return Constants.EMPTY_STRING;
55 }
56
57 StringBuilder buf = new StringBuilder();
58 String[] stringList = pc.getSafeStringFor(key).split("\r?\n");
59 if (3 == headTokens.length)
60 {
61 buf.append(stringList[Integer.parseInt(headTokens[2])]);
62 }
63 else
64 {
65 // This should be deprecated now
66 // For tags like the following in FOR loops
67 // will add after the ',' at end of each line
68 // |MISC.MAGIC,</fo:block><fo:block font-size="7pt">|
69 for (String str : stringList)
70 {
71 buf.append(str);
72 buf.append(sourceText);
73 }
74 }
75
76 return buf.toString().trim();
77 }
78}

Callers

nothing calls this directly

Calls 7

parseIntMethod · 0.80
trimMethod · 0.80
equalsMethod · 0.65
toStringMethod · 0.65
splitMethod · 0.45
getSafeStringForMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected