org.vmguys.vmtools.utils
Class DiffElement

java.lang.Object
  |
  +--org.jdom.Element
        |
        +--org.vmguys.vmtools.utils.DiffElement
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class DiffElement
extends org.jdom.Element

This class adds properties to Element that are needed by the algorithm used.

Thanks to Richard Titze (richard.titze@tin.it) for the idea and the original implementation.

See Also:
Serialized Form

Fields inherited from class org.jdom.Element
additionalNamespaces, attributes, content, name, namespace, parent
 
Constructor Summary
DiffElement(java.lang.String name)
           
DiffElement(java.lang.String name, org.jdom.Namespace namespace)
           
DiffElement(java.lang.String name, java.lang.String uri)
           
DiffElement(java.lang.String name, java.lang.String prefix, java.lang.String uri)
           
 
Method Summary
 org.jdom.Attribute[] getAttributesAsArray()
          Gets an array of the node's attributes.
 int getChildNumber()
          Returns the number of this child.
 java.util.List getChildren()
          Overrides Element.getChildren().
 java.lang.Object[] getContentAsArray()
          Gets an array of the node's content that excludes the children.
 int getContentsize()
          Returns the content size of the subtree rooted at this node.
 DiffElement getDiffParent()
          Similar to Element.getParent().
 int getLeftmostLeafNum()
          Returns the number of the leftmost leaf.
 int getNodeNumber()
          Returns the number of this node within the tree.
 DiffElement getRoot()
          Returns the root element of the tree containing this node.
 int getTreesize()
          Returns the size of (the number of nodes in) the subtree rooted at this node.
 java.lang.String getXpath()
          Returns a String containing the XPath of this node.
 boolean hasLeftSibling()
          Indicates whether this node has a sibling to its left.
 java.lang.String toString()
          Returns a String containing information about this node.
 
Methods inherited from class org.jdom.Element
addAttribute, addAttribute, addContent, addContent, addContent, addContent, addContent, addContent, addNamespaceDeclaration, clone, detach, equals, getAdditionalNamespaces, getAttribute, getAttribute, getAttributes, getAttributeValue, getAttributeValue, getChild, getChild, getChildren, getChildren, getChildText, getChildText, getChildTextTrim, getChildTextTrim, getContent, getCopy, getCopy, getDocument, getMixedContent, getName, getNamespace, getNamespace, getNamespacePrefix, getNamespaceURI, getParent, getQualifiedName, getSerializedForm, getText, getTextNormalize, getTextTrim, hasChildren, hashCode, hasMixedContent, isRootElement, removeAttribute, removeAttribute, removeAttribute, removeChild, removeChild, removeChildren, removeChildren, removeChildren, removeContent, removeContent, removeContent, removeContent, removeContent, removeNamespaceDeclaration, setAttribute, setAttribute, setAttribute, setAttributes, setChildren, setContent, setDocument, setMixedContent, setName, setNamespace, setParent, setText
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiffElement

public DiffElement(java.lang.String name)

DiffElement

public DiffElement(java.lang.String name,
                   org.jdom.Namespace namespace)

DiffElement

public DiffElement(java.lang.String name,
                   java.lang.String uri)

DiffElement

public DiffElement(java.lang.String name,
                   java.lang.String prefix,
                   java.lang.String uri)
Method Detail

getTreesize

public int getTreesize()
Returns the size of (the number of nodes in) the subtree rooted at this node. The number is cached for future use.

getContentsize

public int getContentsize()
Returns the content size of the subtree rooted at this node. This is similar to treesize, but it includes all the content of all the nodes as well as the children. The number is cached for future use.

getChildNumber

public int getChildNumber()
Returns the number of this child. The leftmost sibling is child number 1, the next is child number 2, etc.

getNodeNumber

public int getNodeNumber()
Returns the number of this node within the tree. Each node is assigned a number using a postorder algorithm during a tree walk. The result is that all of the nodes in a subtree have numbers lower than the root of that subtree. This is used by the difference finding algorithm.

hasLeftSibling

public boolean hasLeftSibling()
Indicates whether this node has a sibling to its left. This is used in determining if this node is a keyRoot, which is needed by the difference finding algorithm.

getLeftmostLeafNum

public int getLeftmostLeafNum()
Returns the number of the leftmost leaf. Returns this node's number if it has no children.

getDiffParent

public DiffElement getDiffParent()
Similar to Element.getParent(). Same functionality, but the result is cast to a DiffElement object.

getChildren

public java.util.List getChildren()
Overrides Element.getChildren(). Same functionality, but the results are cached.
Overrides:
getChildren in class org.jdom.Element

getContentAsArray

public java.lang.Object[] getContentAsArray()
Gets an array of the node's content that excludes the children. The array is cached so subsequent calls can be handled quickly.

getAttributesAsArray

public org.jdom.Attribute[] getAttributesAsArray()
Gets an array of the node's attributes. The attributes are sorted by name. The array is cached for future use.

getXpath

public java.lang.String getXpath()
                          throws org.jdom.JDOMException
Returns a String containing the XPath of this node.

toString

public java.lang.String toString()
Returns a String containing information about this node.
Overrides:
toString in class org.jdom.Element

getRoot

public DiffElement getRoot()
Returns the root element of the tree containing this node. The result is cached for future use.


Copyright © 2001 VM Systems, Inc. All Rights Reserved.