net.xineo.xml.handler
Class ObjectHandlerAdapter

java.lang.Object
  |
  +--net.xineo.xml.handler.ObjectHandler
        |
        +--net.xineo.xml.handler.ObjectHandlerAdapter
All Implemented Interfaces:
ObjectHandlerInterface
Direct Known Subclasses:
VirtualHandler

public class ObjectHandlerAdapter
extends ObjectHandler

Provides a default implementation of ObjectHandler. Two possible uses of this convenience class are availables:

Version:
1.0
Author:
Fr�d�rik Bilhaut

Constructor Summary
ObjectHandlerAdapter(ElementName handledElementName)
          Creates an object handler adapter which will handle an element given by its name.
ObjectHandlerAdapter(ObjectHandlerInterface delegate)
          Creates an object handler adapter that will delegate all events to the given handler.
ObjectHandlerAdapter(java.lang.String elementQName)
          Creates an object handler adapter which will handle an element given by its name.
ObjectHandlerAdapter(java.lang.String namespaceURI, java.lang.String localName)
          Creates an object handler adapter which will handle an element given by its name.
 
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.
 ObjectHandlerInterface getDelegate()
           
 ElementName getHandledElement()
          Returns the handled element name.
 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.
protected  void setDelegate(ObjectHandlerInterface delegate)
           
 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

ObjectHandlerAdapter

public ObjectHandlerAdapter(java.lang.String elementQName)
Creates an object handler adapter which will handle an element given by its name.

Parameters:
elementQName - Qualified name of the handled element

ObjectHandlerAdapter

public ObjectHandlerAdapter(java.lang.String namespaceURI,
                            java.lang.String localName)
Creates an object handler adapter which will handle an element given by its name.

Parameters:
namespaceURI - Namespace URI of the handled element
localName - Local name of the handled element

ObjectHandlerAdapter

public ObjectHandlerAdapter(ElementName handledElementName)
Creates an object handler adapter which will handle an element given by its name.

Parameters:
handledElementName - Name of the handled element

ObjectHandlerAdapter

public ObjectHandlerAdapter(ObjectHandlerInterface delegate)
Creates an object handler adapter that will delegate all events to the given handler.

Parameters:
delegate - The delegate object handler
Method Detail

getHandledElement

public ElementName getHandledElement()
Returns the handled element name. Returns null if the adapter is used with a delegate.

Returns:
The handled element name

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

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

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

getDelegate

public ObjectHandlerInterface getDelegate()

setDelegate

protected void setDelegate(ObjectHandlerInterface delegate)


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