Top Description Fields Constructors Methods
org.dom4j.io

pack-priv Class ElementStack

extends Object
implements ElementPath
Class Inheritance
All Implemented Interfaces
org.dom4j.ElementPath
Known Direct Subclasses
org.dom4j.io.PruningElementStack
Imports
org.dom4j.Element, .ElementHandler, .ElementPath

ElementStack is used internally inside the SAXContentHandler to maintain a stack of Elementinstances. It opens an integration possibility allowing derivations to prune the tree when a node is complete.

Author
James Strachan
Version
$Revision: 1.14 $

Field Summary

Modifier and TypeField and Description
private DispatchHandler
protected int
lastElementIndex

index of the item at the top of the stack or -1 if the stack is empty

protected Element[]
stack

stack of Element objects

Constructor Summary

AccessConstructor and Description
public
public
ElementStack(int defaultCapacity)

Method Summary

Modifier and TypeMethod and Description
public void
addHandler(String
is the path to be handled
path
,
ElementHandler
is the ElementHandler to be called by the event based processor.
elementHandler
)

Implements org.dom4j.ElementPath.addHandler.

Adds the ElementHandler to be called when the specified path is encounted.
public void
clear()

Peeks at the top element on the stack without changing the contents of the stack.

public boolean

Returns:

true when an ElementHandler is registered for the specified path.
containsHandler
(String
DOCUMENT ME!
path
)

DOCUMENT ME!

public Element
getCurrent()

Implements org.dom4j.ElementPath.getCurrent.

DOCUMENT ME!
public DispatchHandler
public Element
getElement(int
DOCUMENT ME!
depth
)

Implements org.dom4j.ElementPath.getElement.

DOCUMENT ME!
private String
public String
getPath()

Implements org.dom4j.ElementPath.getPath.

DOCUMENT ME!
public Element

Returns:

the current element on the stack
peekElement
()

Peeks at the top element on the stack without changing the contents of the stack.

public Element

Returns:

the element that has just been popped off the stack
popElement
()

Pops the element off the stack

public void
pushElement(Element
DOCUMENT ME!
element
)

Pushes a new element onto the stack

protected void
reallocate(int
DOCUMENT ME!
size
)

Reallocates the stack to the given size

public void
removeHandler(String
is the path to remove the ElementHandler for.
path
)

Implements org.dom4j.ElementPath.removeHandler.

Removes the ElementHandler from the event based processor, for the specified path.
public void
public int
size()

Implements org.dom4j.ElementPath.size.

DOCUMENT ME!
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

handlerback to summary
private DispatchHandler handler
lastElementIndexback to summary
protected int lastElementIndex

index of the item at the top of the stack or -1 if the stack is empty

stackback to summary
protected Element[] stack

stack of Element objects

Constructor Detail

ElementStackback to summary
public ElementStack()
ElementStackback to summary
public ElementStack(int defaultCapacity)

Method Detail

addHandlerback to summary
public void addHandler(String path, ElementHandler elementHandler)

Implements org.dom4j.ElementPath.addHandler.

Doc from org.dom4j.ElementPath.addHandler.

Adds the ElementHandler to be called when the specified path is encounted. The path can be either an absolute path (i.e. prefixed with "/") or a relative path (i.e. assummed to be a child of the current path as retrieved by getPath .

Parameters
path:String

is the path to be handled

elementHandler:ElementHandler

is the ElementHandler to be called by the event based processor.

clearback to summary
public void clear()

Peeks at the top element on the stack without changing the contents of the stack.

containsHandlerback to summary
public boolean containsHandler(String path)

DOCUMENT ME!

Parameters
path:String

DOCUMENT ME!

Returns:boolean

true when an ElementHandler is registered for the specified path.

getCurrentback to summary
public Element getCurrent()

Implements org.dom4j.ElementPath.getCurrent.

Doc from org.dom4j.ElementPath.getCurrent.

DOCUMENT ME!

Returns:Element

the current element

getDispatchHandlerback to summary
public DispatchHandler getDispatchHandler()
getElementback to summary
public Element getElement(int depth)

Implements org.dom4j.ElementPath.getElement.

Doc from org.dom4j.ElementPath.getElement.

DOCUMENT ME!

Parameters
depth:int

DOCUMENT ME!

Returns:Element

the element at the specified depth index, 0 = root element

getHandlerPathback to summary
private String getHandlerPath(String path)
getPathback to summary
public String getPath()

Implements org.dom4j.ElementPath.getPath.

Doc from org.dom4j.ElementPath.getPath.

DOCUMENT ME!

Returns:String

the path as a string

peekElementback to summary
public Element peekElement()

Peeks at the top element on the stack without changing the contents of the stack.

Returns:Element

the current element on the stack

popElementback to summary
public Element popElement()

Pops the element off the stack

Returns:Element

the element that has just been popped off the stack

pushElementback to summary
public void pushElement(Element element)

Pushes a new element onto the stack

Parameters
element:Element

DOCUMENT ME!

reallocateback to summary
protected void reallocate(int size)

Reallocates the stack to the given size

Parameters
size:int

DOCUMENT ME!

removeHandlerback to summary
public void removeHandler(String path)

Implements org.dom4j.ElementPath.removeHandler.

Doc from org.dom4j.ElementPath.removeHandler.

Removes the ElementHandler from the event based processor, for the specified path. The path can be either an absolute path (i.e. prefixed with "/") or a relative path (i.e. assummed to be a child of the current path as retrieved by getPath .

Parameters
path:String

is the path to remove the ElementHandler for.

setDispatchHandlerback to summary
public void setDispatchHandler(DispatchHandler dispatchHandler)
sizeback to summary
public int size()

Implements org.dom4j.ElementPath.size.

Doc from org.dom4j.ElementPath.size.

DOCUMENT ME!

Returns:int

the number of elements in the path