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:
Serializable
,Cloneable
,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
FieldsModifier and TypeFieldDescriptionprivate final NodeHandler
<T> The node handler.private final T
Stores the associated node.private static final long
The serial version UID.Fields inherited from class org.apache.commons.jxpath.ri.model.NodePointer
index, locale, parent, UNKNOWN_NAMESPACE, WHOLE_COLLECTION
-
Constructor Summary
ConstructorsConstructorDescriptionConfigurationNodePointer
(ConfigurationNodePointer<T> parent, T node, NodeHandler<T> handler) Creates a new instance ofConfigurationNodePointer
and initializes it with its parent pointer.ConfigurationNodePointer
(T node, Locale locale, NodeHandler<T> handler) Creates a new instance ofConfigurationNodePointer
pointing to the specified node. -
Method Summary
Modifier and TypeMethodDescriptionorg.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.Gets this node's base value.Gets the wrapped configuration node.Gets the immediate node.int
Gets this node's length.org.apache.commons.jxpath.ri.QName
getName()
Gets this node's name.Gets theNodeHandler
used by this instance.getValue()
Gets the value of this node.boolean
Checks whether this node pointer refers to an attribute node.boolean
Returns a flag if this node is a collection.boolean
isLeaf()
Returns a flag whether this node is a leaf.void
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 Details
-
serialVersionUID
private static final long serialVersionUIDThe serial version UID.- See Also:
-
handler
The node handler. -
node
Stores the associated node.
-
-
Constructor Details
-
ConfigurationNodePointer
Creates a new instance ofConfigurationNodePointer
pointing to the specified node.- Parameters:
node
- the wrapped nodelocale
- the localehandler
- theNodeHandler
-
ConfigurationNodePointer
Creates a new instance ofConfigurationNodePointer
and initializes it with its parent pointer.- Parameters:
parent
- the parent pointernode
- the associated nodehandler
- theNodeHandler
-
-
Method Details
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
setValue
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
-
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
-
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
-
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
-
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
-
getNodeHandler
Gets theNodeHandler
used by this instance.- Returns:
- the
NodeHandler
-
getConfigurationNode
Gets the wrapped configuration node.- Returns:
- the wrapped node
-
castPointer
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
-