net.sf.stax
Class DispatchOnElement.ByQName

java.lang.Object
  extended by net.sf.stax.StAXContentHandlerBase
      extended by net.sf.stax.DispatchOnElement
          extended by net.sf.stax.DispatchOnElement.ByQName
All Implemented Interfaces:
StAXContentHandler
Enclosing class:
DispatchOnElement

public static final class DispatchOnElement.ByQName
extends DispatchOnElement

On-element dispatch that chooses handlers by qualified XML name.

This class replaces

 class FooHandler
     extends StAXContentHandlerBase
 {
     public void startElement(..., StAXDelegationContext dctx)
     {
         if ("bar".equals(qName))
         {
             dctx.delegate(barHandler);
         }
         else if ("baz".equals(qName))
         {
             dctx.delegate.(bazHandler);
         }
     }
 }
 
with
 DispatchOnElement dispatch = new DispatchOnElement.ByQName();
 dispatch.setHandler("bar", barHandler);
 dispatch.setHandler("baz", bazHandler);
 


Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.stax.DispatchOnElement
DispatchOnElement.ByLocalName, DispatchOnElement.ByNsURI, DispatchOnElement.ByQName
 
Field Summary
 
Fields inherited from interface net.sf.stax.StAXContentHandler
IGNORE
 
Constructor Summary
DispatchOnElement.ByQName()
           
 
Method Summary
protected  StAXContentHandler chooseHandler(String nsURI, String localName, String qName)
          Choose a handler for the specified namespace URI, local name, and qualified XML name.
 
Methods inherited from class net.sf.stax.DispatchOnElement
endElement, endTree, getDefaultHandler, getHandler, setDefaultHandler, setHandler, startElement
 
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.ByQName

public DispatchOnElement.ByQName()
Method Detail

chooseHandler

protected StAXContentHandler chooseHandler(String nsURI,
                                           String localName,
                                           String qName)
                                    throws SAXException
Description copied from class: DispatchOnElement
Choose a handler for the specified namespace URI, local name, and qualified XML name.

Specified by:
chooseHandler in class DispatchOnElement
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
See Also:
DispatchOnElement


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