org.enhydra.xml.io
Class XMLEntityResolver

java.lang.Object
  |
  +--org.enhydra.xml.io.XMLEntityResolver
All Implemented Interfaces:
EntityResolver

public class XMLEntityResolver
extends Object
implements EntityResolver

A flexable entity resolver for use with parsing XML files. This implements:

A list of class loaders maybe associated with this object. If so an attempt will be made to resolve file: URLs from the class path.

See Also:
org.enhydra.apache.xerces.readers.XCatalog

Field Summary
static String CLASSPATH_PROTOCOL
          Protocol to use in specifying a URL pointing to the CLASSPATH or a file on the file system.
static String CLASSPATH_PROTOCOL_PREFIX
          Protocol prefix.
static String DEFAULT_ENTITY_CATALOG
          URL for Enhydra default entity catalog.
static String LUTRIS_ENTITY_CATALOG
          URL for Lutrus Enhydra default entity catalog.
 
Constructor Summary
XMLEntityResolver()
           
 
Method Summary
 void addClassLoader(ClassLoader classLoader)
          Add a classloader to the end of the order list of classloaders to search for entities.
 Enumeration getClassLoaders()
          Get an enumeration of the class loaders.
 PrintWriter getDebugWriter()
          Get the debug writer.
 String getPublicMapping(String publicId, String systemId)
          Returns a public identifier mapping.
 String getSystemMapping(String systemId)
          Returns a system identifier alias.
 void loadCatalog(InputSource source)
          Loads a catalog specified by the given input source and appends the contents to the catalog object.
 InputSource resolveEntity(String publicId, String systemId)
           
 void setDebugWriter(PrintWriter writer)
          Set a writer used to output debug messages.
 void setDefaultResolving()
          Load the default entity catalog and enable loading entities from the classloader for the classloader that loaded this class.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASSPATH_PROTOCOL

public static final String CLASSPATH_PROTOCOL
Protocol to use in specifying a URL pointing to the CLASSPATH or a file on the file system.

CLASSPATH_PROTOCOL_PREFIX

public static final String CLASSPATH_PROTOCOL_PREFIX
Protocol prefix. In the case of loading from the classpath, this protocol prefix and any leading slash is stripped to provide a path expected by classloader.getResourceAsStream(String).

DEFAULT_ENTITY_CATALOG

public static final String DEFAULT_ENTITY_CATALOG
URL for Enhydra default entity catalog.
See Also:
setDefaultResolving()

LUTRIS_ENTITY_CATALOG

public static final String LUTRIS_ENTITY_CATALOG
URL for Lutrus Enhydra default entity catalog. Only loaded if available.
See Also:
setDefaultResolving()
Constructor Detail

XMLEntityResolver

public XMLEntityResolver()
Method Detail

setDebugWriter

public void setDebugWriter(PrintWriter writer)
Set a writer used to output debug messages.

getDebugWriter

public PrintWriter getDebugWriter()
Get the debug writer.

loadCatalog

public void loadCatalog(InputSource source)
                 throws SAXException,
                        IOException
Loads a catalog specified by the given input source and appends the contents to the catalog object.
Parameters:
source - The catalog source.
Throws:
SAXException - Throws exception on SAX error.
IOException - Throws exception on i/o error.

setDefaultResolving

public void setDefaultResolving()
                         throws SAXException,
                                IOException
Load the default entity catalog and enable loading entities from the classloader for the classloader that loaded this class.

getPublicMapping

public String getPublicMapping(String publicId,
                               String systemId)
Returns a public identifier mapping.
Parameters:
publicId - The public identifier, or "key".
Returns:
Returns the system identifier value or null if there is no mapping defined.

getSystemMapping

public String getSystemMapping(String systemId)
Returns a system identifier alias.
Parameters:
systemId - The system identifier "key".
Returns:
Returns the system identifier alias value or null if there is no alias defined.

addClassLoader

public void addClassLoader(ClassLoader classLoader)
Add a classloader to the end of the order list of classloaders to search for entities. Attempts to set a null classloader value are ignored.

getClassLoaders

public Enumeration getClassLoaders()
Get an enumeration of the class loaders.

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
                          throws SAXException,
                                 IOException
Specified by:
resolveEntity in interface EntityResolver
See Also:
EntityResolver


Copyright © 1999-2002 enhydra.org (Mark Diekhans, David Li, Richard Kunze). All Rights reserved.