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

Method getToken

code/src/java/pcgen/io/exporttoken/FollowerToken.java:53–92  ·  view source on GitHub ↗
(String tokenSource, PlayerCharacter pc, ExportHandler eh)

Source from the content-addressed store, hash-verified

51 }
52
53 @Override
54 public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh)
55 {
56 /* FOLLOWER%.subtag stuff handled in here*/
57
58 // New token syntax FOLLOWER.x instead of FOLLOWERx
59 StringTokenizer aTok = new StringTokenizer(tokenSource, ".");
60 String fString = aTok.nextToken(); // FOLLOWER
61 final int i;
62
63 if ("FOLLOWER".equals(fString))
64 {
65 i = Integer.parseInt(aTok.nextToken());
66 }
67 else
68 {
69 Logging.errorPrint("Old syntax FOLLOWERx will be replaced for FOLLOWER.x");
70
71 i = Integer.parseInt(tokenSource.substring(8, tokenSource.indexOf('.')));
72 }
73
74 StringBuilder restString = new StringBuilder();
75 while (aTok.hasMoreTokens())
76 {
77 restString.append(".").append(aTok.nextToken());
78 }
79 if (restString.indexOf(".") == 0)
80 {
81 restString = restString.deleteCharAt(0);
82 }
83
84 String result = "";
85 final List<Follower> followers = new ArrayList<>(pc.getDisplay().getFollowerList());
86 if (i < followers.size())
87 {
88 result = FollowerToken.getFollowerOutput(eh, restString.toString(), followers.get(i));
89 }
90
91 return result;
92 }
93
94 /**
95 * Process a token for a follower (must already be loaded) and return the output.

Callers

nothing calls this directly

Calls 13

errorPrintMethod · 0.95
getFollowerOutputMethod · 0.95
nextTokenMethod · 0.80
parseIntMethod · 0.80
hasMoreTokensMethod · 0.80
equalsMethod · 0.65
indexOfMethod · 0.65
sizeMethod · 0.65
toStringMethod · 0.65
getMethod · 0.65
appendMethod · 0.45
getFollowerListMethod · 0.45

Tested by

no test coverage detected