Class ConfigurationNodeIteratorChildren<T>
- java.lang.Object
-
- org.apache.commons.configuration2.tree.xpath.AbstractConfigurationNodeIterator<T>
-
- org.apache.commons.configuration2.tree.xpath.ConfigurationNodeIteratorChildren<T>
-
- Type Parameters:
T
- the type of the nodes this iterator deals with
- All Implemented Interfaces:
org.apache.commons.jxpath.ri.model.NodeIterator
final class ConfigurationNodeIteratorChildren<T> extends AbstractConfigurationNodeIterator<T>
A specialized iterator implementation for the child nodes of a configuration node.- Since:
- 1.3
-
-
Constructor Summary
Constructors Constructor Description ConfigurationNodeIteratorChildren(ConfigurationNodePointer<T> parent, org.apache.commons.jxpath.ri.compiler.NodeTest nodeTest, boolean reverse, ConfigurationNodePointer<T> startsWith)
Creates a new instance ofConfigurationNodeIteratorChildren
and initializes it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.commons.jxpath.ri.model.NodePointer
createNodePointer(int position)
Creates the configuration node pointer for the current position.private java.util.List<T>
createSubNodeList(T node, org.apache.commons.jxpath.ri.compiler.NodeTest test)
Creates the list with sub nodes.private java.util.List<T>
createSubNodeListForName(T node, org.apache.commons.jxpath.ri.QName name)
Obtains the list of selected nodes for aNodeNameTest
with either a simple or a qualified name.private java.util.List<T>
createSubNodeListForWildcardName(T node, org.apache.commons.jxpath.ri.QName name)
Obtains the list of selected sub nodes for aNodeNameTest
with a wildcard name.private int
findStartIndex(java.util.List<T> children, T startNode)
Determines the start position of the iteration.protected int
size()
Returns the number of elements in this iteration.-
Methods inherited from class org.apache.commons.configuration2.tree.xpath.AbstractConfigurationNodeIterator
getMaxPosition, getNodeHandler, getNodePointer, getParent, getPosition, getStartOffset, positionToIndex, prefixName, qualifiedName, setPosition, setStartOffset
-
-
-
-
Field Detail
-
subNodes
private final java.util.List<T> subNodes
The list with the sub nodes to iterate over.
-
-
Constructor Detail
-
ConfigurationNodeIteratorChildren
public ConfigurationNodeIteratorChildren(ConfigurationNodePointer<T> parent, org.apache.commons.jxpath.ri.compiler.NodeTest nodeTest, boolean reverse, ConfigurationNodePointer<T> startsWith)
Creates a new instance ofConfigurationNodeIteratorChildren
and initializes it.- Parameters:
parent
- the parent pointernodeTest
- the test selecting the sub nodesreverse
- the reverse flagstartsWith
- the first element of the iteration
-
-
Method Detail
-
createNodePointer
protected org.apache.commons.jxpath.ri.model.NodePointer createNodePointer(int position)
Creates the configuration node pointer for the current position.- Specified by:
createNodePointer
in classAbstractConfigurationNodeIterator<T>
- Parameters:
position
- the current position in the iteration- Returns:
- the node pointer
-
createSubNodeList
private java.util.List<T> createSubNodeList(T 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 nodetest
- the test object- Returns:
- a list with the matching nodes
-
createSubNodeListForName
private java.util.List<T> createSubNodeListForName(T node, org.apache.commons.jxpath.ri.QName name)
Obtains the list of selected nodes for aNodeNameTest
with either a simple or a qualified name.- Parameters:
node
- the current nodename
- the name to be selected- Returns:
- the list with selected sub nodes
-
createSubNodeListForWildcardName
private java.util.List<T> createSubNodeListForWildcardName(T node, org.apache.commons.jxpath.ri.QName name)
Obtains the list of selected sub nodes for aNodeNameTest
with a wildcard name.- Parameters:
node
- the current nodename
- the name to be selected- Returns:
- the list with selected sub nodes
-
findStartIndex
private int findStartIndex(java.util.List<T> children, T startNode)
Determines the start position of the iteration. Finds the index of the given start node in the children of the root node.- Parameters:
children
- the children of the root nodestartNode
- the start node- Returns:
- the start node's index
-
size
protected int size()
Returns the number of elements in this iteration. This is the number of elements in the children list.- Specified by:
size
in classAbstractConfigurationNodeIterator<T>
- Returns:
- the number of elements
-
-