net.sf.stax
Class DispatchForChild

java.lang.Object
  extended by net.sf.stax.StAXContentHandlerBase
      extended by net.sf.stax.DispatchForChild
All Implemented Interfaces:
StAXContentHandler

public final class DispatchForChild
extends StAXContentHandlerBase

For-child dispatch. Use this class to handle multiple child elements of the same type. The list of values, returned by the endTree(StAXContext) method, is available to a parent handler via its endElement(String, String, String, String, Object, StAXContext) method.

For example, for the following (sub-)tree:

 >foo<
   >int<0>/int<
   >int<1>/int<
   >int<2>/int<
   >int<3>/int<
   >int<4>/int<
 >/foo<
 

Use

 class FooHandler
     extends StAXContentHandlerBase
 {
     private List integerValues;
     private DispatchForChild dispatch = new DispatchForChild(new IntElementHandler());

     public void startElement(..., StAXDelegationContext dctx)
     {
         dctx.delegate(dispatch);
     }

     public void endElement(..., Object result, ...)
     {
         this.integerValues = (List) result;
     }
 }
 

Version:
$Revision: 1.3 $ $Date: 2006/01/02 20:37:34 $
Author:
Thomas Down, Matthew Pocock, Michael Heuer

Field Summary
 
Fields inherited from interface net.sf.stax.StAXContentHandler
IGNORE
 
Constructor Summary
DispatchForChild(StAXContentHandler handler)
          Create a new for-child dispatch wrapping the specified handler.
 
Method Summary
 void endElement(String nsURI, String localName, String qName, Object result, 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.
 void startElement(String nsURI, String localName, String qName, Attributes attrs, StAXDelegationContext dctx)
          Receive notification of the beginning of an element.
 void startTree(StAXContext ctx)
          Receive notification of the beginning of a sub-tree of a document.
 
Methods inherited from class net.sf.stax.StAXContentHandlerBase
characters, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DispatchForChild

public DispatchForChild(StAXContentHandler handler)
Create a new for-child dispatch wrapping the specified handler.

Parameters:
handler - wrapped handler
Method Detail

startTree

public void startTree(StAXContext ctx)
Description copied from interface: StAXContentHandler
Receive notification of the beginning of a sub-tree of a document.

Specified by:
startTree in interface StAXContentHandler
Overrides:
startTree in class StAXContentHandlerBase
Parameters:
ctx - StAX context
See Also:
StAXContentHandlerBase

startElement

public 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 void endElement(String nsURI,
                       String localName,
                       String qName,
                       Object result,
                       StAXContext ctx)
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)
result - result
ctx - StAX context
See Also:
StAXContentHandlerBase

endTree

public 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


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