Class AbstractConfigurationNodeIterator<T>

java.lang.Object
org.apache.commons.configuration2.tree.xpath.AbstractConfigurationNodeIterator<T>
Type Parameters:
T - the type of the nodes this iterator deals with
All Implemented Interfaces:
org.apache.commons.jxpath.ri.model.NodeIterator
Direct Known Subclasses:
ConfigurationNodeIteratorAttribute, ConfigurationNodeIteratorChildren

abstract class AbstractConfigurationNodeIterator<T> extends Object implements org.apache.commons.jxpath.ri.model.NodeIterator

A base class for implementing iterators over configuration nodes.

This class already provides common functionality for implementing the iteration process. Derived classes will implement specific behavior based on the concrete node type (child node or attribute node).

Since:
1.3
  • Field Details

    • PREFIX_SEPARATOR

      private static final String PREFIX_SEPARATOR
      Constant for the prefix separator.
      See Also:
    • FMT_NAMESPACE

      private static final String FMT_NAMESPACE
      A format for constructing a node name with a namespace prefix.
      See Also:
    • parent

      private final ConfigurationNodePointer<T> parent
      Stores the parent node pointer.
    • position

      private int position
      Stores the current position.
    • startOffset

      private int startOffset
      Stores the start offset of the iterator.
    • reverse

      private final boolean reverse
      Stores the reverse flag.
  • Constructor Details

    • AbstractConfigurationNodeIterator

      protected AbstractConfigurationNodeIterator(ConfigurationNodePointer<T> parent, boolean reverse)
      Creates a new instance of ConfigurationNodeIteratorBase and initializes it.
      Parameters:
      parent - the parent pointer
      reverse - the reverse flag
  • Method Details

    • getPosition

      public int getPosition()
      Gets the position of the iteration.
      Specified by:
      getPosition in interface org.apache.commons.jxpath.ri.model.NodeIterator
      Returns:
      the position
    • setPosition

      public boolean setPosition(int pos)
      Sets the position of the iteration.
      Specified by:
      setPosition in interface org.apache.commons.jxpath.ri.model.NodeIterator
      Parameters:
      pos - the new position
      Returns:
      a flag if this is a valid position
    • getNodePointer

      public org.apache.commons.jxpath.ri.model.NodePointer getNodePointer()
      Gets the current node pointer.
      Specified by:
      getNodePointer in interface org.apache.commons.jxpath.ri.model.NodeIterator
      Returns:
      the current pointer in this iteration
    • getParent

      protected ConfigurationNodePointer<T> getParent()
      Gets the parent node pointer.
      Returns:
      the parent node pointer
    • getNodeHandler

      protected NodeHandler<T> getNodeHandler()
      Gets the node handler for the managed nodes. This is a convenience method.
      Returns:
      the node handler
    • getStartOffset

      protected int getStartOffset()
      Gets the start offset of the iteration.
      Returns:
      the start offset
    • setStartOffset

      protected void setStartOffset(int startOffset)
      Sets the start offset of the iteration. This is used when a start element was set.
      Parameters:
      startOffset - the start offset
    • getMaxPosition

      protected int getMaxPosition()
      Gets the maximum position for this iterator.
      Returns:
      the maximum allowed position
    • positionToIndex

      protected int positionToIndex(int pos)
      Returns the index in the data list for the given position. This method also checks the reverse flag.
      Parameters:
      pos - the position (1-based)
      Returns:
      the corresponding list index
    • createNodePointer

      protected abstract org.apache.commons.jxpath.ri.model.NodePointer createNodePointer(int position)
      Creates the configuration node pointer for the current position. This method is called by getNodePointer(). Derived classes must create the correct pointer object.
      Parameters:
      position - the current position in the iteration
      Returns:
      the node pointer
    • size

      protected abstract int size()
      Returns the number of elements in this iteration.
      Returns:
      the number of elements
    • prefixName

      protected static String prefixName(String prefix, String name)
      Generates a qualified name with a namespace prefix.
      Parameters:
      prefix - the prefix
      name - the name (may be null)
      Returns:
      the qualified name
    • qualifiedName

      protected static String qualifiedName(org.apache.commons.jxpath.ri.QName name)
      Returns the qualified name from the given QName. If the name has no namespace, result is the simple name. Otherwise, the namespace prefix is added.
      Parameters:
      name - the QName
      Returns:
      the qualified name