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

Method getToken

code/src/java/plugin/exporttokens/SpellBookToken.java:40–93  ·  view source on GitHub ↗
(String tokenSource, CharacterDisplay display, ExportHandler eh)

Source from the content-addressed store, hash-verified

38 }
39
40 @Override
41 public String getToken(String tokenSource, CharacterDisplay display, ExportHandler eh)
42 {
43 String retString = "";
44
45 final StringTokenizer aTok = new StringTokenizer(tokenSource, ".");
46
47 // Ignore the token itself
48 aTok.nextToken();
49
50 final int bookNum = Integer.parseInt(aTok.nextToken());
51 String aLabel = "NAME";
52
53 if (aTok.hasMoreTokens())
54 {
55 aLabel = aTok.nextToken();
56 }
57
58 SpellBook book = null;
59 if (bookNum >= 0 && bookNum < display.getSpellBookCount())
60 {
61 String bookName = display.getSpellBookNames().get(bookNum);
62 book = display.getSpellBookByName(bookName);
63 }
64 if (book != null)
65 {
66 if ("NAME".equals(aLabel))
67 {
68 retString = book.getName();
69 }
70 else if ("NUMPAGES".equals(aLabel))
71 {
72 retString = String.valueOf(book.getNumPages());
73 }
74 else if ("NUMPAGESUSED".equals(aLabel))
75 {
76 retString = String.valueOf(book.getNumPagesUsed());
77 }
78 else if ("NUMSPELLS".equals(aLabel))
79 {
80 retString = String.valueOf(book.getNumSpells());
81 }
82 else if ("PAGEFORMULA".equals(aLabel))
83 {
84 retString = book.getPageFormula().toString();
85 }
86 else if ("TYPE".equals(aLabel))
87 {
88 retString = book.getTypeName();
89 }
90 }
91
92 return retString;
93 }
94
95}

Callers

nothing calls this directly

Calls 15

getNameMethod · 0.95
getNumPagesMethod · 0.95
getNumPagesUsedMethod · 0.95
getNumSpellsMethod · 0.95
getPageFormulaMethod · 0.95
getTypeNameMethod · 0.95
nextTokenMethod · 0.80
parseIntMethod · 0.80
hasMoreTokensMethod · 0.80
getMethod · 0.65
equalsMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected