Class Xpp3Dom

java.lang.Object
org.apache.maven.internal.xml.Xpp3Dom
All Implemented Interfaces:
Serializable, Dom

public class Xpp3Dom extends Object implements Serializable, Dom
NOTE: remove all the util code in here when separated, this class should be pure data.
See Also:
  • Field Details

    • name

      protected final String name
    • value

      protected final String value
    • attributes

      protected final Map<String,String> attributes
    • children

      protected final List<Dom> children
    • location

      protected final Object location
  • Constructor Details

  • Method Details

    • merge

      public Dom merge(Dom source, Boolean childMergeOverride)
      Specified by:
      merge in interface Dom
    • clone

      public Dom clone()
      Specified by:
      clone in interface Dom
      Overrides:
      clone in class Object
    • getName

      public String getName()
      Specified by:
      getName in interface Dom
    • getValue

      public String getValue()
      Specified by:
      getValue in interface Dom
    • getAttributes

      public Map<String,String> getAttributes()
      Specified by:
      getAttributes in interface Dom
    • getAttribute

      public String getAttribute(String name)
      Specified by:
      getAttribute in interface Dom
    • getChild

      public Dom getChild(String name)
      Specified by:
      getChild in interface Dom
    • getChildren

      public List<Dom> getChildren()
      Specified by:
      getChildren in interface Dom
    • getChildCount

      public int getChildCount()
    • getInputLocation

      public Object getInputLocation()
      Specified by:
      getInputLocation in interface Dom
      Returns:
      input location
      Since:
      3.2.0
    • writeToSerializer

      public void writeToSerializer(String namespace, org.codehaus.plexus.util.xml.pull.XmlSerializer serializer) throws IOException
      Throws:
      IOException
    • merge

      public static Dom merge(Dom dominant, Dom recessive, Boolean childMergeOverride)
      Merges one DOM into another, given a specific algorithm and possible override points for that algorithm.

      The algorithm is as follows:

      1. if the recessive DOM is null, there is nothing to do... return.
      2. Determine whether the dominant node will suppress the recessive one (flag=mergeSelf).
        1. retrieve the 'combine.self' attribute on the dominant node, and try to match against 'override'... if it matches 'override', then set mergeSelf == false...the dominant node suppresses the recessive one completely.
        2. otherwise, use the default value for mergeSelf, which is true...this is the same as specifying 'combine.self' == 'merge' as an attribute of the dominant root node.
      3. If mergeSelf == true
        1. Determine whether children from the recessive DOM will be merged or appended to the dominant DOM as siblings (flag=mergeChildren).
          1. if childMergeOverride is set (non-null), use that value (true/false)
          2. retrieve the 'combine.children' attribute on the dominant node, and try to match against 'append'...
          3. if it matches 'append', then set mergeChildren == false...the recessive children will be appended as siblings of the dominant children.
          4. otherwise, use the default value for mergeChildren, which is true...this is the same as specifying 'combine.children' == 'merge' as an attribute on the dominant root node.
        2. Iterate through the recessive children, and:
          1. if mergeChildren == true and there is a corresponding dominant child (matched by element name), merge the two.
          2. otherwise, add the recessive child as a new child on the dominant root node.
    • merge

      public static Dom merge(Dom dominant, Dom recessive)
      Merge two DOMs, with one having dominance in the case of collision. Merge mechanisms (vs. override for nodes, or vs. append for children) is determined by attributes of the dominant root node.
      Parameters:
      dominant - The dominant DOM into which the recessive value/attributes/children will be merged
      recessive - The recessive DOM, which will be merged into the dominant DOM
      Returns:
      merged DOM
      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toUnescapedString

      public String toUnescapedString()