Package de.pdark.decentxml

Examples of de.pdark.decentxml.Element


      handleProperties(element, properties);
      effectiveParent = this;
      parent.addChild(this);
    }
    for (Iterator<Element> it = children.iterator(); it.hasNext();) {
      Element aChild = it.next();
      handleChild(effectiveParent, aChild);
    }
  }
View Full Code Here


    }
    JcrNode childJcrNode = new JcrNode(parent, domNode, this, null);
    handleProperties(domNode, childJcrNode.properties);
    List<Element> children = domNode.getChildren();
    for (Iterator<Element> it = children.iterator(); it.hasNext();) {
      Element element = it.next();
      handleChild(childJcrNode, element);
    }
  }
View Full Code Here

    if (underlying==null) {
      if (resource==null) {
        if (domElement==null) {
          return toString().hashCode();
        } else {
            Element domElementCopy = domElement.copy();
            domElementCopy.clearChildren();
          return domElementCopy.toString().hashCode() + parent.hashCode();
        }
      } else {
        return resource.getFullPath().hashCode();
      }
    } else {
      if (domElement==null) {
        return underlying.hashCode();
      }
            Element domElementCopy = domElement.copy();
            domElementCopy.clearChildren();
      return underlying.hashCode() + domElementCopy.toString().hashCode();
    }
  }
View Full Code Here

    }
    if (parent!=null && other.parent!=null) {
      if (!parent.equals(other.parent)) {
        return false;
      }
      Element domElementCopy = domElement.copy();
      domElementCopy.clearChildren();
      Element otherDomElementCopy = other.domElement.copy();
      otherDomElementCopy.clearChildren();
      return domElementCopy.toString().equals(otherDomElementCopy.toString());
    }
    return toString().equals(obj.toString());
  }
View Full Code Here

    }
    JcrNode parent = createSelectionNode(resourceParent);
    if (parent==null) {
      return null;
    }
    Element domNode = null;
    JcrNode selectedNode = new JcrNode(parent, domNode, resource);
    return selectedNode;
  }
View Full Code Here

      throw new IllegalArgumentException("domNode must not be null");
    }
    if (effectiveUnderlying==null) {
      throw new IllegalArgumentException("effectiveUnderlying must not be null");
    }
    Element element = new Element(nodeName);
    if (nodeType!=null) {
        element.addAttribute("jcr:primaryType", nodeType);
    }
    StringBuffer indent = new StringBuffer();
    Element parElement = domElement.getParentElement();
    while(parElement!=null) {
      indent.append("    ");
      parElement = parElement.getParentElement();
    }
    domElement.addNode(new Text("\n    "+indent.toString()));
    element = domElement.addNode(element);
    domElement.addNode(new Text("\n"+indent.toString()));
    JcrNode childNode = new JcrNode(this, element, null);
View Full Code Here

            } catch (CoreException e) {
                Activator.getDefault().getPluginLogger().error("Error renaming resource ("+resource+"): "+e, e);
            }
    }
    if (domElement!=null) {
      Element parentNode = domElement.getParentElement();
      domElement.remove();
      if (parentNode!=null) {
        List<Node> allChildNodes = parentNode.getNodes();
        boolean nonTextChild = false;
        for (Iterator<Node> it = allChildNodes.iterator(); it
            .hasNext();) {
          Node node = it.next();
          if (node.getType()!=Type.TEXT) {
            nonTextChild = true;
          }         
        }
        if (!nonTextChild) {
          for (Iterator<Node> it = allChildNodes.iterator(); it
              .hasNext();) {
            Node node = it.next();
            it.remove();
          }
          if (!parentNode.hasNodes()) {
            parentNode.setCompactEmpty(true);
          }
        }
      }
    }
    if (underlying!=null) {
View Full Code Here

                } else {
                    domElement.addAttribute("jcr:primaryType", newPrimaryType);
                }
               
                // then copy all the other attributes - plus children if there are nay
                Element propDomElement = properties.getDomElement();
                if (propDomElement!=null) {
                    List<Attribute> attributes = propDomElement.getAttributes();
                    for (Iterator<Attribute> it = attributes.iterator(); it.hasNext();) {
                        Attribute anAttribute = it.next();
                        if (anAttribute.getName().startsWith("xmlns:")) {
                            continue;
                        }
                        if (anAttribute.getName().equals("jcr:primaryType")) {
                            continue;
                        }
                        if (domElement.getAttributeMap().containsKey(anAttribute.getName())) {
                            domElement.setAttribute(anAttribute.getName(), anAttribute.getValue());
                        } else {
                            domElement.addAttribute(anAttribute);
                        }
                    }
                    List<Element> c2 = propDomElement.getChildren();
                    if (c2!=null && c2.size()!=0) {
                        domElement.addNodes(c2);
                    }
                }
               
View Full Code Here

        } else {
            final String NL = System.getProperty("line.separator");
            final String INDENT = "    ";
            // otherwise, make sure each element has the correct preSpace
            final String correctPreSpace;
            Element parent = domElement.getParentElement();
            if (parent!=null) {
                List<Node> nodes = parent.getNodes();
                if (nodes.size()>1 && (nodes.get(0) instanceof Text) && (nodes.get(0).toXML().startsWith(NL))) {
                    correctPreSpace = nodes.get(0).toXML() + INDENT;
                } else {
                    String totalIndent = INDENT;
                    while(parent!=null) {
                        totalIndent = totalIndent + INDENT;
                        parent = parent.getParentElement();
                    }
                    correctPreSpace = NL + totalIndent;
                }
            } else {
                // guestimate
View Full Code Here

        this.dom = document.getRootElement();
    }

    public List<? extends TargetDefinition.Location> getLocations() {
        ArrayList<TargetDefinition.Location> locations = new ArrayList<TargetDefinition.Location>();
        Element locationsDom = dom.getChild("locations");
        if (locationsDom != null) {
            for (Element locationDom : locationsDom.getChildren("location")) {
                String type = locationDom.getAttributeValue("type");
                if ("InstallableUnit".equals(type))
                    locations.add(new IULocation(locationDom));
                else
                    locations.add(new OtherLocation(type));
View Full Code Here

TOP

Related Classes of de.pdark.decentxml.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.