Class ConfigurationNodePointer<T>
- java.lang.Object
-
- org.apache.commons.jxpath.ri.model.NodePointer
-
- org.apache.commons.configuration2.tree.xpath.ConfigurationNodePointer<T>
-
- Type Parameters:
T
- the type of the nodes this pointer deals with
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable
,org.apache.commons.jxpath.Pointer
final class ConfigurationNodePointer<T> extends org.apache.commons.jxpath.ri.model.NodePointer
A specific
NodePointer
implementation for configuration nodes.This is needed for queries using JXPath.
- Since:
- 1.3
-
-
Field Summary
Fields Modifier and Type Field Description private NodeHandler<T>
handler
The node handler.private T
node
Stores the associated node.private static long
serialVersionUID
The serial version UID.
-
Constructor Summary
Constructors Constructor Description ConfigurationNodePointer(ConfigurationNodePointer<T> parent, T node, NodeHandler<T> handler)
Creates a new instance ofConfigurationNodePointer
and initializes it with its parent pointer.ConfigurationNodePointer(T node, java.util.Locale locale, NodeHandler<T> handler)
Creates a new instance ofConfigurationNodePointer
pointing to the specified node.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.commons.jxpath.ri.model.NodeIterator
attributeIterator(org.apache.commons.jxpath.ri.QName name)
Returns an iterator for the attributes that match the given name.private ConfigurationNodePointer<T>
castPointer(org.apache.commons.jxpath.ri.model.NodePointer p)
Casts the given child pointer to a node pointer of this type.org.apache.commons.jxpath.ri.model.NodeIterator
childIterator(org.apache.commons.jxpath.ri.compiler.NodeTest test, boolean reverse, org.apache.commons.jxpath.ri.model.NodePointer startWith)
Returns an iterator for the children of this pointer that match the given test object.int
compareChildNodePointers(org.apache.commons.jxpath.ri.model.NodePointer pointer1, org.apache.commons.jxpath.ri.model.NodePointer pointer2)
Compares two child node pointers.java.lang.Object
getBaseValue()
Gets this node's base value.T
getConfigurationNode()
Gets the wrapped configuration node.java.lang.Object
getImmediateNode()
Gets the immediate node.int
getLength()
Gets this node's length.org.apache.commons.jxpath.ri.QName
getName()
Gets this node's name.NodeHandler<T>
getNodeHandler()
Gets theNodeHandler
used by this instance.java.lang.Object
getValue()
Gets the value of this node.boolean
isAttribute()
Checks whether this node pointer refers to an attribute node.boolean
isCollection()
Returns a flag if this node is a collection.boolean
isLeaf()
Returns a flag whether this node is a leaf.void
setValue(java.lang.Object value)
Sets the value of this node.boolean
testNode(org.apache.commons.jxpath.ri.compiler.NodeTest test)
Tests if this node matches the given test.-
Methods inherited from class org.apache.commons.jxpath.ri.model.NodePointer
asPath, clone, compareTo, createAttribute, createChild, createChild, createPath, createPath, escape, getAbstractFactory, getDefaultNamespaceURI, getImmediateParentPointer, getImmediateValuePointer, getIndex, getLocale, getNamespaceResolver, getNamespaceURI, getNamespaceURI, getNode, getNodeSetByKey, getNodeValue, getParent, getPointerByID, getPointerByKey, getRootNode, getValuePointer, isActual, isContainer, isDefaultNamespace, isLanguage, isNode, isRoot, namespaceIterator, namespacePointer, newChildNodePointer, newNodePointer, printPointerChain, remove, setAttribute, setIndex, setNamespaceResolver, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
The serial version UID.- See Also:
- Constant Field Values
-
handler
private final NodeHandler<T> handler
The node handler.
-
node
private final T node
Stores the associated node.
-
-
Constructor Detail
-
ConfigurationNodePointer
public ConfigurationNodePointer(ConfigurationNodePointer<T> parent, T node, NodeHandler<T> handler)
Creates a new instance ofConfigurationNodePointer
and initializes it with its parent pointer.- Parameters:
parent
- the parent pointernode
- the associated nodehandler
- theNodeHandler
-
ConfigurationNodePointer
public ConfigurationNodePointer(T node, java.util.Locale locale, NodeHandler<T> handler)
Creates a new instance ofConfigurationNodePointer
pointing to the specified node.- Parameters:
node
- the wrapped nodelocale
- the localehandler
- theNodeHandler
-
-
Method Detail
-
attributeIterator
public org.apache.commons.jxpath.ri.model.NodeIterator attributeIterator(org.apache.commons.jxpath.ri.QName name)
Returns an iterator for the attributes that match the given name.- Overrides:
attributeIterator
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Parameters:
name
- the attribute name- Returns:
- the iterator for the attributes
-
castPointer
private ConfigurationNodePointer<T> castPointer(org.apache.commons.jxpath.ri.model.NodePointer p)
Casts the given child pointer to a node pointer of this type. This is a bit dangerous. However, in a typical setup, child node pointers can only be created by this instance which ensures that they are of the correct type. Therefore, this cast is safe.- Parameters:
p
- theNodePointer
to cast- Returns:
- the resulting
ConfigurationNodePointer
-
childIterator
public org.apache.commons.jxpath.ri.model.NodeIterator childIterator(org.apache.commons.jxpath.ri.compiler.NodeTest test, boolean reverse, org.apache.commons.jxpath.ri.model.NodePointer startWith)
Returns an iterator for the children of this pointer that match the given test object.- Overrides:
childIterator
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Parameters:
test
- the test objectreverse
- the reverse flagstartWith
- the start value of the iteration
-
compareChildNodePointers
public int compareChildNodePointers(org.apache.commons.jxpath.ri.model.NodePointer pointer1, org.apache.commons.jxpath.ri.model.NodePointer pointer2)
Compares two child node pointers.- Specified by:
compareChildNodePointers
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Parameters:
pointer1
- one pointerpointer2
- another pointer- Returns:
- a flag, which pointer should be sorted first
-
getBaseValue
public java.lang.Object getBaseValue()
Gets this node's base value. This is the associated configuration node.- Specified by:
getBaseValue
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Returns:
- the base value
-
getConfigurationNode
public T getConfigurationNode()
Gets the wrapped configuration node.- Returns:
- the wrapped node
-
getImmediateNode
public java.lang.Object getImmediateNode()
Gets the immediate node. This is the associated configuration node.- Specified by:
getImmediateNode
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Returns:
- the immediate node
-
getLength
public int getLength()
Gets this node's length. This is always 1.- Specified by:
getLength
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Returns:
- the node's length
-
getName
public org.apache.commons.jxpath.ri.QName getName()
Gets this node's name.- Specified by:
getName
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Returns:
- the name
-
getNodeHandler
public NodeHandler<T> getNodeHandler()
Gets theNodeHandler
used by this instance.- Returns:
- the
NodeHandler
-
getValue
public java.lang.Object getValue()
Gets the value of this node.- Specified by:
getValue
in interfaceorg.apache.commons.jxpath.Pointer
- Overrides:
getValue
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Returns:
- the represented node's value
-
isAttribute
public boolean isAttribute()
Checks whether this node pointer refers to an attribute node. This is not the case.- Overrides:
isAttribute
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Returns:
- the attribute flag
-
isCollection
public boolean isCollection()
Returns a flag if this node is a collection. This is not the case.- Specified by:
isCollection
in classorg.apache.commons.jxpath.ri.model.NodePointer
- 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.- Specified by:
isLeaf
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Returns:
- a flag if this node is a leaf
-
setValue
public void setValue(java.lang.Object value)
Sets the value of this node. This is not supported, so always an exception is thrown.- Specified by:
setValue
in interfaceorg.apache.commons.jxpath.Pointer
- Specified by:
setValue
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Parameters:
value
- the new value
-
testNode
public boolean testNode(org.apache.commons.jxpath.ri.compiler.NodeTest test)
Tests if this node matches the given test. Configuration nodes are text nodes, too because they can contain a value.- Overrides:
testNode
in classorg.apache.commons.jxpath.ri.model.NodePointer
- Parameters:
test
- the test object- Returns:
- a flag if this node corresponds to the test
-
-