org.jaffa.util
Class DefaultEntityResolver

java.lang.Object
  extended byorg.jaffa.util.DefaultEntityResolver
All Implemented Interfaces:
EntityResolver

public class DefaultEntityResolver
extends Object
implements EntityResolver

This is an implementation of the EntityResolver interface. It maintains a map of PublicId/DtdUrlString pairs, which are loaded from the org/jaffa/config/dtd.properties file. An instance of this class should be passed to the XML parser, before parsing an XML file. This will ensure that the parser reads the DTD file off the local machine (if specifed by the publicId) or uses the systemId to locate the DTD on an external resource.

Author:
GautamJ

Constructor Summary
DefaultEntityResolver()
           
 
Method Summary
 InputSource resolveEntity(String publicId, String systemId)
          This method will be invoked by an XML parser, when it tries to locate the DTD for validating the XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultEntityResolver

public DefaultEntityResolver()
Method Detail

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
                          throws SAXException,
                                 IOException
This method will be invoked by an XML parser, when it tries to locate the DTD for validating the XML. If the publicId is passed and the internal Map of PublicId/DtdUrlString pairs contains an entry for it, then an InputStream object will be created for the corresponding DTD. This is useful for cases where the DTD is located locally on the web-server, and hence doesn't need to access any external resource for locating DTDs. A null will be returned, in case there is no entry for the publicId in the internal Map. In such a case, the parser will locate the DTD as specified by the systemId.

Specified by:
resolveEntity in interface EntityResolver
Parameters:
publicId - The public identifier of the external entity being referenced, or null if none was supplied.
systemId - The system identifier of the external entity being referenced.
Returns:
An InputSource object describing the new input source, or null to request that the parser open a regular URI connection to the system identifier.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
IOException - A Java-specific IO exception, possibly the result of creating a new InputStream or Reader for the InputSource.


Copyright © 2002-2004 JAFFA Project.