net.sf.stax
Class DispatchOnElement.ByNsURI

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

public static final class DispatchOnElement.ByNsURI
extends DispatchOnElement

On-element dispatch that chooses handlers by namespace URI.

This class replaces

 class FooHandler
     extends StAXContentHandlerBase
 {
     public void startElement(..., StAXDelegationContext dctx)
     {
         if ("urn:net.sf.stax:bar".equals(nsURI))
         {
             dctx.delegate(barHandler);
         }
         else if ("urn:net.sf.stax:baz".equals(nsURI))
         {
             dctx.delegate.(bazHandler);
         }
     }
 }
 
with
 DispatchOnElement dispatch = new DispatchOnElement.ByNsURI();
 dispatch.setHandler("urn:net.sf.stax:bar", barHandler);
 dispatch.setHandler("urn:net.sf.stax: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.ByNsURI()
           
 
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.ByNsURI

public DispatchOnElement.ByNsURI()
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).