コード例 #1
0
ファイル: ConfigEditor.java プロジェクト: kaine-shaman/jcfg
  private List<Node> getChildNodes(Node parentNode, String tagName) {
    List<Node> nodeList = new ArrayList<Node>();
    for (Node child = parentNode.getFirstChild(); child != null; child = child.getNextSibling()) {
      if (child.getNodeType() == Node.ELEMENT_NODE && tagName.equals(child.getNodeName())) {
        nodeList.add(child);
      }
    }

    return nodeList;
  }
コード例 #2
0
ファイル: ConfigEditor.java プロジェクト: kaine-shaman/jcfg
  private void call(String script)
      throws ParserConfigurationException, TransformerConfigurationException {
    File callerScript = this.currentScript;
    Document doc = null;
    try {
      this.currentScript = new File(script);
      DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      doc = db.parse(this.currentScript);
    } catch (Exception ex) {
      this.currentScript = callerScript;
      Utils.onError(new Error.FileParse(script));
      return;
    }

    NodeList operations = doc.getDocumentElement().getChildNodes();
    for (int i = 0; i < operations.getLength(); i++) {
      Node operation = operations.item(i);
      if (operation.getNodeType() != Node.ELEMENT_NODE) continue;
      call(operation);
    }
    this.currentScript = callerScript;
  }