20 package net.sf.gridarta.model.match;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.Locale;
27 import nu.xom.Element;
30 import org.jetbrains.annotations.NotNull;
31 import org.jetbrains.annotations.Nullable;
138 final String localName = el.getLocalName();
139 if (localName ==
null || !localName.equals(
"GameObjectMatcher")) {
140 throw new ParsingException(
"wrong local element name: expected \"GameObjectMatcher\" but got \"" + localName +
"\"");
144 if (title ==
null || title.isEmpty()) {
147 if (title ==
null || title.isEmpty()) {
152 assert content !=
null;
156 if (env instanceof Element) {
160 envGameObjectMatcher =
null;
165 return new NamedGameObjectMatcher(systemMatcher ? 0 : editType,
id, title, systemMatcher, envGameObjectMatcher, matcher);
175 private static String
getLanguageTitle(@NotNull
final Node el, @NotNull
final String language) {
176 final Nodes nodes = el.query(
"title[lang('" + language +
"')]");
177 return nodes.size() == 0 ? null : nodes.get(0).getValue();
188 final String localName = el.getLocalName();
189 if (localName ==
null) {
236 final Collection<GameObjectMatcher> childMatchers =
new ArrayList<>();
237 for (
int i = 0; i < el.getChildCount(); i++) {
238 final Node childNode = el.getChild(i);
239 if (childNode instanceof Element) {
243 return childMatchers;
255 if (type.equals(
"string")) {
258 if (type.equals(
"int")) {
261 throw new AssertionError(
"impossible value '" + type +
"' for XML_ATTRIB_ATTRIBUTE_TYPE");
274 final int[] types =
new int[typeNrs.length];
275 for (
int i = 0; i < types.length; i++) {
277 types[i] = Integer.parseInt(typeNrs[i]);
278 }
catch (
final NumberFormatException ex) {
292 private static Node
xpathEvaluate(@NotNull
final Node el, @NotNull
final String xpathExpression) {
293 final Nodes nodes = el.query(xpathExpression);
294 assert nodes.size() <= 1;
295 return nodes.size() == 0 ? null : nodes.get(0);