Beispiel #1
0
  public static boolean setParamsInListFromXML(ParameterList paramList, Element paramListEl) {
    boolean failure = false;
    for (ParameterAPI<?> param : paramList) {
      Iterator<Element> it = paramListEl.elementIterator();
      boolean matched = false;
      while (it.hasNext()) {
        Element el = it.next();
        if (param.getName().equals(el.attribute("name").getValue())) {
          matched = true;
          // System.out.println("Found a match!");
          if (param.setValueFromXMLMetadata(el)) {
            // System.out.println("Parameter set successfully!");
          } else {
            System.err.println("Parameter could not be set from XML!");
            System.err.println(
                "It is possible that the parameter type doesn't yet support loading from XML");
            failure = true;
          }
        }
      }
      if (!matched) {
        System.err.println(
            "Parameter '"
                + param.getName()
                + "' from XML can not be set because it can't be"
                + " found in the given ParameterList!");
        failure = true;
      }
    }

    return !failure;
  }