Package com.dotcms.repackage.org.dom4j

Examples of com.dotcms.repackage.org.dom4j.Element


    Document doc = reader.read(xmlFile);

    Iterator itr = doc.getRootElement().element("enterprise-beans").elements("entity").iterator();

    while (itr.hasNext()) {
      Element entity = (Element)itr.next();

      methodsSB.append("\t\t\t<method>\n");
      methodsSB.append("\t\t\t\t<ejb-name>" + entity.elementText("ejb-name") + "</ejb-name>\n");
      methodsSB.append("\t\t\t\t<method-name>*</method-name>\n");
      methodsSB.append("\t\t\t</method>\n");
    }

    itr = doc.getRootElement().element("enterprise-beans").elements("session").iterator();

    while (itr.hasNext()) {
      Element entity = (Element)itr.next();

      methodsSB.append("\t\t\t<method>\n");
      methodsSB.append("\t\t\t\t<ejb-name>" + entity.elementText("ejb-name") + "</ejb-name>\n");
      methodsSB.append("\t\t\t\t<method-name>*</method-name>\n");
      methodsSB.append("\t\t\t</method>\n");
    }

    StringBuffer sb = new StringBuffer();
View Full Code Here


    Document doc = reader.read(new File(filePath));

    Iterator itr = doc.getRootElement().elements("ejb-local-ref").iterator();

    while (itr.hasNext()) {
      Element ejbLocalRef = (Element)itr.next();

      sb.append("\t\t<ejb-local-ref>\n");
      sb.append("\t\t\t<ejb-ref-name>").append(ejbLocalRef.elementText("ejb-ref-name")).append("</ejb-ref-name>\n");
      sb.append("\t\t\t<ejb-link>").append(ejbLocalRef.elementText("ejb-link")).append("</ejb-link>\n");
      sb.append("\t\t</ejb-local-ref>\n");
    }

    itr = doc.getRootElement().elements("resource-ref").iterator();

    while (itr.hasNext()) {
      Element resourceRef = (Element)itr.next();

      sb.append("\t\t<resource-mapping>\n");
      sb.append("\t\t\t<resource-name>").append(resourceRef.elementText("res-ref-name")).append("</resource-name>\n");
      sb.append("\t\t\t<resource-type>").append(resourceRef.elementText("res-type")).append("</resource-type>\n");
      sb.append("\t\t\t<resource-link>").append(resourceRef.elementText("res-ref-name")).append("</resource-link>\n");
      sb.append("\t\t</resource-mapping>\n");
    }

    sb.append("\t</web-module>\n");
View Full Code Here

    return name1.compareTo(name2);
  }

  private int _compareChildText(Element el1, Element el2, String childName) {
    Element child1 = _getChild(el1, childName);
    Element child2 = _getChild(el2, childName);

    if ((child1 == null) || (child2 == null)) {
      return -1;
    }

    String name1 = child1.getText();
    String name2 = child2.getText();

    if ((name1 == null) || (name2 == null)) {
      return -1;
    }
View Full Code Here

    return name1.compareTo(name2);
  }

  private Element _getChild(Element parent, String childName) {
    Element child = parent.element(childName);

    /*if (child == null) {
      child = parent.element(childName, parent.getNamespace());
    }*/

 
View Full Code Here

  }

  public Document merge(Document masterDoc, Document slaveDoc) {
    Document mergedDoc = (Document)masterDoc.clone();

    Element root1 = mergedDoc.getRootElement();
    Element root2 = slaveDoc.getRootElement();

    List children1 = root1.elements();
    List children2 = root2.elements();

    for (int i = 0; i < children2.size(); i++) {
      Element el2 = (Element)children2.get(i);

      Element el2Clone = (Element)el2.clone();
      el2Clone.detach();

      root1.add(el2Clone);
    }

    organizeXML(mergedDoc);
View Full Code Here

    }
    catch (DocumentException de) {
      Logger.error(WebSiteBuilder.class,de.getMessage(),de);
    }

    Element root = doc.getRootElement();

    List webSites = new ArrayList();

    Iterator itr = root.elements("web-site").iterator();

    while (itr.hasNext()) {
      Element webSite = (Element)itr.next();

      String id = webSite.attributeValue("id");
      boolean httpEnabled = GetterUtil.getBoolean(
        webSite.attributeValue("http-enabled"), true);
      String keystore = GetterUtil.getString(
        webSite.attributeValue("keystore"));
      String keystorePassword = GetterUtil.getString(
        webSite.attributeValue("keystore-password"));
      String virtualHosts = GetterUtil.getString(
        webSite.attributeValue("virtual-hosts"));
      String forwardURL = GetterUtil.getString(
        webSite.attributeValue("forward-url"), "/c");

      webSites.add(
        new WebSite(
          id, httpEnabled, keystore, keystorePassword, virtualHosts,
          forwardURL));
View Full Code Here

    return mergedDoc;
  }

  public void organizeXML(Document doc) {
    Element root = doc.getRootElement();

    _orderChildren(root, _descriptor.getRootChildrenOrder());
    _mergeDuplicateElements(root, getElementComparator());
  }
View Full Code Here

    Element example, List list, ElementComparator comparator) {

    Iterator itr = list.iterator();

    while (itr.hasNext()) {
      Element candidate = (Element)itr.next();

      if (comparator.compare(example, candidate) == 0) {
        return true;
      }
    }
View Full Code Here

    Element example, List list, ElementComparator comparator) {

    Iterator itr = list.iterator();

    while (itr.hasNext()) {
          Element candidate = (Element)itr.next();

      if (comparator.compare(example, candidate) == 0) {
              return candidate;
          }
      }
View Full Code Here

      List originals = new ArrayList();
      List duplicates = new ArrayList();

      for (int i = 0; i < children.size(); i++) {
        Element child = (Element)children.get(i);

        if (_containsObjectEqualTo(child, originals, comparator)) {
          if (comparator.shouldJoinChildren(child)) {
            Element first =
              _findObjectEqualTo(child, originals, comparator);

            Collection childrenToJoin = child.elements();

            _addChildren(first, childrenToJoin);
          }

          duplicates.add(child);
        }
        else {
          originals.add(child);
        }
      }

      for (int i = 0; i < duplicates.size(); i++) {
        Element duplicate = (Element)duplicates.get(i);

        duplicate.detach();
      }

      Iterator itr = originals.iterator();

      while (itr.hasNext()) {
        Element child = (Element)itr.next();

        _mergeDuplicateElements(child, comparator);
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.org.dom4j.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.