Package org.dom4j.io
Class ElementStack
- java.lang.Object
-
- org.dom4j.io.ElementStack
-
- All Implemented Interfaces:
ElementPath
- Direct Known Subclasses:
PruningElementStack
class ElementStack extends Object implements ElementPath
ElementStackis used internally inside theSAXContentHandlerto maintain a stack ofElementinstances. It opens an integration possibility allowing derivations to prune the tree when a node is complete.- Version:
- $Revision: 1.14 $
- Author:
- James Strachan
-
-
Field Summary
Fields Modifier and Type Field Description protected intlastElementIndexindex of the item at the top of the stack or -1 if the stack is emptyprotected Element[]stackstack ofElementobjects
-
Constructor Summary
Constructors Constructor Description ElementStack()ElementStack(int defaultCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHandler(String path, ElementHandler elementHandler)Adds theElementHandlerto be called when the specified path is encounted.voidclear()Peeks at the top element on the stack without changing the contents of the stack.booleancontainsHandler(String path)DOCUMENT ME!ElementgetCurrent()DOCUMENT ME!DispatchHandlergetDispatchHandler()ElementgetElement(int depth)DOCUMENT ME!StringgetPath()DOCUMENT ME!ElementpeekElement()Peeks at the top element on the stack without changing the contents of the stack.ElementpopElement()Pops the element off the stackvoidpushElement(Element element)Pushes a new element onto the stackprotected voidreallocate(int size)Reallocates the stack to the given sizevoidremoveHandler(String path)Removes theElementHandlerfrom the event based processor, for the specified path.voidsetDispatchHandler(DispatchHandler dispatchHandler)intsize()DOCUMENT ME!
-
-
-
Field Detail
-
stack
protected Element[] stack
stack ofElementobjects
-
lastElementIndex
protected int lastElementIndex
index of the item at the top of the stack or -1 if the stack is empty
-
-
Method Detail
-
setDispatchHandler
public void setDispatchHandler(DispatchHandler dispatchHandler)
-
getDispatchHandler
public DispatchHandler getDispatchHandler()
-
clear
public void clear()
Peeks at the top element on the stack without changing the contents of the stack.
-
peekElement
public Element peekElement()
Peeks at the top element on the stack without changing the contents of the stack.- Returns:
- the current element on the stack
-
popElement
public Element popElement()
Pops the element off the stack- Returns:
- the element that has just been popped off the stack
-
pushElement
public void pushElement(Element element)
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:ElementPathDOCUMENT ME!- Specified by:
sizein interfaceElementPath- Returns:
- the number of elements in the path
-
getElement
public Element getElement(int depth)
Description copied from interface:ElementPathDOCUMENT ME!- Specified by:
getElementin interfaceElementPath- Parameters:
depth- DOCUMENT ME!- Returns:
- the element at the specified depth index, 0 = root element
-
getPath
public String getPath()
Description copied from interface:ElementPathDOCUMENT ME!- Specified by:
getPathin interfaceElementPath- Returns:
- the path as a string
-
getCurrent
public Element getCurrent()
Description copied from interface:ElementPathDOCUMENT ME!- Specified by:
getCurrentin interfaceElementPath- Returns:
- the current element
-
addHandler
public void addHandler(String path, ElementHandler elementHandler)
Description copied from interface:ElementPathAdds theElementHandlerto 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:
addHandlerin interfaceElementPath- Parameters:
path- is the path to be handledelementHandler- is theElementHandlerto be called by the event based processor.
-
removeHandler
public void removeHandler(String path)
Description copied from interface:ElementPathRemoves theElementHandlerfrom 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:
removeHandlerin interfaceElementPath- Parameters:
path- is the path to remove theElementHandlerfor.
-
containsHandler
public boolean containsHandler(String path)
DOCUMENT ME!- Parameters:
path- DOCUMENT ME!- Returns:
- true when an
ElementHandleris registered for the specified path.
-
-