org.castor.xmlctf.xmldiff.xml.nodes
Class XMLNode

java.lang.Object
  extended by org.castor.xmlctf.xmldiff.xml.nodes.XMLNode
Direct Known Subclasses:
Attribute, ParentNode, ProcessingInstruction, Text

public abstract class XMLNode
extends java.lang.Object

The base node for all XMLNode types.

Since:
Castor 1.1
Version:
$Revision: 0000 $ $Date: 2007-01-11 00:00:00 -0600 (Thu, 11 Jan 2007) $
Author:
Edward Kuns

Field Summary
static int ATTRIBUTE
          Node is an attribute.
static int ELEMENT
          Node is an element.
static int PROCESSING_INSTRUCTION
          Node is a processing instruction.
static int ROOT
          Node is a root node.
static int TEXT
          Node is a text node.
 
Constructor Summary
XMLNode(java.lang.String namespace, java.lang.String localName, int nodeType)
          Creates a new XMLNode
 
Method Summary
 java.lang.String getLocalName()
          Returns the local name of the node.
 java.lang.String getNamespaceURI()
          Returns the namespace URI the node.
 java.lang.String getNamespaceURI(java.lang.String prefix)
          Returns the namespace URI associated with this namespace prefix, as defined in the context of this node.
 java.lang.String getNodeLocation()
          Finds and returns the location of this node in its root's tree.
 int getNodeType()
          Returns the type of this node.
 ParentNode getParentNode()
          Returns the parent node, or null if the node has no parent.
 XMLNode getRootNode()
          Returns the root node.
abstract  java.lang.String getStringValue()
          Returns the string value of the node.
protected  java.lang.String getXPath()
          Returns the XPath from the root node to this node.
 void setNamespace(java.lang.String namespace)
          Sets the namespace URI for this XMLNode.
(package private)  void setParent(ParentNode node)
          Sets the parent XMLNode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT

public static final int ROOT
Node is a root node.

See Also:
Constant Field Values

ELEMENT

public static final int ELEMENT
Node is an element.

See Also:
Constant Field Values

ATTRIBUTE

public static final int ATTRIBUTE
Node is an attribute.

See Also:
Constant Field Values

TEXT

public static final int TEXT
Node is a text node.

See Also:
Constant Field Values

PROCESSING_INSTRUCTION

public static final int PROCESSING_INSTRUCTION
Node is a processing instruction.

See Also:
Constant Field Values
Constructor Detail

XMLNode

XMLNode(java.lang.String namespace,
        java.lang.String localName,
        int nodeType)
Creates a new XMLNode

Parameters:
namespace - the namespace URI for this node. [May be null]
localName - the local-name of this node. [May be null]
nodeType - the node type being created
Method Detail

getNodeType

public final int getNodeType()
Returns the type of this node.

Returns:
The type of this node

getLocalName

public java.lang.String getLocalName()
Returns the local name of the node. Returns the local name of an element or attribute, the prefix of a namespace node, the target of a processing instruction, or null for all other node types.

Returns:
The local name of the node, or null if the node has no name

getNamespaceURI

public java.lang.String getNamespaceURI()
Returns the namespace URI the node. Returns the namespace URI of an element, attribute or namespace node, or null for all other node types.

Returns:
The namespace URI of the node, or null if the node has no namespace URI

getParentNode

public ParentNode getParentNode()
Returns the parent node, or null if the node has no parent. This method is valid on all node types except the root node. Attribute and namespace nodes have the element as their parent node.

Returns:
The parent node, or null

getRootNode

public XMLNode getRootNode()
Returns the root node.

Returns:
The root node

getStringValue

public abstract java.lang.String getStringValue()
Returns the string value of the node. The string value of a text node or an attribute node is its text value. The string value of an element or a root node is the concatenation of the string value of all its child nodes. The string value of a namespace node is its namespace URI. The string value of a processing instruction is the instruction, and the string value of a comment is the comment text.

Returns:
The string value of the node

getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.String prefix)
Returns the namespace URI associated with this namespace prefix, as defined in the context of this node. Returns null if the prefix is undefined. Returns empty if the prefix is defined and associated with no namespace. This method is valid only for element nodes.

Parameters:
prefix - The namespace prefix
Returns:
The namespace URI, or null

setNamespace

public void setNamespace(java.lang.String namespace)
Sets the namespace URI for this XMLNode.

Parameters:
namespace - the Namespace URI

setParent

void setParent(ParentNode node)
Sets the parent XMLNode.

Parameters:
node - the XMLNode which is the parent of this XMLNode

getNodeLocation

public java.lang.String getNodeLocation()
Finds and returns the location of this node in its root's tree.

Returns:
the location of this node in its root's tree.

getXPath

protected java.lang.String getXPath()
Returns the XPath from the root node to this node.

Returns:
the XPath from the root node to this node.


Intalio Inc. (C) 1999-2007. All rights reserved http://www.intalio.com