org.apache.commons.configuration.resolver
Class CatalogResolver

java.lang.Object
  extended by org.apache.commons.configuration.resolver.CatalogResolver
All Implemented Interfaces:
EntityResolver

public class CatalogResolver
extends Object
implements EntityResolver

Thin wrapper around xml commons CatalogResolver to allow list of catalogs to be provided.

Since:
1.7
Version:
$Id: CatalogResolver.java 1206764 2011-11-27 16:45:39Z oheger $
Author:
Commons Configuration team

Nested Class Summary
static class CatalogResolver.Catalog
          Overrides the Catalog implementation to use the underlying FileSystem.
static class CatalogResolver.CatalogManager
          Extend the CatalogManager to make the FileSystem and base directory accessible.
 
Field Summary
protected  FileSystem fs
          The FileSystem in use.
protected  CatalogResolver.CatalogManager manager
          The CatalogManager
 
Constructor Summary
CatalogResolver()
          Constructs the CatalogResolver
 
Method Summary
 org.apache.commons.logging.Log getLogger()
          Returns the logger used by this configuration object.
 InputSource resolveEntity(String publicId, String systemId)
          Implements the resolveEntity method for the SAX interface.
 void setBaseDir(String baseDir)
          Set the base path.
 void setCatalogFiles(String catalogs)
          Set the list of catalog file names
 void setDebug(boolean debug)
          Enables debug logging of xml-commons Catalog processing.
 void setFileSystem(FileSystem fileSystem)
          Set the FileSystem.
 void setLogger(org.apache.commons.logging.Log log)
          Allows to set the logger to be used by this configuration object.
 void setSubstitutor(org.apache.commons.lang.text.StrSubstitutor substitutor)
          Set the StrSubstitutor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

manager

protected CatalogResolver.CatalogManager manager
The CatalogManager


fs

protected FileSystem fs
The FileSystem in use.

Constructor Detail

CatalogResolver

public CatalogResolver()
Constructs the CatalogResolver

Method Detail

setCatalogFiles

public void setCatalogFiles(String catalogs)
Set the list of catalog file names

Parameters:
catalogs - The delimited list of catalog files.

setFileSystem

public void setFileSystem(FileSystem fileSystem)
Set the FileSystem.

Parameters:
fileSystem - The FileSystem.

setBaseDir

public void setBaseDir(String baseDir)
Set the base path.

Parameters:
baseDir - The base path String.

setSubstitutor

public void setSubstitutor(org.apache.commons.lang.text.StrSubstitutor substitutor)
Set the StrSubstitutor.

Parameters:
substitutor - The StrSubstitutor.

setDebug

public void setDebug(boolean debug)
Enables debug logging of xml-commons Catalog processing.

Parameters:
debug - True if debugging should be enabled, false otherwise.

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
                          throws SAXException
Implements the resolveEntity method for the SAX interface.

Presented with an optional public identifier and a system identifier, this function attempts to locate a mapping in the catalogs.

If such a mapping is found, the resolver attempts to open the mapped value as an InputSource and return it. Exceptions are ignored and null is returned if the mapped value cannot be opened as an input source.

If no mapping is found (or an error occurs attempting to open the mapped value as an input source), null is returned and the system will use the specified system identifier as if no entityResolver was specified.

Specified by:
resolveEntity in interface EntityResolver
Parameters:
publicId - The public identifier for the entity in question. This may be null.
systemId - The system identifier for the entity in question. XML requires a system identifier on all external entities, so this value is always specified.
Returns:
An InputSource for the mapped identifier, or null.
Throws:
SAXException - if an error occurs.

getLogger

public org.apache.commons.logging.Log getLogger()
Returns the logger used by this configuration object.

Returns:
the logger

setLogger

public void setLogger(org.apache.commons.logging.Log log)
Allows to set the logger to be used by this configuration object. This method makes it possible for clients to exactly control logging behavior. Per default a logger is set that will ignore all log messages. Derived classes that want to enable logging should call this method during their initialization with the logger to be used.

Parameters:
log - the new logger


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