org.apache.jackrabbit.commons.xml
Class ProxyContentHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.jackrabbit.commons.xml.ProxyContentHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
Direct Known Subclasses:
XmlnsContentHandler

public class ProxyContentHandler
extends DefaultHandler

A proxy content handler that passes all SAX events as-is to the proxied handler.

As a convenience this class inherits the DefaultHandler class instead of just the ContentHandler interface. This makes it possible to use this class as an adapter when using methods like SAXParser.parse(String, DefaultHandler) that expect a DefaultHandler instance instead of a ContentHandler.


Field Summary
protected  ContentHandler handler
          The proxied content handler.
 
Constructor Summary
ProxyContentHandler(ContentHandler handler)
          Creates a proxy for the given content handler.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Delegated to handler.
 void endDocument()
          Delegated to handler.
 void endElement(String namespaceURI, String localName, String qName)
          Delegated to handler.
 void endPrefixMapping(String prefix)
          Delegated to handler.
 void ignorableWhitespace(char[] ch, int start, int length)
          Delegated to handler.
 void processingInstruction(String target, String data)
          Delegated to handler.
 void setDocumentLocator(Locator locator)
          Delegated to handler.
 void skippedEntity(String name)
          Delegated to handler.
 void startDocument()
          Delegated to handler.
 void startElement(String namespaceURI, String localName, String qName, Attributes atts)
          Delegated to handler.
 void startPrefixMapping(String prefix, String uri)
          Delegated to handler.
 String toString()
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, notationDecl, resolveEntity, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

handler

protected ContentHandler handler
The proxied content handler. This is a protected, non-final field so that subclasses can access the proxied handler or even replace it they want.

Constructor Detail

ProxyContentHandler

public ProxyContentHandler(ContentHandler handler)
Creates a proxy for the given content handler.

Parameters:
handler - content handler to be proxied
Method Detail

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Delegated to handler.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Parameters:
ch - passed through
start - passed through
length - passed through
Throws:
SAXException - if an error occurs

endDocument

public void endDocument()
                 throws SAXException
Delegated to handler.

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class DefaultHandler
Throws:
SAXException - if an error occurs

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException
Delegated to handler.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Parameters:
namespaceURI - passed through
localName - passed through
qName - passed through
Throws:
SAXException - if an error occurs

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Delegated to handler.

Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in class DefaultHandler
Parameters:
prefix - passed through
Throws:
SAXException - if an error occurs

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Delegated to handler.

Specified by:
ignorableWhitespace in interface ContentHandler
Overrides:
ignorableWhitespace in class DefaultHandler
Parameters:
ch - passed through
start - passed through
length - passed through
Throws:
SAXException - if an error occurs

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Delegated to handler.

Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class DefaultHandler
Parameters:
target - passed through
data - passed through
Throws:
SAXException - if an error occurs

setDocumentLocator

public void setDocumentLocator(Locator locator)
Delegated to handler.

Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in class DefaultHandler
Parameters:
locator - passed through

skippedEntity

public void skippedEntity(String name)
                   throws SAXException
Delegated to handler.

Specified by:
skippedEntity in interface ContentHandler
Overrides:
skippedEntity in class DefaultHandler
Parameters:
name - passed through
Throws:
SAXException - if an error occurs

startDocument

public void startDocument()
                   throws SAXException
Delegated to handler.

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class DefaultHandler
Throws:
SAXException - if an error occurs

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Delegated to handler.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Parameters:
namespaceURI - passed through
localName - passed through
qName - passed through
atts - passed through
Throws:
SAXException - if an error occurs

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Delegated to handler.

Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class DefaultHandler
Parameters:
prefix - passed through
uri - passed through
Throws:
SAXException - if an error occurs

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.