org.apache.commons.configuration.tree.xpath

Class ConfigurationNodePointer

class ConfigurationNodePointer extends NodePointer

A specific NodePointer implementation for configuration nodes.

This is needed for queries using JXPath.

Since: 1.3

Version: $Id: ConfigurationNodePointer.java 439648 2006-09-02 20:42:10Z oheger $

Author: Oliver Heger

Field Summary
ConfigurationNodenode
Stores the associated configuration node.
static longserialVersionUID
The serial version UID.
Constructor Summary
ConfigurationNodePointer(ConfigurationNode node, Locale locale)
Creates a new instance of ConfigurationNodePointer.
ConfigurationNodePointer(NodePointer parent, ConfigurationNode node)
Creates a new instance of ConfigurationNodePointer and initializes it with its parent pointer.
Method Summary
NodeIteratorattributeIterator(QName name)
Returns an iterator for the attributes that match the given name.
NodeIteratorchildIterator(NodeTest test, boolean reverse, NodePointer startWith)
Returns an iterator for the children of this pointer that match the given test object.
intcompareChildNodePointers(NodePointer pointer1, NodePointer pointer2)
Compares two child node pointers.
ObjectgetBaseValue()
Returns this node's base value.
ObjectgetImmediateNode()
Returns the immediate node.
intgetLength()
Returns this node's length.
QNamegetName()
Returns this node's name.
ObjectgetValue()
Returns the value of this node.
booleanisAttribute()
Checks whether this node pointer refers to an attribute node.
booleanisCollection()
Returns a flag if this node is a collection.
booleanisLeaf()
Returns a flag whether this node is a leaf.
voidsetValue(Object value)
Sets the value of this node.
booleantestNode(NodeTest test)
Tests if this node matches the given test.

Field Detail

node

private ConfigurationNode node
Stores the associated configuration node.

serialVersionUID

private static final long serialVersionUID
The serial version UID.

Constructor Detail

ConfigurationNodePointer

public ConfigurationNodePointer(ConfigurationNode node, Locale locale)
Creates a new instance of ConfigurationNodePointer.

Parameters: node the node locale the locale

ConfigurationNodePointer

public ConfigurationNodePointer(NodePointer parent, ConfigurationNode node)
Creates a new instance of ConfigurationNodePointer and initializes it with its parent pointer.

Parameters: parent the parent pointer node the associated node

Method Detail

attributeIterator

public NodeIterator attributeIterator(QName name)
Returns an iterator for the attributes that match the given name.

Parameters: name the attribute name

Returns: the iterator for the attributes

childIterator

public NodeIterator childIterator(NodeTest test, boolean reverse, NodePointer startWith)
Returns an iterator for the children of this pointer that match the given test object.

Parameters: test the test object reverse the reverse flag startWith the start value of the iteration

compareChildNodePointers

public int compareChildNodePointers(NodePointer pointer1, NodePointer pointer2)
Compares two child node pointers.

Parameters: pointer1 one pointer pointer2 another pointer

Returns: a flag, which pointer should be sorted first

getBaseValue

public Object getBaseValue()
Returns this node's base value. This is the associated configuration node.

Returns: the base value

getImmediateNode

public Object getImmediateNode()
Returns the immediate node. This is the associated configuration node.

Returns: the immediate node

getLength

public int getLength()
Returns this node's length. This is always 1.

Returns: the node's length

getName

public QName getName()
Returns this node's name.

Returns: the name

getValue

public Object getValue()
Returns the value of this node.

Returns: the represented node's value

isAttribute

public boolean isAttribute()
Checks whether this node pointer refers to an attribute node. This method checks the attribute flag of the associated configuration node.

Returns: the attribute flag

isCollection

public boolean isCollection()
Returns a flag if this node is a collection. This is not the case.

Returns: the collection flag

isLeaf

public boolean isLeaf()
Returns a flag whether this node is a leaf. This is the case if there are no child nodes.

Returns: a flag if this node is a leaf

setValue

public void setValue(Object value)
Sets the value of this node.

Parameters: value the new value

testNode

public boolean testNode(NodeTest test)
Tests if this node matches the given test. Configuration nodes are text nodes, too because they can contain a value.

Parameters: test the test object

Returns: a flag if this node corresponds to the test