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

Version:
$Revision: 1.11 $
  • Field Details

    • elementHandler

      private ElementHandler elementHandler
      ElementHandler to call when pruning occurs
    • path

      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
    • 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 Details

    • PruningElementStack

      public PruningElementStack(String[] path, ElementHandler elementHandler)
    • PruningElementStack

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

    • popElement

      public Element popElement()
      Description copied from class: ElementStack
      Pops the element off the stack
      Overrides:
      popElement in class ElementStack
      Returns:
      the element that has just been popped off the stack
    • pathMatches

      protected void pathMatches(Element parent, Element selectedNode)
    • validElement

      protected boolean validElement(Element element, int index)
    • checkPath

      private void checkPath()