Top Description Fields Constructors Methods
org.dom4j.io

pack-priv Class PruningElementStack

extends ElementStack
Class Inheritance
Imports
org.dom4j.Element, .ElementHandler

PruningElementStack is a stack of Elementinstances 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.

Author
James Strachan
Version
$Revision: 1.11 $

Field Summary

Modifier and TypeField and Description
private ElementHandler
elementHandler

ElementHandler to call when pruning occurs

private int
matchingElementIndex

The level at which a path match can occur.

private 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).

Inherited from org.dom4j.io.ElementStack:
lastElementIndexstack

Constructor Summary

AccessConstructor and Description
public
PruningElementStack(String[] path, ElementHandler elementHandler)

public
PruningElementStack(String[] path, ElementHandler elementHandler, int defaultCapacity)

Method Summary

Modifier and TypeMethod and Description
private void
protected void
pathMatches(Element parent, Element selectedNode)

public Element
popElement()

Overrides org.dom4j.io.ElementStack.popElement.

Pops the element off the stack
protected boolean
validElement(Element element, int index)

Inherited from org.dom4j.io.ElementStack:
addHandlerclearcontainsHandlergetCurrentgetDispatchHandlergetElementgetPathpeekElementpushElementreallocateremoveHandlersetDispatchHandlersize

Field Detail

elementHandlerback to summary
private ElementHandler elementHandler

ElementHandler to call when pruning occurs

matchingElementIndexback to summary
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

pathback to summary
private 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

Constructor Detail

PruningElementStackback to summary
public PruningElementStack(String[] path, ElementHandler elementHandler)
PruningElementStackback to summary
public PruningElementStack(String[] path, ElementHandler elementHandler, int defaultCapacity)

Method Detail

checkPathback to summary
private void checkPath()
pathMatchesback to summary
protected void pathMatches(Element parent, Element selectedNode)
popElementback to summary
public Element popElement()

Overrides org.dom4j.io.ElementStack.popElement.

Doc from org.dom4j.io.ElementStack.popElement.

Pops the element off the stack

Returns:Element

the element that has just been popped off the stack

validElementback to summary
protected boolean validElement(Element element, int index)