Class 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 java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String FMT_NAMESPACE
      A format for constructing a node name with a namespace prefix.
      private ConfigurationNodePointer<T> parent
      Stores the parent node pointer.
      private int position
      Stores the current position.
      private static java.lang.String PREFIX_SEPARATOR
      Constant for the prefix separator.
      private boolean reverse
      Stores the reverse flag.
      private int startOffset
      Stores the start offset of the iterator.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract org.apache.commons.jxpath.ri.model.NodePointer createNodePointer​(int position)
      Creates the configuration node pointer for the current position.
      protected int getMaxPosition()
      Gets the maximum position for this iterator.
      protected NodeHandler<T> getNodeHandler()
      Gets the node handler for the managed nodes.
      org.apache.commons.jxpath.ri.model.NodePointer getNodePointer()
      Gets the current node pointer.
      protected ConfigurationNodePointer<T> getParent()
      Gets the parent node pointer.
      int getPosition()
      Gets the position of the iteration.
      protected int getStartOffset()
      Gets the start offset of the iteration.
      protected int positionToIndex​(int pos)
      Returns the index in the data list for the given position.
      protected static java.lang.String prefixName​(java.lang.String prefix, java.lang.String name)
      Generates a qualified name with a namespace prefix.
      protected static java.lang.String qualifiedName​(org.apache.commons.jxpath.ri.QName name)
      Returns the qualified name from the given QName.
      boolean setPosition​(int pos)
      Sets the position of the iteration.
      protected void setStartOffset​(int startOffset)
      Sets the start offset of the iteration.
      protected abstract int size()
      Returns the number of elements in this iteration.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PREFIX_SEPARATOR

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

        private static final java.lang.String FMT_NAMESPACE
        A format for constructing a node name with a namespace prefix.
        See Also:
        Constant Field Values
      • 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 Detail

      • 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 Detail

      • prefixName

        protected static java.lang.String prefixName​(java.lang.String prefix,
                                                     java.lang.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 java.lang.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
      • 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
      • getMaxPosition

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

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

        protected int getStartOffset()
        Gets the start offset of the iteration.
        Returns:
        the start offset
      • 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
      • 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
      • 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
      • size

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