org.apache.commons.configuration.tree.xpath
Class ConfigurationNodeIteratorChildren

java.lang.Object
  extended byorg.apache.commons.configuration.tree.xpath.ConfigurationNodeIteratorBase
      extended byorg.apache.commons.configuration.tree.xpath.ConfigurationNodeIteratorChildren
All Implemented Interfaces:
org.apache.commons.jxpath.ri.model.NodeIterator

class ConfigurationNodeIteratorChildren
extends ConfigurationNodeIteratorBase

A specialized iterator implementation for the child nodes of a configuration node.

Since:
1.3
Version:
$Id: ConfigurationNodeIteratorChildren.java 439648 2006-09-02 20:42:10Z oheger $
Author:
Oliver Heger

Constructor Summary
ConfigurationNodeIteratorChildren(org.apache.commons.jxpath.ri.model.NodePointer parent, org.apache.commons.jxpath.ri.compiler.NodeTest nodeTest, boolean reverse, org.apache.commons.jxpath.ri.model.NodePointer startsWith)
          Creates a new instance of ConfigurationNodeIteratorChildren 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  List createSubNodeList(ConfigurationNode node, org.apache.commons.jxpath.ri.compiler.NodeTest test)
          Creates the list with sub nodes.
protected  int findStartIndex(ConfigurationNode node, ConfigurationNode startNode)
          Determines the start position of the iteration.
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

ConfigurationNodeIteratorChildren

public ConfigurationNodeIteratorChildren(org.apache.commons.jxpath.ri.model.NodePointer parent,
                                         org.apache.commons.jxpath.ri.compiler.NodeTest nodeTest,
                                         boolean reverse,
                                         org.apache.commons.jxpath.ri.model.NodePointer startsWith)
Creates a new instance of ConfigurationNodeIteratorChildren and initializes it.

Parameters:
parent - the parent pointer
nodeTest - the test selecting the sub nodes
reverse - the reverse flag
startsWith - the first element of the iteration
Method Detail

createSubNodeList

protected List createSubNodeList(ConfigurationNode node,
                                 org.apache.commons.jxpath.ri.compiler.NodeTest test)
Creates the list with sub nodes. This method gets called during initialization phase. It finds out, based on the given test, which nodes must be iterated over.

Parameters:
node - the current node
test - the test object
Returns:
a list with the matching nodes

findStartIndex

protected int findStartIndex(ConfigurationNode node,
                             ConfigurationNode startNode)
Determines the start position of the iteration. Finds the index of the given start node in the children of the root node.

Parameters:
node - the root node
startNode - the start node
Returns:
the start node's index

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.