protected Map<String, String> getMatchingNodes(XmlPullParser xpp, ActionArgument[] args) throws Exception { // This is a case-insensitive search! List<String> names = new ArrayList<>(); for (ActionArgument argument : args) { names.add(argument.getName().toUpperCase(Locale.ROOT)); for (String alias : Arrays.asList(argument.getAliases())) { names.add(alias.toUpperCase(Locale.ROOT)); } } Map<String, String> matches = new HashMap<>(); String enclosingTag = xpp.getName(); int event; do { event = xpp.next(); if(event == XmlPullParser.START_TAG && names.contains(xpp.getName().toUpperCase(Locale.ROOT))) { matches.put(xpp.getName(), xpp.nextText()); } } while (event != XmlPullParser.END_DOCUMENT && (event != XmlPullParser.END_TAG || !xpp.getName().equals(enclosingTag))); if (matches.size() < args.length) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "Invalid number of input or output arguments in XML message, expected " + args.length + " but found " + matches.size() ); } return matches; }
/** * Finds all element nodes in the list that match any argument name or argument * alias, throws {@link ActionException} if not all arguments were found. */ protected List<Node> getMatchingNodes(NodeList nodeList, ActionArgument[] args) throws ActionException { List<String> names = new ArrayList<>(); for (ActionArgument argument : args) { names.add(argument.getName()); names.addAll(Arrays.asList(argument.getAliases())); } List<Node> matches = new ArrayList<>(); for (int i = 0; i < nodeList.getLength(); i++) { Node child = nodeList.item(i); if (child.getNodeType() != Node.ELEMENT_NODE) continue; if (names.contains(getUnprefixedNodeName(child))) matches.add(child); } if (matches.size() < args.length) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "Invalid number of input or output arguments in XML message, expected " + args.length + " but found " + matches.size() ); } return matches; }
public ActionArgument<S> deepCopy() { return new ActionArgument<>( getName(), getAliases(), getRelatedStateVariableName(), getDirection(), isReturnValue() ); }
/** * Finds all element nodes in the list that match any argument name or argument * alias, throws {@link ActionException} if not all arguments were found. */ protected List<Node> getMatchingNodes(NodeList nodeList, ActionArgument[] args) throws ActionException { List<String> names = new ArrayList(); for (ActionArgument argument : args) { names.add(argument.getName()); names.addAll(Arrays.asList(argument.getAliases())); } List<Node> matches = new ArrayList(); for (int i = 0; i < nodeList.getLength(); i++) { Node child = nodeList.item(i); if (child.getNodeType() != Node.ELEMENT_NODE) continue; if (names.contains(getUnprefixedNodeName(child))) matches.add(child); } if (matches.size() < args.length) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "Invalid number of input or output arguments in XML message, expected " + args.length + " but found " + matches.size() ); } return matches; }
protected Map<String, String> getMatchingNodes(XmlPullParser xpp, ActionArgument[] args) throws Exception { // This is a case-insensitive search! List<String> names = new ArrayList<String>(); for (ActionArgument argument : args) { names.add(argument.getName().toUpperCase()); for (String alias : Arrays.asList(argument.getAliases())) { names.add(alias.toUpperCase()); } } Map<String, String> matches = new HashMap<String, String>(); String enclosingTag = xpp.getName(); int event; do { event = xpp.next(); if(event == XmlPullParser.START_TAG && names.contains(xpp.getName().toUpperCase())) { matches.put(xpp.getName(), xpp.nextText()); } } while (event != XmlPullParser.END_DOCUMENT && (event != XmlPullParser.END_TAG || !xpp.getName().equals(enclosingTag))); if (matches.size() < args.length) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "Invalid number of input or output arguments in XML message, expected " + args.length + " but found " + matches.size() ); } return matches; }
public ActionArgument<S> deepCopy() { return new ActionArgument<S>( getName(), getAliases(), getRelatedStateVariableName(), getDirection(), isReturnValue() ); }
protected Map<String, String> getMatchingNodes(XmlPullParser xpp, ActionArgument[] args) throws Exception { // This is a case-insensitive search! List<String> names = new ArrayList<>(); for (ActionArgument argument : args) { names.add(argument.getName().toUpperCase(Locale.ROOT)); for (String alias : Arrays.asList(argument.getAliases())) { names.add(alias.toUpperCase(Locale.ROOT)); } } Map<String, String> matches = new HashMap<>(); String enclosingTag = xpp.getName(); int event; do { event = xpp.next(); if(event == XmlPullParser.START_TAG && names.contains(xpp.getName().toUpperCase(Locale.ROOT))) { matches.put(xpp.getName(), xpp.nextText()); } } while (event != XmlPullParser.END_DOCUMENT && (event != XmlPullParser.END_TAG || !xpp.getName().equals(enclosingTag))); if (matches.size() < args.length) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "Invalid number of input or output arguments in XML message, expected " + args.length + " but found " + matches.size() ); } return matches; }
/** * Finds all element nodes in the list that match any argument name or argument * alias, throws {@link ActionException} if not all arguments were found. */ protected List<Node> getMatchingNodes(NodeList nodeList, ActionArgument[] args) throws ActionException { List<String> names = new ArrayList<>(); for (ActionArgument argument : args) { names.add(argument.getName()); names.addAll(Arrays.asList(argument.getAliases())); } List<Node> matches = new ArrayList<>(); for (int i = 0; i < nodeList.getLength(); i++) { Node child = nodeList.item(i); if (child.getNodeType() != Node.ELEMENT_NODE) continue; if (names.contains(getUnprefixedNodeName(child))) matches.add(child); } if (matches.size() < args.length) { throw new ActionException( ErrorCode.ARGUMENT_VALUE_INVALID, "Invalid number of input or output arguments in XML message, expected " + args.length + " but found " + matches.size() ); } return matches; }
public ActionArgument<S> deepCopy() { return new ActionArgument<>( getName(), getAliases(), getRelatedStateVariableName(), getDirection(), isReturnValue() ); }