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

Method parseToken

code/src/java/plugin/lsttokens/BonusLst.java:59–81  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj, String value)

Source from the content-addressed store, hash-verified

57 }
58
59 @Override
60 public ParseResult parseToken(LoadContext context, CDOMObject obj, String value)
61 {
62 if (obj instanceof Ungranted)
63 {
64 return new ParseResult.Fail(
65 "Cannot use " + getTokenName() + " on an Ungranted object type: " + obj.getClass().getSimpleName());
66 }
67 if (value.contains("PREAPPLY:"))
68 {
69 return new ParseResult.Fail(
70 "Use of PREAPPLY prohibited on a BONUS , " + "please use TEMPBONUS with: " + value);
71 }
72 final String v = value.replaceAll(Pattern.quote("<this>"), obj.getKeyName());
73 BonusObj bon = Bonus.newBonus(context, v);
74 if (bon == null)
75 {
76 return new ParseResult.Fail(getTokenName() + " was given invalid bonus: " + value);
77 }
78 bon.setTokenSource(getTokenName());
79 context.getObjectContext().addToList(obj, ListKey.BONUS, bon);
80 return ParseResult.SUCCESS;
81 }
82
83 @Override
84 public String[] unparse(LoadContext context, CDOMObject obj)

Callers

nothing calls this directly

Calls 9

getTokenNameMethod · 0.95
newBonusMethod · 0.95
setTokenSourceMethod · 0.95
getSimpleNameMethod · 0.80
containsMethod · 0.65
getKeyNameMethod · 0.65
addToListMethod · 0.65
getObjectContextMethod · 0.65
replaceAllMethod · 0.45

Tested by

no test coverage detected