Package org.dom4j.io
Class PruningElementStack
- java.lang.Object
-
- org.dom4j.io.ElementStack
-
- org.dom4j.io.PruningElementStack
-
- All Implemented Interfaces:
ElementPath
class PruningElementStack extends ElementStack
PruningElementStack
is a stack ofElement
instances which will prune the tree when a path expression is reached. This is useful for parsing very large documents where children of the root element can be processed individually rather than keeping them all in memory at the same time.- Version:
- $Revision: 1.11 $
-
-
Field Summary
Fields Modifier and Type Field Description private ElementHandler
elementHandler
ElementHandler to call when pruning occursprivate int
matchingElementIndex
The level at which a path match can occur.private java.lang.String[]
path
the element name path which denotes the node to remove from its parent when it is complete (i.e.-
Fields inherited from class org.dom4j.io.ElementStack
lastElementIndex, stack
-
-
Constructor Summary
Constructors Constructor Description PruningElementStack(java.lang.String[] path, ElementHandler elementHandler)
PruningElementStack(java.lang.String[] path, ElementHandler elementHandler, int defaultCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkPath()
protected void
pathMatches(Element parent, Element selectedNode)
Element
popElement()
Pops the element off the stackprotected boolean
validElement(Element element, int index)
-
Methods inherited from class org.dom4j.io.ElementStack
addHandler, clear, containsHandler, getCurrent, getDispatchHandler, getElement, getPath, peekElement, pushElement, reallocate, removeHandler, setDispatchHandler, size
-
-
-
-
Field Detail
-
elementHandler
private ElementHandler elementHandler
ElementHandler to call when pruning occurs
-
path
private java.lang.String[] path
the element name path which denotes the node to remove from its parent when it is complete (i.e. when it is popped from the stack). The first entry in the path will be a child of the root node
-
matchingElementIndex
private int matchingElementIndex
The level at which a path match can occur. We match when we have popped the selected node so the and the lastElementIndex points to its parent so this value should be path.length - 2
-
-
Constructor Detail
-
PruningElementStack
public PruningElementStack(java.lang.String[] path, ElementHandler elementHandler)
-
PruningElementStack
public PruningElementStack(java.lang.String[] path, ElementHandler elementHandler, int defaultCapacity)
-
-
Method Detail
-
popElement
public Element popElement()
Description copied from class:ElementStack
Pops the element off the stack- Overrides:
popElement
in classElementStack
- Returns:
- the element that has just been popped off the stack
-
validElement
protected boolean validElement(Element element, int index)
-
checkPath
private void checkPath()
-
-