コード例 #1
0
ファイル: FdFixme.java プロジェクト: asami/xmlsmartdoc
 /**
  * Creates a DOM representation of the object. Result is appended to the Node <code>parent</code>.
  *
  * @param parent
  */
 public void makeElement(Node parent) {
   Document doc;
   if (parent instanceof Document) {
     doc = (Document) parent;
   } else {
     doc = parent.getOwnerDocument();
   }
   Element element = doc.createElement("fixme");
   int size;
   if (this.author_ != null) {
     URelaxer.setAttributePropertyByString(element, "author", this.author_);
   }
   if (this.id_ != null) {
     URelaxer.setAttributePropertyByString(element, "id", this.id_);
   }
   if (this.xmlLang_ != null) {
     URelaxer.setAttributePropertyByString(element, "xml:lang", this.xmlLang_);
   }
   size = this.content_.size();
   for (int i = 0; i < size; i++) {
     IFdContentMixMixed value = (IFdContentMixMixed) this.content_.get(i);
     value.makeElement(element);
   }
   parent.appendChild(element);
 }
コード例 #2
0
ファイル: Reportador.java プロジェクト: aesquive/NuevoGol
  private void guardaRes(String resu, CliGol cliGol)
      throws ParserConfigurationException, SAXException, IOException {

    String[] nodos = {"NoHit", "Hit", "Buro"};

    DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    InputSource is = new InputSource(new StringReader(resu));
    Document xml = db.parse(is);

    Element raiz = xml.getDocumentElement();

    String nombre = obtenerNombre(raiz);

    for (String s : nodos) {

      Node nodo =
          raiz.getElementsByTagName(s) == null ? null : raiz.getElementsByTagName(s).item(0);

      if (nodo != null) {
        String informacion = sustraerInformacionNodo(cliGol, nodo);

        guardarEnListas(nodo.getNodeName(), nombre + "," + informacion);
      }
    }
  }
コード例 #3
0
ファイル: FcTable.java プロジェクト: asami/xmlsmartdoc
 /**
  * Creates a DOM representation of the object. Result is appended to the Node <code>parent</code>.
  *
  * @param parent
  */
 public void makeElement(Node parent) {
   Document doc;
   if (parent instanceof Document) {
     doc = (Document) parent;
   } else {
     doc = parent.getOwnerDocument();
   }
   Element element = doc.createElement("table");
   int size;
   if (this.id_ != null) {
     URelaxer.setAttributePropertyByString(element, "id", this.id_);
   }
   if (this.xmlLang_ != null) {
     URelaxer.setAttributePropertyByString(element, "xml:lang", this.xmlLang_);
   }
   if (this.caption_ != null) {
     this.caption_.makeElement(element);
   }
   size = this.tr_.size();
   for (int i = 0; i < size; i++) {
     FcTr value = (FcTr) this.tr_.get(i);
     value.makeElement(element);
   }
   parent.appendChild(element);
 }
コード例 #4
0
ファイル: XML.java プロジェクト: JakubValtar/processing
 public String getString(String name, String defaultValue) {
   NamedNodeMap attrs = node.getAttributes();
   if (attrs != null) {
     Node attr = attrs.getNamedItem(name);
     if (attr != null) {
       return attr.getNodeValue();
     }
   }
   return defaultValue;
 }
コード例 #5
0
ファイル: DomParseUtils.java プロジェクト: sluk3r/c3p0
 /** @deprecated use allText(Element elem, boolean trim) */
 public static String allTextFromElement(Element elem, boolean trim) throws DOMException {
   StringBuffer textBuf = new StringBuffer();
   NodeList nl = elem.getChildNodes();
   for (int j = 0, len = nl.getLength(); j < len; ++j) {
     Node node = nl.item(j);
     if (node instanceof Text) // includes Text and CDATA!
     textBuf.append(node.getNodeValue());
   }
   String out = textBuf.toString();
   return (trim ? out.trim() : out);
 }
コード例 #6
0
ファイル: AppConfig.java プロジェクト: ramseylab/Dizzy
 public String getProperty(String pPropertyName) {
   String propertyValue = null;
   NodeList nodeList = mConfigFileDocument.getElementsByTagName(pPropertyName);
   int nodeListLength = nodeList.getLength();
   if (nodeListLength > 0) {
     Node firstChildNode = nodeList.item(nodeListLength - 1).getFirstChild();
     if (null != firstChildNode) {
       propertyValue = firstChildNode.getNodeValue();
     }
   }
   return (propertyValue);
 }
コード例 #7
0
ファイル: AMLtoPNML.java プロジェクト: CaoAo/BeehiveZ
  private static String getTextContent(Node n) {
    NodeList nodeList = n.getChildNodes();
    String textContent = "";
    for (int j = 0; j < nodeList.getLength(); j++) {
      Node k = nodeList.item(j);
      if (k.getNodeType() == Node.TEXT_NODE) {
        textContent = k.getNodeValue();
        break;
      }
    }

    return textContent;
  }
コード例 #8
0
  @Override
  public VPackage parse() {

    logger.debug("Starting parsing package: " + xmlFile.getAbsolutePath());

    long startParsing = System.currentTimeMillis();

    try {
      Document document = getDocument();
      Element root = document.getDocumentElement();

      _package = new VPackage(xmlFile);

      Node name = root.getElementsByTagName(EL_NAME).item(0);
      _package.setName(name.getTextContent());
      Node descr = root.getElementsByTagName(EL_DESCRIPTION).item(0);
      _package.setDescription(descr.getTextContent());

      NodeList list = root.getElementsByTagName(EL_CLASS);

      boolean initPainters = false;
      for (int i = 0; i < list.getLength(); i++) {
        PackageClass pc = parseClass((Element) list.item(i));
        if (pc.getPainterName() != null) {
          initPainters = true;
        }
      }

      if (initPainters) {
        _package.initPainters();
      }

      logger.info(
          "Parsing the package '{}' finished in {}ms.\n",
          _package.getName(),
          (System.currentTimeMillis() - startParsing));
    } catch (Exception e) {
      collector.collectDiagnostic(e.getMessage(), true);
      if (RuntimeProperties.isLogDebugEnabled()) {
        e.printStackTrace();
      }
    }

    try {
      checkProblems("Error parsing package file " + xmlFile.getName());
    } catch (Exception e) {
      return null;
    }

    return _package;
  }
コード例 #9
0
ファイル: Parameters.java プロジェクト: nagyist/jitsi
 /**
  * Populates LOCALES list with contents of xml.
  *
  * @param list the configuration list
  */
 private static void parseLocales(NodeList list) {
   for (int i = 0; i < list.getLength(); ++i) {
     Node node = list.item(i);
     NamedNodeMap attributes = node.getAttributes();
     String label = ((Attr) attributes.getNamedItem("label")).getValue();
     String code = ((Attr) attributes.getNamedItem("isoCode")).getValue();
     String dictLocation = ((Attr) attributes.getNamedItem("dictionaryUrl")).getValue();
     try {
       LOCALES.add(new Locale(label, code, new URL(dictLocation)));
     } catch (MalformedURLException exc) {
       logger.warn(
           "Unable to parse dictionary location of " + label + " (" + dictLocation + ")", exc);
     }
   }
 }
コード例 #10
0
 /**
  * Creates a DOM representation of the object. Result is appended to the Node <code>parent</code>.
  *
  * @param parent
  */
 public void makeElement(Node parent) {
   Document doc;
   if (parent instanceof Document) {
     doc = (Document) parent;
   } else {
     doc = parent.getOwnerDocument();
   }
   Element element =
       doc.createElementNS(
           "http://www.iso_relax.org/xmlns/miaou/binaryTreeAutomaton", "textTransition");
   rNSContext_.setupNamespace(element);
   int size;
   URelaxer.setAttributePropertyByInt(element, "target", this.target_);
   URelaxer.setAttributePropertyByInt(element, "right", this.right_);
   parent.appendChild(element);
 }
コード例 #11
0
ファイル: XML.java プロジェクト: JakubValtar/processing
  public void trim() {
    try {
      XPathFactory xpathFactory = XPathFactory.newInstance();
      XPathExpression xpathExp =
          xpathFactory.newXPath().compile("//text()[normalize-space(.) = '']");
      NodeList emptyTextNodes = (NodeList) xpathExp.evaluate(node, XPathConstants.NODESET);

      // Remove each empty text node from document.
      for (int i = 0; i < emptyTextNodes.getLength(); i++) {
        Node emptyTextNode = emptyTextNodes.item(i);
        emptyTextNode.getParentNode().removeChild(emptyTextNode);
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
コード例 #12
0
ファイル: DomParseUtils.java プロジェクト: sluk3r/c3p0
  /** @deprecated use immediateChildrenByTagName( Element parent, String tagName ) */
  public static NodeList getImmediateChildElementsByTagName(Element parent, String tagName)
      throws DOMException {
    final List nodes = new ArrayList();
    for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling())
      if (child instanceof Element && ((Element) child).getTagName().equals(tagName))
        nodes.add(child);
    return new NodeList() {
      public int getLength() {
        return nodes.size();
      }

      public Node item(int i) {
        return (Node) nodes.get(i);
      }
    };
  }
コード例 #13
0
ファイル: XMLParser.java プロジェクト: NBroekhuijsen/EasyCell
  /**
   * Method that reads a XML-file, and returns a Model that contains the information
   *
   * @param file
   * @return
   * @return
   */
  public static Model readXML(String file) {
    // initialize table to be filled with content of XML file
    Model t = new Model();
    try {
      // Create file to be parsed by document parser
      File xmlfile = new File(file);
      // create parser
      DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      // parse the file
      Document parsedfile = parser.parse(xmlfile);
      // normalize the parsed file (make it more user-friendly)
      parsedfile.getDocumentElement().normalize();

      NodeList cells = parsedfile.getElementsByTagName("CELL");
      for (int i = 0; i < cells.getLength(); i++) {
        // Get cell at list index i
        Node currentcell = cells.item(i);
        // read the elements "location" attributes row/column
        if (Node.ELEMENT_NODE == currentcell.getNodeType()) {
          Element cellinfo = (Element) currentcell;
          // get the row number from node attribute
          int row = Integer.parseInt(cellinfo.getAttribute("row")) - 1;
          // get the column number from the node attribute
          int col = Integer.parseInt(cellinfo.getAttribute("column")) - 1;
          // get content from node
          String content = cellinfo.getTextContent();
          if (content != null) {
            content = content.replace("\n", "");
          }
          // Make the content an Integer (if it is a number), easier
          // for
          // using it later on
          // put content in table, with row/column inserted as x/y
          t.setContent(row, col, (String) content);
        }
      }

    } catch (ParserConfigurationException e) {
      System.out.println("Fileparser could not be made");
    } catch (IOException f) {
      System.out.println("File could not be parsed, did you enter the correct file name?");
    } catch (SAXException g) {
      System.out.println("Something went wrong in parsing the file");
    }
    return t;
  }
コード例 #14
0
ファイル: XML.java プロジェクト: JakubValtar/processing
 /**
  * Get a list of the names for all of the attributes for this node.
  *
  * @webref xml:method
  * @brief Returns a list of names of all attributes as an array
  */
 public String[] listAttributes() {
   NamedNodeMap nnm = node.getAttributes();
   String[] outgoing = new String[nnm.getLength()];
   for (int i = 0; i < outgoing.length; i++) {
     outgoing[i] = nnm.item(i).getNodeName();
   }
   return outgoing;
 }
コード例 #15
0
ファイル: XML.java プロジェクト: JakubValtar/processing
 /** Internal handler to add the node structure. */
 protected XML appendChild(Node newNode) {
   node.appendChild(newNode);
   XML newbie = new XML(this, newNode);
   if (children != null) {
     children = (XML[]) PApplet.concat(children, new XML[] {newbie});
   }
   return newbie;
 }
コード例 #16
0
  // ActionListener Interface
  public void actionPerformed(ActionEvent e) {
    OutlinerDocument doc = (OutlinerDocument) Outliner.documents.getMostRecentDocumentTouched();
    OutlinerCellRendererImpl textArea = doc.panel.layout.getUIComponent(doc.tree.getEditingNode());

    if (textArea == null) {
      return;
    }

    Node node = textArea.node;
    JoeTree tree = node.getTree();
    OutlineLayoutManager layout = tree.getDocument().panel.layout;

    if (doc.tree.getComponentFocus() == OutlineLayoutManager.TEXT) {
      ToggleEditableAction.toggleEditableInheritanceText(node, tree, layout);
    } else if (doc.tree.getComponentFocus() == OutlineLayoutManager.ICON) {
      ToggleEditableAction.toggleEditableInheritance(node, tree, layout);
    }
  }
コード例 #17
0
ファイル: XML.java プロジェクト: JakubValtar/processing
 public double getDoubleContent(double defaultValue) {
   String c = node.getTextContent();
   if (c != null) {
     try {
       return Double.parseDouble(c);
     } catch (NumberFormatException nfe) {
     }
   }
   return defaultValue;
 }
コード例 #18
0
ファイル: XML.java プロジェクト: JakubValtar/processing
 public long getLongContent(long defaultValue) {
   String c = node.getTextContent();
   if (c != null) {
     try {
       return Long.parseLong(c);
     } catch (NumberFormatException nfe) {
     }
   }
   return defaultValue;
 }
コード例 #19
0
  /** used for cut and paste. */
  public void addObjectFromClipboard(String a_value) throws CircularIncludeException {
    Reader reader = new StringReader(a_value);
    Document document = null;
    try {
      document = UJAXP.getDocument(reader);
    } catch (Exception e) {
      e.printStackTrace();
      return;
    } // try-catch

    Element root = document.getDocumentElement();
    if (!root.getNodeName().equals("clipboard")) {
      return;
    } // if

    Node child;
    for (child = root.getFirstChild(); child != null; child = child.getNextSibling()) {
      if (!(child instanceof Element)) {
        continue;
      } // if
      Element element = (Element) child;

      IGlyphFactory factory = GlyphFactory.getFactory();

      if (XModule.isMatch(element)) {
        EModuleInvoke module = (EModuleInvoke) factory.createXModule(element);
        addModule(module);
        continue;
      } // if

      if (XContour.isMatch(element)) {
        EContour contour = (EContour) factory.createXContour(element);
        addContour(contour);
        continue;
      } // if

      if (XInclude.isMatch(element)) {
        EIncludeInvoke include = (EIncludeInvoke) factory.createXInclude(element);
        addInclude(include);
        continue;
      } // if
    } // while
  }
コード例 #20
0
ファイル: XML.java プロジェクト: JakubValtar/processing
 /**
  * Honey, can you just check on the kids? Thanks.
  *
  * <p>Internal function; not included in reference.
  */
 protected void checkChildren() {
   if (children == null) {
     NodeList kids = node.getChildNodes();
     int childCount = kids.getLength();
     children = new XML[childCount];
     for (int i = 0; i < childCount; i++) {
       children[i] = new XML(this, kids.item(i));
     }
   }
 }
コード例 #21
0
  /**
   * Creates a DOM representation of the object. Result is appended to the Node <code>parent</code>.
   *
   * @param parent
   */
  public void makeElement(Node parent) {
    Document doc;

    if (parent instanceof Document) {
      doc = (Document) parent;
    } else {
      doc = parent.getOwnerDocument();
    }

    Element element =
        doc.createElementNS("http://www.asahi-net.or.jp/~cs8k-cyu/bulletml", "direction");
    rNSContext_.setupNamespace(element);
    URelaxer.setElementPropertyByString(element, this.content_);

    int size;

    if (this.type_ != null) {
      URelaxer.setAttributePropertyByString(element, "type", this.type_);
    }

    parent.appendChild(element);
  }
コード例 #22
0
ファイル: FtHeader.java プロジェクト: asami/xmlsmartdoc
 /**
  * Creates a DOM representation of the object. Result is appended to the Node <code>parent</code>.
  *
  * @param parent
  */
 public void makeElement(Node parent) {
   Document doc;
   if (parent instanceof Document) {
     doc = (Document) parent;
   } else {
     doc = parent.getOwnerDocument();
   }
   Element element = doc.createElement("header");
   int size;
   if (this.id_ != null) {
     URelaxer.setAttributePropertyByString(element, "id", this.id_);
   }
   if (this.xmlLang_ != null) {
     URelaxer.setAttributePropertyByString(element, "xml:lang", this.xmlLang_);
   }
   this.title_.makeElement(element);
   if (this.subtitle_ != null) {
     this.subtitle_.makeElement(element);
   }
   if (this.version_ != null) {
     this.version_.makeElement(element);
   }
   if (this.type_ != null) {
     this.type_.makeElement(element);
   }
   if (this.authors_ != null) {
     this.authors_.makeElement(element);
   }
   size = this.notice_.size();
   for (int i = 0; i < size; i++) {
     FtNotice value = (FtNotice) this.notice_.get(i);
     value.makeElement(element);
   }
   if (this.abstract_ != null) {
     this.abstract_.makeElement(element);
   }
   parent.appendChild(element);
 }
コード例 #23
0
ファイル: Parameters.java プロジェクト: nagyist/jitsi
  static {
    try {
      URL url = SpellCheckActivator.bundleContext.getBundle().getResource(RESOURCE_LOC);

      InputStream stream = url.openStream();

      if (stream == null) throw new IOException();

      // strict parsing options
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

      factory.setValidating(false);
      factory.setIgnoringComments(true);
      factory.setIgnoringElementContentWhitespace(true);

      // parses configuration xml
      /*-
       * Warning: Felix is unable to import the com.sun.rowset.internal
       * package, meaning this can't use the XmlErrorHandler. This causes
       * a warning and a default handler to be attached. Otherwise this
       * should have: builder.setErrorHandler(new XmlErrorHandler());
       */
      DocumentBuilder builder = factory.newDocumentBuilder();
      Document doc = builder.parse(stream);

      // iterates over nodes, parsing contents
      Node root = doc.getChildNodes().item(1);

      NodeList categories = root.getChildNodes();

      for (int i = 0; i < categories.getLength(); ++i) {
        Node node = categories.item(i);
        if (node.getNodeName().equals(NODE_DEFAULTS)) {
          parseDefaults(node.getChildNodes());
        } else if (node.getNodeName().equals(NODE_LOCALES)) {
          parseLocales(node.getChildNodes());
        } else {
          logger.warn("Unrecognized category: " + node.getNodeName());
        }
      }
    } catch (IOException exc) {
      logger.error("Unable to load spell checker parameters", exc);
    } catch (SAXException exc) {
      logger.error("Unable to parse spell checker parameters", exc);
    } catch (ParserConfigurationException exc) {
      logger.error("Unable to parse spell checker parameters", exc);
    }
  }
コード例 #24
0
ファイル: Reportador.java プロジェクト: aesquive/NuevoGol
  private String sustraerInformacionNodo(CliGol cliGol, Node nodo) {

    String[] excluye = {
      "CLI_ID",
      "CLI_SAP",
      "CliApePat",
      "CliApeMat",
      "CliNom",
      "CLI_FEC_NAC",
      "CLI_DOM_CAL",
      "CLI_DOM_NUM_EXT",
      "CLI_DOM_NUM_INT",
      "CLI_DOM_COL",
      "CLI_POS_ID",
      "CliGolP1",
      "CliGolP8",
      "CliGolP10",
      "CliGolP11",
      "CliGolP15",
      "CliGolP17",
      "CliGolP18",
      "CliGolP25",
      "CliGolResAct",
      "CliGolNumTar",
      "CliGolCtaChe",
      "CliGolCrePer",
      "CliGolCreAut",
      "CliGolCreHip",
      "CliGolOtrCre",
      "CliBurMens",
      "PagRnt",
      "CliGolBurCre",
      "CliBurValr",
      "CliGolIng",
      "CliGolImpRen"
    };

    NodeList variables = nodo.getChildNodes();

    LinkedHashMap[] mapas = obtenerMapeos(cliGol, variables, excluye);

    Dao dao = new Dao();
    Object[] descripciones = dao.ObtenLista(mapas[0], Arrays.asList(excluye));

    // <variable,puntos>,descripciones
    return unirMapeos(mapas[1], descripciones);
  }
コード例 #25
0
 /* return the value of the XML text node (never null) */
 protected static String GetNodeText(Node root) {
   StringBuffer sb = new StringBuffer();
   if (root != null) {
     NodeList list = root.getChildNodes();
     for (int i = 0; i < list.getLength(); i++) {
       Node n = list.item(i);
       if (n.getNodeType() == Node.CDATA_SECTION_NODE) { // CDATA Section
         sb.append(n.getNodeValue());
       } else if (n.getNodeType() == Node.TEXT_NODE) {
         sb.append(n.getNodeValue());
       } else {
         // Print.logWarn("Unrecognized node type: " + n.getNodeType());
       }
     }
   }
   return sb.toString();
 }
コード例 #26
0
ファイル: XML.java プロジェクト: JakubValtar/processing
 /** @param defaultValue the default value of the attribute */
 public float getFloatContent(float defaultValue) {
   return PApplet.parseFloat(node.getTextContent(), defaultValue);
 }
コード例 #27
0
ファイル: XML.java プロジェクト: JakubValtar/processing
 public String getContent(String defaultValue) {
   String s = node.getTextContent();
   return (s != null) ? s : defaultValue;
 }
コード例 #28
0
ファイル: XML.java プロジェクト: JakubValtar/processing
 /** @param defaultValue the default value of the attribute */
 public int getIntContent(int defaultValue) {
   return PApplet.parseInt(node.getTextContent(), defaultValue);
 }
コード例 #29
0
  protected void init(Element root) {
    NodeList children = root.getChildNodes();

    for (int i = 0; i < children.getLength(); i++) {
      Node child = children.item(i);

      if (child.getNodeName().equals("meta")) {
        Element meta = (Element) child;
        String value = XMLUtil.getText(meta);
        this.metaAttributes.put(meta.getAttribute("name"), value);
      }
    }

    // handle registers - OPTIONAL
    Element r = XMLUtil.getChildElement(root, "registers");

    if (r != null) {
      List registers = XMLUtil.getChildElements(r, "register");

      for (int i = 0; i < registers.size(); i++) {
        Element register = (Element) registers.get(i);
        RegisterDescriptor registerDescriptor =
            DescriptorFactory.getFactory().createRegisterDescriptor(register);
        registerDescriptor.setParent(this);
        this.registers.add(registerDescriptor);
      }
    }

    // handle global-conditions - OPTIONAL
    Element globalConditionsElement = XMLUtil.getChildElement(root, "global-conditions");

    if (globalConditionsElement != null) {
      Element globalConditions = XMLUtil.getChildElement(globalConditionsElement, "conditions");

      ConditionsDescriptor conditionsDescriptor =
          DescriptorFactory.getFactory().createConditionsDescriptor(globalConditions);
      conditionsDescriptor.setParent(this);
      this.globalConditions = conditionsDescriptor;
    }

    // handle initial-steps - REQUIRED
    Element intialActionsElement = XMLUtil.getChildElement(root, "initial-actions");
    List initialActions = XMLUtil.getChildElements(intialActionsElement, "action");

    for (int i = 0; i < initialActions.size(); i++) {
      Element initialAction = (Element) initialActions.get(i);
      ActionDescriptor actionDescriptor =
          DescriptorFactory.getFactory().createActionDescriptor(initialAction);
      actionDescriptor.setParent(this);
      this.initialActions.add(actionDescriptor);
    }

    // handle global-actions - OPTIONAL
    Element globalActionsElement = XMLUtil.getChildElement(root, "global-actions");

    if (globalActionsElement != null) {
      List globalActions = XMLUtil.getChildElements(globalActionsElement, "action");

      for (int i = 0; i < globalActions.size(); i++) {
        Element globalAction = (Element) globalActions.get(i);
        ActionDescriptor actionDescriptor =
            DescriptorFactory.getFactory().createActionDescriptor(globalAction);
        actionDescriptor.setParent(this);
        this.globalActions.add(actionDescriptor);
      }
    }

    // handle common-actions - OPTIONAL
    //   - Store actions in HashMap for now. When parsing Steps, we'll resolve
    //      any common actions into local references.
    Element commonActionsElement = XMLUtil.getChildElement(root, "common-actions");

    if (commonActionsElement != null) {
      List commonActions = XMLUtil.getChildElements(commonActionsElement, "action");

      for (int i = 0; i < commonActions.size(); i++) {
        Element commonAction = (Element) commonActions.get(i);
        ActionDescriptor actionDescriptor =
            DescriptorFactory.getFactory().createActionDescriptor(commonAction);
        actionDescriptor.setParent(this);
        addCommonAction(actionDescriptor);
      }
    }

    // handle timer-functions - OPTIONAL
    Element timerFunctionsElement = XMLUtil.getChildElement(root, "trigger-functions");

    if (timerFunctionsElement != null) {
      List timerFunctions = XMLUtil.getChildElements(timerFunctionsElement, "trigger-function");

      for (int i = 0; i < timerFunctions.size(); i++) {
        Element timerFunction = (Element) timerFunctions.get(i);
        Integer id = new Integer(timerFunction.getAttribute("id"));
        FunctionDescriptor function =
            DescriptorFactory.getFactory()
                .createFunctionDescriptor(XMLUtil.getChildElement(timerFunction, "function"));
        function.setParent(this);
        this.timerFunctions.put(id, function);
      }
    }

    // handle steps - REQUIRED
    Element stepsElement = XMLUtil.getChildElement(root, "steps");
    List steps = XMLUtil.getChildElements(stepsElement, "step");

    for (int i = 0; i < steps.size(); i++) {
      Element step = (Element) steps.get(i);
      StepDescriptor stepDescriptor =
          DescriptorFactory.getFactory().createStepDescriptor(step, this);
      this.steps.add(stepDescriptor);
    }

    // handle splits - OPTIONAL
    Element splitsElement = XMLUtil.getChildElement(root, "splits");

    if (splitsElement != null) {
      List split = XMLUtil.getChildElements(splitsElement, "split");

      for (int i = 0; i < split.size(); i++) {
        Element s = (Element) split.get(i);
        SplitDescriptor splitDescriptor = DescriptorFactory.getFactory().createSplitDescriptor(s);
        splitDescriptor.setParent(this);
        this.splits.add(splitDescriptor);
      }
    }

    // handle joins - OPTIONAL:
    Element joinsElement = XMLUtil.getChildElement(root, "joins");

    if (joinsElement != null) {
      List join = XMLUtil.getChildElements(joinsElement, "join");

      for (int i = 0; i < join.size(); i++) {
        Element s = (Element) join.get(i);
        JoinDescriptor joinDescriptor = DescriptorFactory.getFactory().createJoinDescriptor(s);
        joinDescriptor.setParent(this);
        this.joins.add(joinDescriptor);
      }
    }
  }
コード例 #30
0
ファイル: XML.java プロジェクト: JakubValtar/processing
 /**
  * @webref xml:method
  * @brief Sets the content of an element
  */
 public void setContent(String text) {
   node.setTextContent(text);
 }