Class XmlChange


  • public class XmlChange
    extends java.lang.Object
    Represents a single change detected between two XML documents.

    Each change has a type, an XPath-like path identifying the location, and optional before/after values and node references.

    Example output:

     ELEMENT_ADDED: /project/dependencies/dependency[3]
     TEXT_CHANGED: /project/version: "1.0" → "1.1"
     ATTRIBUTE_CHANGED: /project/dependencies/dependency[2]/@scope: "compile" → "test"
     
    Since:
    1.3.0
    See Also:
    ChangeType, DiffResult, XmlDiff
    • Constructor Summary

      Constructors 
      Constructor Description
      XmlChange​(ChangeType type, java.lang.String path, java.lang.String beforeValue, java.lang.String afterValue, Node beforeNode, Node afterNode)
      Creates a new XmlChange.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Node afterNode()
      Returns the node after the change, or null for removals.
      java.lang.String afterValue()
      Returns the value after the change, or null for removals.
      Node beforeNode()
      Returns the node before the change, or null for additions.
      java.lang.String beforeValue()
      Returns the value before the change, or null for additions.
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      boolean isFormattingOnly()
      Returns true if the change is formatting-only (no semantic effect).
      boolean isSemantic()
      Returns true if the change affects the semantic meaning of the XML.
      java.lang.String path()
      Returns the XPath-like path to the changed node.
      java.lang.String toString()  
      ChangeType type()
      Returns the type of change.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • XmlChange

        public XmlChange​(ChangeType type,
                         java.lang.String path,
                         java.lang.String beforeValue,
                         java.lang.String afterValue,
                         Node beforeNode,
                         Node afterNode)
        Creates a new XmlChange.
        Parameters:
        type - the type of change
        path - the XPath-like path to the changed node
        beforeValue - the value before the change, or null for additions
        afterValue - the value after the change, or null for removals
        beforeNode - the node before the change, or null for additions
        afterNode - the node after the change, or null for removals
    • Method Detail

      • type

        public ChangeType type()
        Returns the type of change.
        Returns:
        the change type
      • path

        public java.lang.String path()
        Returns the XPath-like path to the changed node.
        Returns:
        the path
      • isSemantic

        public boolean isSemantic()
        Returns true if the change affects the semantic meaning of the XML.
        Returns:
        true if semantic
      • isFormattingOnly

        public boolean isFormattingOnly()
        Returns true if the change is formatting-only (no semantic effect).
        Returns:
        true if formatting-only
      • beforeValue

        public java.lang.String beforeValue()
        Returns the value before the change, or null for additions.
        Returns:
        the before value
      • afterValue

        public java.lang.String afterValue()
        Returns the value after the change, or null for removals.
        Returns:
        the after value
      • beforeNode

        public Node beforeNode()
        Returns the node before the change, or null for additions.
        Returns:
        the before node
      • afterNode

        public Node afterNode()
        Returns the node after the change, or null for removals.
        Returns:
        the after node
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object