Package org.dom4j.io
Class DispatchHandler
- java.lang.Object
-
- org.dom4j.io.DispatchHandler
-
- All Implemented Interfaces:
ElementHandler
- Direct Known Subclasses:
PruningDispatchHandler
class DispatchHandler extends Object implements ElementHandler
DispatchHandlerimplements theElementHandlerinterface and provides a means to register multipleElementHandlerinstances to be used by an event based processor. This is a specialElementHandlerin that it's onStart and onEnd implementation methods are called for every element encountered during the parse. It then delegates to otherElementHandlerinstances registered with it to process the elements encountered.- Version:
- $Revision: 1.11 $
- Author:
- Dave White
-
-
Constructor Summary
Constructors Constructor Description DispatchHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHandler(String handlerPath, ElementHandler handler)Adds theElementHandlerto be called when the specified path is encounted.booleancontainsHandler(String handlerPath)DOCUMENT ME!intgetActiveHandlerCount()Returns the number ofElementHandlerobjects that are waiting for their elements closing tag.ElementHandlergetHandler(String handlerPath)Get the registeredElementHandlerfor the specified path.StringgetPath()DOCUMENT ME!voidonEnd(ElementPath elementPath)Called by an event based processor when an elements closing tag is encountered.voidonStart(ElementPath elementPath)Called by an event based processor when an elements openning tag is encountered.ElementHandlerremoveHandler(String handlerPath)Removes theElementHandlerfrom the event based processor, for the specified path.voidresetHandlers()Used to remove all the Element Handlers and return things back to the way they were when object was created.voidsetDefaultHandler(ElementHandler handler)When multipleElementHandlerinstances have been registered, this will set a defaultElementHandlerto be called for any path which does NOT have a handler registered.
-
-
-
Method Detail
-
addHandler
public void addHandler(String handlerPath, ElementHandler handler)
Adds theElementHandlerto be called when the specified path is encounted.- Parameters:
handlerPath- is the path to be handledhandler- is theElementHandlerto be called by the event based processor.
-
removeHandler
public ElementHandler removeHandler(String handlerPath)
Removes theElementHandlerfrom the event based processor, for the specified path.- Parameters:
handlerPath- is the path to remove theElementHandlerfor.- Returns:
- DOCUMENT ME!
-
containsHandler
public boolean containsHandler(String handlerPath)
DOCUMENT ME!- Parameters:
handlerPath- DOCUMENT ME!- Returns:
- true when an
ElementHandleris registered for the specified path.
-
getHandler
public ElementHandler getHandler(String handlerPath)
Get the registeredElementHandlerfor the specified path.- Parameters:
handlerPath- XML path to get the handler for- Returns:
- the registered handler
-
getActiveHandlerCount
public int getActiveHandlerCount()
Returns the number ofElementHandlerobjects that are waiting for their elements closing tag.- Returns:
- number of active handlers
-
setDefaultHandler
public void setDefaultHandler(ElementHandler handler)
When multipleElementHandlerinstances have been registered, this will set a defaultElementHandlerto be called for any path which does NOT have a handler registered.- Parameters:
handler- is theElementHandlerto be called by the event based processor.
-
resetHandlers
public void resetHandlers()
Used to remove all the Element Handlers and return things back to the way they were when object was created.
-
getPath
public String getPath()
DOCUMENT ME!- Returns:
- the current path for the parse
-
onStart
public void onStart(ElementPath elementPath)
Description copied from interface:ElementHandlerCalled by an event based processor when an elements openning tag is encountered.- Specified by:
onStartin interfaceElementHandler- Parameters:
elementPath- is the currentElementPathto process
-
onEnd
public void onEnd(ElementPath elementPath)
Description copied from interface:ElementHandlerCalled by an event based processor when an elements closing tag is encountered.- Specified by:
onEndin interfaceElementHandler- Parameters:
elementPath- is the currentElementPathto process
-
-