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

Method process

code/src/java/plugin/lsttokens/InfoLst.java:115–158  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj)

Source from the content-addressed store, hash-verified

113 }
114
115 @Override
116 public boolean process(LoadContext context, CDOMObject obj)
117 {
118 boolean returnValue = true;
119 MapKey<CaseInsensitiveString, MessageFormat> infoKey = MapKey.INFO;
120 MapKey<CaseInsensitiveString, String[]> infoVarKey = MapKey.INFOVARS;
121 Set<CaseInsensitiveString> infoKeys = obj.getKeysFor(infoKey);
122 Set<CaseInsensitiveString> infoVarKeys = obj.getKeysFor(infoVarKey);
123 //Check if INFO needed INFOVARS
124 for (CaseInsensitiveString s : infoKeys)
125 {
126 MessageFormat mf = obj.get(infoKey, s);
127 int required = MessageFormatUtilities.getRequriedArgumentCount(mf);
128 if (required > 0)
129 {
130 String[] vars = obj.get(infoVarKey, s);
131 if (vars == null)
132 {
133 Logging.errorPrint(obj.getClass().getSimpleName() + ' ' + obj.getKeyName()
134 + " was loaded with INFO: " + s + " that requires " + required + " arguments, but no arguments"
135 + " in INFOVARS were provided", context);
136 returnValue = false;
137 }
138 else if (vars.length != required)
139 {
140 Logging.errorPrint(obj.getClass().getSimpleName() + ' ' + obj.getKeyName()
141 + " was loaded with INFO: " + s + " that requires " + required + " arguments, but "
142 + vars.length + " arguments in INFOVARS were provided", context);
143 returnValue = false;
144 }
145 }
146 }
147 //Check if "Extra" INFOVARS were provided
148 for (CaseInsensitiveString s : infoVarKeys)
149 {
150 if (!infoKeys.contains(s))
151 {
152 Logging.errorPrint(obj.getClass().getSimpleName() + ' ' + obj.getKeyName()
153 + " was loaded with INFOVARS: " + s + " but no matching INFO was provided", context);
154 returnValue = false;
155 }
156 }
157 return returnValue;
158 }
159
160 @Override
161 public Class<CDOMObject> getDeferredTokenClass()

Callers

nothing calls this directly

Calls 7

errorPrintMethod · 0.95
getSimpleNameMethod · 0.80
getMethod · 0.65
getKeyNameMethod · 0.65
containsMethod · 0.65
getKeysForMethod · 0.45

Tested by

no test coverage detected