net.sf.webmancer.util.xml.sax
Class DelegateContentHandler

java.lang.Object
  extended by net.sf.webmancer.util.xml.sax.DelegateContentHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler
Direct Known Subclasses:
ForkingHandler

public class DelegateContentHandler
extends java.lang.Object
implements org.xml.sax.ContentHandler

This is the ContentHandler implementation that simply delegates all SAX parsing events to the target ContentHandler that may be set at any time by the setTargetContentHandler(ContentHandler) method. If the target ContentHandler is set to null, the content handler simply does nothing.

Author:
Michal Burda

Constructor Summary
DelegateContentHandler()
          Convenient constructor that creates new delegate content handler with target content handler set to null.
DelegateContentHandler(org.xml.sax.ContentHandler handler)
          Create new delegate content handler.
 
Method Summary
 void endDocument()
          Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.
 void endPrefixMapping(java.lang.String prefix)
          Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.
 org.xml.sax.ContentHandler getTargetContentHandler()
          Get the actually used target content handler.
 void characters(char[] ch, int start, int length)
          Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.
 void ignorableWhitespace(char[] ch, int start, int length)
          Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.
 void setDocumentLocator(org.xml.sax.Locator locator)
          Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.
 void setTargetContentHandler(org.xml.sax.ContentHandler handler)
          Set the target content handler.
 void skippedEntity(java.lang.String name)
          Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.
 void startDocument()
          Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegateContentHandler

public DelegateContentHandler(org.xml.sax.ContentHandler handler)
Create new delegate content handler.

Parameters:
handler - The possibly null target content handler

DelegateContentHandler

public DelegateContentHandler()
Convenient constructor that creates new delegate content handler with target content handler set to null.

Method Detail

setTargetContentHandler

public void setTargetContentHandler(org.xml.sax.ContentHandler handler)
Set the target content handler. The method could be called at any time to enable complex behaviour. If the target ContentHandler is set to null, the content handler would simply do nothing.

Parameters:
handler - The target content handler

getTargetContentHandler

public org.xml.sax.ContentHandler getTargetContentHandler()
Get the actually used target content handler.

Returns:
The actually used target content handler

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
setTargetContentHandler(ContentHandler), ContentHandler.startDocument()

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
setTargetContentHandler(ContentHandler), ContentHandler.endDocument()

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.

Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
See Also:
setTargetContentHandler(ContentHandler), ContentHandler.setDocumentLocator(org.xml.sax.Locator)

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
setTargetContentHandler(ContentHandler), ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.

Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
setTargetContentHandler(ContentHandler), ContentHandler.endPrefixMapping(java.lang.String)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.

Specified by:
characters in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
setTargetContentHandler(ContentHandler), ContentHandler.characters(char[], int, int)

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
setTargetContentHandler(ContentHandler), ContentHandler.ignorableWhitespace(char[], int, int)

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
setTargetContentHandler(ContentHandler), ContentHandler.processingInstruction(java.lang.String, java.lang.String)

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.

Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
setTargetContentHandler(ContentHandler), ContentHandler.skippedEntity(java.lang.String)

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
setTargetContentHandler(ContentHandler), ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Delegates the SAX event to the target content handler or simply does nothing, if the target content handler is null.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
setTargetContentHandler(ContentHandler), ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)


Copyright © 2006-2007. All Rights Reserved.