## org.apache.xerces.readers
Class XMLCatalogHandler

    java.lang.Object
      |
      +--org.apache.xerces.readers.XMLCatalogHandler

Direct Known Subclasses:
  XCatalog

public abstract class XMLCatalogHandler
extends java.lang.Object
implements EntityResolver

Interface for implementing basic catalog support in the parser. To implement and use a Catalog, implement this interface and install your catalog instance as the EntityResolver in the parser's entity handler. For example:

         XMLParser parser = new AnyParser();
         parser.addCatalogHandler(new MyCatalog());

This default catalog implementation does not provide a method for loading multiple catalogs from various input sources. Instead, it is a convenient base class for other catalog implementations.

To create a catalog implementation, simply extend this class and implement the `loadCatalog` method. Public and system identifier mappings can be stored and accessed using the convenient public methods on this class.

Version:
Author:
  Andy Clark, IBM
See Also:
  `EntityResolver`

Constructor Summary
`XMLCatalogHandler()`

Method Summary
`void` `addPublicMapping(java.lang.String publicId, java.lang.String systemId)` Adds a public to system identifier mapping.
`void` `addSystemMapping(java.lang.String systemId1, java.lang.String systemId2)` Adds a system identifier alias.
`java.lang.String` `getPublicMapping(java.lang.String publicId)` Returns a public identifier mapping.
`java.util.Enumeration` `getPublicMappingKeys()` Returns an enumeration of public identifier mapping keys.
`java.lang.String` `getSystemMapping(java.lang.String systemId)` Returns a system identifier alias.
`java.util.Enumeration` `getSystemMappingKeys()` Returns an enumeration of system identifier mapping keys.
`abstract void` `loadCatalog(InputSource source)` Loads the catalog stream specified by the given input source and appends the contents to the catalog.
`void` `removePublicMapping(java.lang.System publicId)` Removes a public identifier mapping.
`void` `removeSystemMapping(java.lang.String systemId)` Removes a system identifier alias.
`InputSource` `resolveEntity(java.lang.String publicId, java.lang.String systemId)` Resolves external entities.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XMLCatalogHandler

    public XMLCatalogHandler()

Method Detail

### loadCatalog

    public abstract void loadCatalog(InputSource source)
                              throws java.lang.Exception

  Loads the catalog stream specified by the given input source and appends the contents to the catalog.
  Parameters:
    `source` - The catalog source.
  Throws:
    java.lang.Exception - Throws an exception if an error occurs while loading the catalog source.

### addPublicMapping

    public void addPublicMapping(java.lang.String publicId,
                                 java.lang.String systemId)

  Adds a public to system identifier mapping.
  Parameters:
    `publicId` - The public identifier, or "key".
    `systemId` - The system identifier, or "value".

### removePublicMapping

    public void removePublicMapping(java.lang.System publicId)

  Removes a public identifier mapping.
  Parameters:
    `publicId` - The public identifier to remove.

### getPublicMappingKeys

    public java.util.Enumeration getPublicMappingKeys()

  Returns an enumeration of public identifier mapping keys.

### getPublicMapping

    public java.lang.String getPublicMapping(java.lang.String publicId)

  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.

### addSystemMapping

    public void addSystemMapping(java.lang.String systemId1,
                                 java.lang.String systemId2)

  Adds a system identifier alias.
  Parameters:
    `publicId` - The system identifier "key".
    `systemId` - The system identifier "value".

### removeSystemMapping

    public void removeSystemMapping(java.lang.String systemId)

  Removes a system identifier alias.
  Parameters:
    `systemId` - The system identifier to remove.

### getSystemMappingKeys

    public java.util.Enumeration getSystemMappingKeys()

  Returns an enumeration of system identifier mapping keys.

### getSystemMapping

    public java.lang.String getSystemMapping(java.lang.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.

### resolveEntity

    public InputSource resolveEntity(java.lang.String publicId,
                                     java.lang.String systemId)
                              throws SAXException,
                                     java.io.IOException

  Resolves external entities.
  Specified by:
    resolveEntity in interface EntityResolver
  Parameters:
    `publicId` - The public identifier used for entity resolution.
    `systemId` - If the publicId is not null, this systemId is to be considered the default system identifier; else a system identifier alias mapping is requested.
  Returns:
    Returns the input source of the resolved entity or null if no resolution is possible.
  Throws:
    SAXException - Exception thrown on SAX error.
    java.io.IOException - Exception thrown on i/o error.

Copyright © 1999-2001 Apache XML Project. All Rights Reserved.