net.sf.stax
Class DispatchOnElement

java.lang.Object
  extended by net.sf.stax.StAXContentHandlerBase
      extended by net.sf.stax.DispatchOnElement
All Implemented Interfaces:
StAXContentHandler
Direct Known Subclasses:
DispatchOnElement.ByLocalName, DispatchOnElement.ByNsURI, DispatchOnElement.ByQName

public abstract class DispatchOnElement
extends StAXContentHandlerBase

On-element dispatch.

Select from one of the concrete subclasses ByNsURI, ByLocalName, or ByQName.

Version:
$Revision: 1.2 $ $Date: 2006/01/02 20:37:34 $
Author:
Thomas Down, Matthew Pocock, Michael Heuer
See Also:
DispatchOnElement.ByNsURI, DispatchOnElement.ByLocalName, DispatchOnElement.ByQName

Nested Class Summary
static class DispatchOnElement.ByLocalName
          On-element dispatch that chooses handlers by local name.
static class DispatchOnElement.ByNsURI
          On-element dispatch that chooses handlers by namespace URI.
static class DispatchOnElement.ByQName
          On-element dispatch that chooses handlers by qualified XML name.
 
Field Summary
 
Fields inherited from interface net.sf.stax.StAXContentHandler
IGNORE
 
Constructor Summary
protected DispatchOnElement()
          Create a new on-element dispatch.
 
Method Summary
protected abstract  StAXContentHandler chooseHandler(String nsURI, String localName, String qName)
          Choose a handler for the specified namespace URI, local name, and qualified XML name.
 void endElement(String nsURI, String localName, String qName, Object retVal, StAXContext ctx)
          Receive notification of the end of an element.
 Object endTree(StAXContext ctx)
          Receive notification of the end of a sub-tree of a document.
 StAXContentHandler getDefaultHandler()
          Return the default handler for this on-element dispatch.
 StAXContentHandler getHandler(String name)
          Return the handler associated with the specified name.
 void setDefaultHandler(StAXContentHandler handler)
          Set the default handler for this on-element dispatch to handler.
 void setHandler(String name, StAXContentHandler handler)
          Add the specified named handler.
 void startElement(String nsURI, String localName, String qName, Attributes attrs, StAXDelegationContext dctx)
          Receive notification of the beginning of an element.
 
Methods inherited from class net.sf.stax.StAXContentHandlerBase
characters, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping, startTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DispatchOnElement

protected DispatchOnElement()
Create a new on-element dispatch.

Method Detail

chooseHandler

protected abstract StAXContentHandler chooseHandler(String nsURI,
                                                    String localName,
                                                    String qName)
                                             throws SAXException
Choose a handler for the specified namespace URI, local name, and qualified XML name.

Parameters:
nsURI - namespace URI
localName - local name (without prefix)
qName - qualified XML name (with prefix)
Returns:
a handler for the specified namespare URI, local name, and qualified XML name
Throws:
SAXException - any SAX exception, possibly wrapping another exception

startElement

public final void startElement(String nsURI,
                               String localName,
                               String qName,
                               Attributes attrs,
                               StAXDelegationContext dctx)
                        throws SAXException
Description copied from interface: StAXContentHandler
Receive notification of the beginning of an element.

Specified by:
startElement in interface StAXContentHandler
Overrides:
startElement in class StAXContentHandlerBase
Parameters:
nsURI - namespace URI
localName - local name (without prefix)
qName - qualified XML name (with prefix)
attrs - attributes attached to the element
dctx - StAX delegation context
Throws:
SAXException - any SAX exception, possibly wrapping another exception
See Also:
StAXContentHandlerBase

endElement

public final void endElement(String nsURI,
                             String localName,
                             String qName,
                             Object retVal,
                             StAXContext ctx)
                      throws SAXException
Description copied from interface: StAXContentHandler
Receive notification of the end of an element.

Specified by:
endElement in interface StAXContentHandler
Overrides:
endElement in class StAXContentHandlerBase
Parameters:
nsURI - namespace URI
localName - local name (without prefix)
qName - qualified XML name (with prefix)
retVal - result
ctx - StAX context
Throws:
SAXException - any SAX exception, possibly wrapping another exception
See Also:
StAXContentHandlerBase

endTree

public final Object endTree(StAXContext ctx)
Description copied from interface: StAXContentHandler
Receive notification of the end of a sub-tree of a document.

Specified by:
endTree in interface StAXContentHandler
Overrides:
endTree in class StAXContentHandlerBase
Parameters:
ctx - StAX context
Returns:
return value
See Also:
StAXContentHandlerBase

setHandler

public final void setHandler(String name,
                             StAXContentHandler handler)
Add the specified named handler.

Parameters:
name - name
handler - handler

setDefaultHandler

public final void setDefaultHandler(StAXContentHandler handler)
Set the default handler for this on-element dispatch to handler.

Parameters:
handler - default handler

getDefaultHandler

public final StAXContentHandler getDefaultHandler()
Return the default handler for this on-element dispatch.

Returns:
the default handler for this on-element dispatch

getHandler

public final StAXContentHandler getHandler(String name)
Return the handler associated with the specified name.

Parameters:
name - name
Returns:
the handler associated with the specified name


Copyright (c) 2001-2006 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).