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

    Fields
    Modifier and Type
    Field
    Description
    private 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

    Constructors
    Constructor
    Description
    Creates a new instance of ConfigurationNodePointer and initializes it with its parent pointer.
    ConfigurationNodePointer(T node, Locale locale, NodeHandler<T> handler)
    Creates a new instance of ConfigurationNodePointer pointing to the specified node.
  • Method Summary

    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.
    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
    Gets this node's name.
    Gets the NodeHandler used by this instance.
    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
    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

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      The serial version UID.
      See Also:
    • handler

      private final NodeHandler<T> handler
      The node handler.
    • node

      private final T node
      Stores the associated node.
  • Constructor Details

    • ConfigurationNodePointer

      public ConfigurationNodePointer(T node, Locale locale, NodeHandler<T> handler)
      Creates a new instance of ConfigurationNodePointer pointing to the specified node.
      Parameters:
      node - the wrapped node
      locale - the locale
      handler - the NodeHandler
    • ConfigurationNodePointer

      public ConfigurationNodePointer(ConfigurationNodePointer<T> parent, T node, NodeHandler<T> handler)
      Creates a new instance of ConfigurationNodePointer and initializes it with its parent pointer.
      Parameters:
      parent - the parent pointer
      node - the associated node
      handler - the NodeHandler
  • 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 class org.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 class org.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 class org.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 class org.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 class org.apache.commons.jxpath.ri.model.NodePointer
      Returns:
      the name
    • getBaseValue

      public Object getBaseValue()
      Gets this node's base value. This is the associated configuration node.
      Specified by:
      getBaseValue in class org.apache.commons.jxpath.ri.model.NodePointer
      Returns:
      the base value
    • getImmediateNode

      public Object getImmediateNode()
      Gets the immediate node. This is the associated configuration node.
      Specified by:
      getImmediateNode in class org.apache.commons.jxpath.ri.model.NodePointer
      Returns:
      the immediate node
    • getValue

      public Object getValue()
      Gets the value of this node.
      Specified by:
      getValue in interface org.apache.commons.jxpath.Pointer
      Overrides:
      getValue in class org.apache.commons.jxpath.ri.model.NodePointer
      Returns:
      the represented node's value
    • setValue

      public void setValue(Object value)
      Sets the value of this node. This is not supported, so always an exception is thrown.
      Specified by:
      setValue in interface org.apache.commons.jxpath.Pointer
      Specified by:
      setValue in class org.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 class org.apache.commons.jxpath.ri.model.NodePointer
      Parameters:
      pointer1 - one pointer
      pointer2 - 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 class org.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 class org.apache.commons.jxpath.ri.model.NodePointer
      Parameters:
      test - the test object
      reverse - the reverse flag
      startWith - 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 class org.apache.commons.jxpath.ri.model.NodePointer
      Parameters:
      test - the test object
      Returns:
      a flag if this node corresponds to the test
    • getNodeHandler

      public NodeHandler<T> getNodeHandler()
      Gets the NodeHandler used by this instance.
      Returns:
      the NodeHandler
    • getConfigurationNode

      public T getConfigurationNode()
      Gets the wrapped configuration node.
      Returns:
      the wrapped node
    • 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 - the NodePointer to cast
      Returns:
      the resulting ConfigurationNodePointer