## org.apache.commons.configuration.resolver
Class DefaultEntityResolver

    java.lang.Object
      org.apache.commons.configuration.resolver.DefaultEntityResolver

All Implemented Interfaces:
  EntityRegistry, EntityResolver

    public class DefaultEntityResolver

extends Object
implements EntityResolver, EntityRegistry

The DefaultEntityResolver used by XML Configurations.

Since:
  1.7
Version:
  $Id: DefaultEntityResolver.java 1206579 2011-11-26 20:30:51Z oheger $
Author:
  Commons Configuration team

Constructor Summary
`DefaultEntityResolver()`

Method Summary
`Map<String,URL>` `getRegisteredEntities()` Returns a map with the entity IDs that have been registered using the `registerEntityId()` method.
`void` `registerEntityId(String publicId, URL entityURL)` Registers the specified URL for the specified public identifier.
`InputSource` `resolveEntity(String publicId, String systemId)` Resolves the requested external entity.

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

### registerEntityId

    public void registerEntityId(String publicId,
                                 URL entityURL)

  Registers the specified URL for the specified public identifier.

  This implementation maps `PUBLICID`'s to URLs (from which the resource will be loaded). A common use case for this method is to register local URLs (possibly computed at runtime by a class loader) for DTDs and Schemas. This allows the performance advantage of using a local version without having to ensure every `SYSTEM` URI on every processed XML document is local. This implementation provides only basic functionality. If more sophisticated features are required, either calling `XMLConfiguration.setDocumentBuilder(DocumentBuilder)` to set a custom `DocumentBuilder` (which also can be initialized with a custom `EntityResolver`) or creating a custom entity resolver and registering it with the XMLConfiguration is recommended.

  Specified by:
    `registerEntityId` in interface `EntityRegistry`
  Parameters:
    `publicId` - Public identifier of the Entity to be resolved
    `entityURL` - The URL to use for reading this Entity
  Throws:
    `IllegalArgumentException` - if the public ID is undefined

### resolveEntity

    public InputSource resolveEntity(String publicId,
                                     String systemId)
                              throws SAXException

  Resolves the requested external entity. This is the default implementation of the `EntityResolver` interface. It checks the passed in public ID against the registered entity IDs and uses a local URL if possible.

  Specified by:
    `resolveEntity` in interface `EntityResolver`
  Parameters:
    `publicId` - the public identifier of the entity being referenced
    `systemId` - the system identifier of the entity being referenced
  Returns:
    an input source for the specified entity
  Throws:
    `SAXException` - if a parsing exception occurs

### getRegisteredEntities

    public Map<String,URL> getRegisteredEntities()

  Returns a map with the entity IDs that have been registered using the `registerEntityId()` method.

  Specified by:
    `getRegisteredEntities` in interface `EntityRegistry`
  Returns:
    a map with the registered entity IDs

Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.