Package org.dom4j.io
Class ElementStack
java.lang.Object
org.dom4j.io.ElementStack
- All Implemented Interfaces:
ElementPath
- Direct Known Subclasses:
PruningElementStack
ElementStack
is used internally inside the SAXContentHandler
to maintain a stack of Element
instances. It opens
an integration possibility allowing derivations to prune the tree when a node
is complete.
- Version:
- $Revision: 1.14 $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DispatchHandler
protected int
index of the item at the top of the stack or -1 if the stack is emptyprotected Element[]
stack ofElement
objects -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHandler
(String path, ElementHandler elementHandler) Adds theElementHandler
to be called when the specified path is encounted.void
clear()
Peeks at the top element on the stack without changing the contents of the stack.boolean
containsHandler
(String path) DOCUMENT ME!DOCUMENT ME!getElement
(int depth) DOCUMENT ME!private String
getHandlerPath
(String path) getPath()
DOCUMENT ME!Peeks at the top element on the stack without changing the contents of the stack.Pops the element off the stackvoid
pushElement
(Element element) Pushes a new element onto the stackprotected void
reallocate
(int size) Reallocates the stack to the given sizevoid
removeHandler
(String path) Removes theElementHandler
from the event based processor, for the specified path.void
setDispatchHandler
(DispatchHandler dispatchHandler) int
size()
DOCUMENT ME!
-
Field Details
-
stack
stack ofElement
objects -
lastElementIndex
protected int lastElementIndexindex of the item at the top of the stack or -1 if the stack is empty -
handler
-
-
Constructor Details
-
ElementStack
public ElementStack() -
ElementStack
public ElementStack(int defaultCapacity)
-
-
Method Details
-
setDispatchHandler
-
getDispatchHandler
-
clear
public void clear()Peeks at the top element on the stack without changing the contents of the stack. -
peekElement
Peeks at the top element on the stack without changing the contents of the stack.- Returns:
- the current element on the stack
-
popElement
Pops the element off the stack- Returns:
- the element that has just been popped off the stack
-
pushElement
Pushes a new element onto the stack- Parameters:
element
- DOCUMENT ME!
-
reallocate
protected void reallocate(int size) Reallocates the stack to the given size- Parameters:
size
- DOCUMENT ME!
-
size
public int size()Description copied from interface:ElementPath
DOCUMENT ME!- Specified by:
size
in interfaceElementPath
- Returns:
- the number of elements in the path
-
getElement
Description copied from interface:ElementPath
DOCUMENT ME!- Specified by:
getElement
in interfaceElementPath
- Parameters:
depth
- DOCUMENT ME!- Returns:
- the element at the specified depth index, 0 = root element
-
getPath
Description copied from interface:ElementPath
DOCUMENT ME!- Specified by:
getPath
in interfaceElementPath
- Returns:
- the path as a string
-
getCurrent
Description copied from interface:ElementPath
DOCUMENT ME!- Specified by:
getCurrent
in interfaceElementPath
- Returns:
- the current element
-
addHandler
Description copied from interface:ElementPath
Adds theElementHandler
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 .- Specified by:
addHandler
in interfaceElementPath
- Parameters:
path
- is the path to be handledelementHandler
- is theElementHandler
to be called by the event based processor.
-
removeHandler
Description copied from interface:ElementPath
Removes theElementHandler
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 .- Specified by:
removeHandler
in interfaceElementPath
- Parameters:
path
- is the path to remove theElementHandler
for.
-
containsHandler
DOCUMENT ME!- Parameters:
path
- DOCUMENT ME!- Returns:
- true when an
ElementHandler
is registered for the specified path.
-
getHandlerPath
-