net.xineo.xml.handler
Class RootHandler

java.lang.Object
  |
  +--net.xineo.xml.handler.ObjectHandler
        |
        +--net.xineo.xml.handler.RootHandler
All Implemented Interfaces:
ObjectHandlerInterface

public final class RootHandler
extends ObjectHandler

Convenience class defining a root handler (which can be seen as the handler that handles the document itself). Any object handler system should include a root handler, and this class can be used to easily create one, just passing the main element handler as a pareter to the constructor.

Version:
1.0
Author:
Fr�d�rik Bilhaut
See Also:
ObjectHandler, Parser

Constructor Summary
RootHandler(ObjectHandler mainHandler)
          Creates a new root handler given the main object handler (the handler that will handle the main element of the XML document).
RootHandler(ObjectHandler mainHandler, java.lang.Object userContext)
          Creates a new root handler given the main object handler (the handler that will handle the main element of the XML document), and the user context that will be passes along object handlers during the document parsing.
 
Method Summary
 void endElement(ElementName elementName, java.lang.String characters)
          This method is called when an element which is not handled by a sub-handler ends.
 boolean handlesElement(ElementName elementName)
          Must return true if and only if this handler is able to handle elements designed by the given name.
 void initialize(org.xml.sax.Attributes attributes)
          Called when a handled element starts.
 void startElement(ElementName elementName, org.xml.sax.Attributes attributes)
          This method is called when an element which is not handled by a sub-handler starts.
 void subHandlerInitialized(ObjectHandler subHandler)
          Called when a sub-handler is about to be initialized
 void subHandlerTerminated(ObjectHandler subHandler)
          Called when a sub-handler is about to be terminated
 void terminate(java.lang.String text)
          Called when a handled element ends.
 void text(java.lang.String text)
          Called when text is found (a la SAX).
 
Methods inherited from class net.xineo.xml.handler.ObjectHandler
addSubHandler, findHandlerByElementName, getAsContentHandler, getContext, getName, getParents, getUserContext, setUserContext, toString, transmitContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RootHandler

public RootHandler(ObjectHandler mainHandler)
Creates a new root handler given the main object handler (the handler that will handle the main element of the XML document).

Parameters:
mainHandler - The main object handler

RootHandler

public RootHandler(ObjectHandler mainHandler,
                   java.lang.Object userContext)
Creates a new root handler given the main object handler (the handler that will handle the main element of the XML document), and the user context that will be passes along object handlers during the document parsing.

Parameters:
mainHandler - Tha main object handler
userContext - The user context
Method Detail

handlesElement

public boolean handlesElement(ElementName elementName)
Description copied from interface: ObjectHandlerInterface
Must return true if and only if this handler is able to handle elements designed by the given name.

Parameters:
elementName - The name of the element to handle.
Returns:
True if this handler can handle it

startElement

public void startElement(ElementName elementName,
                         org.xml.sax.Attributes attributes)
                  throws HandlerException
Description copied from interface: ObjectHandlerInterface
This method is called when an element which is not handled by a sub-handler starts.

Parameters:
elementName - The name of the element that starts
attributes - The attributes of the element that starts
Throws:
HandlerException - If any error occurs

endElement

public void endElement(ElementName elementName,
                       java.lang.String characters)
                throws HandlerException
Description copied from interface: ObjectHandlerInterface
This method is called when an element which is not handled by a sub-handler ends.

Parameters:
elementName - The name of the element that ends
characters - Concatenation of all text contained in this element
Throws:
HandlerException - If any error occurs

initialize

public void initialize(org.xml.sax.Attributes attributes)
                throws HandlerException
Description copied from interface: ObjectHandlerInterface
Called when a handled element starts.

Parameters:
attributes - The attributes of the element that starts
Throws:
HandlerException - If any error occurs

terminate

public void terminate(java.lang.String text)
               throws HandlerException
Description copied from interface: ObjectHandlerInterface
Called when a handled element ends.

Parameters:
text - Concatenation of all text contained in this element
Throws:
HandlerException - If any error occurs

subHandlerInitialized

public void subHandlerInitialized(ObjectHandler subHandler)
                           throws HandlerException
Description copied from interface: ObjectHandlerInterface
Called when a sub-handler is about to be initialized

Parameters:
subHandler - The initialized sub-handler
Throws:
HandlerException - In any error occurs

subHandlerTerminated

public void subHandlerTerminated(ObjectHandler subHandler)
                          throws HandlerException
Description copied from interface: ObjectHandlerInterface
Called when a sub-handler is about to be terminated

Parameters:
subHandler - The terminated sub-handler
Throws:
HandlerException - If any error occurs

text

public void text(java.lang.String text)
          throws HandlerException
Description copied from interface: ObjectHandlerInterface
Called when text is found (a la SAX). Note that the concatenation of all text contained in elements is also passed to the terminate() method.

HandlerException


Copyright © 2002 Frédérik Bilhaut - Xineo.NET