## org.apache.commons.configuration.tree.xpath
Class ConfigurationNodeIteratorBase

    java.lang.Object
      org.apache.commons.configuration.tree.xpath.ConfigurationNodeIteratorBase

All Implemented Interfaces:
  org.apache.commons.jxpath.ri.model.NodeIterator

Direct Known Subclasses:
  ConfigurationNodeIteratorAttribute, ConfigurationNodeIteratorChildren

    abstract class ConfigurationNodeIteratorBase

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
Version:
  $Id: ConfigurationNodeIteratorBase.java 439648 2006-09-02 20:42:10Z oheger $
Author:
  Oliver Heger

Constructor Summary
`protected` `ConfigurationNodeIteratorBase(org.apache.commons.jxpath.ri.model.NodePointer parent, boolean reverse)` Creates a new instance of `ConfigurationNodeIteratorBase` and initializes it.

Method Summary
`protected org.apache.commons.jxpath.ri.model.NodePointer` `createNodePointer(ConfigurationNode node)` Creates the configuration node pointer for the current position.
`protected int` `getMaxPosition()` Returns the maximum position for this iterator.
`org.apache.commons.jxpath.ri.model.NodePointer` `getNodePointer()` Returns the current node pointer.
`protected org.apache.commons.jxpath.ri.model.NodePointer` `getParent()` Returns the parent node pointer.
`int` `getPosition()` Returns the position of the iteration.
`protected int` `getStartOffset()` Returns the start offset of the iteration.
`protected void` `initSubNodeList(List nodes)` Initializes the list of sub nodes for the iteration.
`protected int` `positionToIndex(int pos)` Returns the index in the data list for the given position.
`boolean` `setPosition(int pos)` Sets the position of the iteration.
`protected void` `setStartOffset(int startOffset)` Sets the start offset of the iteration.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ConfigurationNodeIteratorBase

    protected ConfigurationNodeIteratorBase(org.apache.commons.jxpath.ri.model.NodePointer parent,
                                            boolean reverse)

  Creates a new instance of `ConfigurationNodeIteratorBase` and initializes it.

  Parameters:
    `parent` - the parent pointer
    `reverse` - the reverse flag

Method Detail

### getPosition

    public int getPosition()

  Returns 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()

  Returns 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 org.apache.commons.jxpath.ri.model.NodePointer getParent()

  Returns the parent node pointer.

  Returns:
    the parent node pointer

### getStartOffset

    protected int getStartOffset()

  Returns 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

### initSubNodeList

    protected void initSubNodeList(List nodes)

  Initializes the list of sub nodes for the iteration. This method must be called during initialization phase.

  Parameters:
    `nodes` - the list with the sub nodes

### getMaxPosition

    protected int getMaxPosition()

  Returns the maximum position for this iterator.

  Returns:
    the maximum allowed position

### createNodePointer

    protected org.apache.commons.jxpath.ri.model.NodePointer createNodePointer(ConfigurationNode node)

  Creates the configuration node pointer for the current position. This method is called by `getNodePointer()`. Derived classes must create the correct pointer object.

  Parameters:
    `node` - the current configuration node
  Returns:
    the node pointer

### 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

Copyright © 2001-2006 The Apache Software Foundation. All Rights Reserved.