org.apache.jackrabbit.commons.xml
Class ParsingContentHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.jackrabbit.commons.xml.DefaultContentHandler
          extended by org.apache.jackrabbit.commons.xml.ParsingContentHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class ParsingContentHandler
extends DefaultContentHandler

Utility class that decorates a ContentHandler instance with simple XML parsing capability.

Since:
Jackrabbit JCR Commons 1.5

Constructor Summary
ParsingContentHandler(ContentHandler handler)
          Creates a DefaultHandler adapter for the given content handler.
 
Method Summary
 void parse(InputStream in)
          Utility method that parses the given input stream using this handler.
 InputSource resolveEntity(String publicId, String systemId)
          Returns an empty stream to prevent the XML parser from attempting to resolve external entity references.
 
Methods inherited from class org.apache.jackrabbit.commons.xml.DefaultContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, notationDecl, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParsingContentHandler

public ParsingContentHandler(ContentHandler handler)
Creates a DefaultHandler adapter for the given content handler.

Parameters:
handler - content handler
Method Detail

parse

public void parse(InputStream in)
           throws IOException,
                  SAXException
Utility method that parses the given input stream using this handler. The parser is namespace-aware and will not resolve external entity references.

Parameters:
in - XML input stream
Throws:
IOException - if an I/O error occurs
SAXException - if an XML parsing error occurs

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
                          throws SAXException
Returns an empty stream to prevent the XML parser from attempting to resolve external entity references.

Specified by:
resolveEntity in interface EntityResolver
Overrides:
resolveEntity in class DefaultHandler
Throws:
SAXException


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