org.castor.xmlctf.xmldiff.xml.nodes

Class XMLNode

Known Direct Subclasses:
Attribute, ParentNode, ProcessingInstruction, Text

public abstract class XMLNode
extends java.lang.Object

The base node for all XMLNode types.
Version:
$Revision: 0000 $ $Date: 2007-01-11 00:00:00 -0600 (Thu, 11 Jan 2007) $
Author:
Edward Kuns
Since:
Castor 1.1

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(String namespace, String localName, int nodeType)
Creates a new XMLNode

Method Summary

String
getLocalName()
Returns the local name of the node.
String
getNamespaceURI()
Returns the namespace URI the node.
String
getNamespaceURI(String prefix)
Returns the namespace URI associated with this namespace prefix, as defined in the context of this node.
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 String
getStringValue()
Returns the string value of the node.
protected String
getXPath()
Returns the XPath from the root node to this node.
void
setNamespace(String namespace)
Sets the namespace URI for this XMLNode.
(package private) void
setParent(ParentNode node)
Sets the parent XMLNode.

Field Details

ATTRIBUTE

public static final int ATTRIBUTE
Node is an attribute.
Field Value:
3

ELEMENT

public static final int ELEMENT
Node is an element.
Field Value:
2

PROCESSING_INSTRUCTION

public static final int PROCESSING_INSTRUCTION
Node is a processing instruction.
Field Value:
5

ROOT

public static final int ROOT
Node is a root node.
Field Value:
1

TEXT

public static final int TEXT
Node is a text node.
Field Value:
4

Constructor Details

XMLNode

(package private)  XMLNode(String namespace,
                           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 Details

getLocalName

public 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 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

getNamespaceURI

public String getNamespaceURI(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

getNodeLocation

public 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.

getNodeType

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

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 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

getXPath

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

setNamespace

public void setNamespace(String namespace)
Sets the namespace URI for this XMLNode.
Parameters:
namespace - the Namespace URI

setParent

(package private)  void setParent(ParentNode node)
Sets the parent XMLNode.
Parameters:
node - the XMLNode which is the parent of this XMLNode

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