org.foray.demo.embed.tools
Class EasyContentHandlerProxy

java.lang.Object
  extended by org.foray.demo.embed.tools.EasyContentHandlerProxy
All Implemented Interfaces:
ContentHandler

public class EasyContentHandlerProxy
extends Object
implements ContentHandler

This class is an implementation of ContentHandler which acts as a proxy to another ContentHandler and has the purpose to provide a few handy methods that make life easier when generating SAX events.
Note: This class is only useful for simple cases with no namespaces.


Field Summary
static Attributes EMPTY_ATTS
          An empty Attributes object used when no attributes are needed.
 
Constructor Summary
EasyContentHandlerProxy(ContentHandler forwardTo)
          Main constructor.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void characters(String s)
          Send a String of character data.
 void element(String name, String value)
          Sends notifications for a whole element with some String content.
 void element(String name, String value, Attributes atts)
          Sends notifications for a whole element with some String content.
 void endDocument()
           
 void endElement(String name)
          Send the notification of the end of an element.
 void endElement(String namespaceURI, String localName, String qName)
           
 void endPrefixMapping(String prefix)
           
 void ignorableWhitespace(char[] ch, int start, int length)
           
 void processingInstruction(String target, String data)
           
 void setDocumentLocator(Locator locator)
           
 void skippedEntity(String name)
           
 void startDocument()
           
 void startElement(String name)
          Sends the notification of the beginning of an element.
 void startElement(String name, Attributes atts)
          Sends the notification of the beginning of an element.
 void startElement(String namespaceURI, String localName, String qName, Attributes atts)
           
 void startPrefixMapping(String prefix, String uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ATTS

public static final Attributes EMPTY_ATTS
An empty Attributes object used when no attributes are needed.

Constructor Detail

EasyContentHandlerProxy

public EasyContentHandlerProxy(ContentHandler forwardTo)
Main constructor.

Parameters:
forwardTo - ContentHandler to forward the SAX event to.
Method Detail

startElement

public void startElement(String name)
                  throws SAXException
Sends the notification of the beginning of an element.

Parameters:
name - Name for the element.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

startElement

public void startElement(String name,
                         Attributes atts)
                  throws SAXException
Sends the notification of the beginning of an element.

Parameters:
name - Name for the element.
atts - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

characters

public void characters(String s)
                throws SAXException
Send a String of character data.

Parameters:
s - The content String
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

endElement

public void endElement(String name)
                throws SAXException
Send the notification of the end of an element.

Parameters:
name - Name for the element.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

element

public void element(String name,
                    String value)
             throws SAXException
Sends notifications for a whole element with some String content.

Parameters:
name - Name for the element.
value - Content of the element.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

element

public void element(String name,
                    String value,
                    Attributes atts)
             throws SAXException
Sends notifications for a whole element with some String content.

Parameters:
name - Name for the element.
value - Content of the element.
atts - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Throws:
SAXException

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Specified by:
ignorableWhitespace in interface ContentHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

skippedEntity

public void skippedEntity(String name)
                   throws SAXException
Specified by:
skippedEntity in interface ContentHandler
Throws:
SAXException


Copyright © 2017. All rights reserved.