Class CatalogResolver
- java.lang.Object
-
- org.apache.commons.configuration2.resolver.CatalogResolver
-
- All Implemented Interfaces:
org.xml.sax.EntityResolver
public class CatalogResolver extends java.lang.Object implements org.xml.sax.EntityResolverThin wrapper around XML commons CatalogResolver to allow list of catalogs to be provided.- Since:
- 1.7
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCatalogResolver.CatalogOverrides the Catalog implementation to use the underlying FileSystem.static classCatalogResolver.CatalogManagerExtends the CatalogManager to make the FileSystem and base directory accessible.
-
Constructor Summary
Constructors Constructor Description CatalogResolver()Constructs the CatalogResolver
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigurationLoggergetLogger()Gets the logger used by this configuration object.org.xml.sax.InputSourceresolveEntity(java.lang.String publicId, java.lang.String systemId)Implements theresolveEntitymethod for the SAX interface.voidsetBaseDir(java.lang.String baseDir)Sets the base path.voidsetCatalogFiles(java.lang.String catalogs)Sets the list of catalog file namesvoidsetDebug(boolean debug)Enables debug logging of xml-commons Catalog processing.voidsetFileSystem(FileSystem fileSystem)Sets the FileSystem.voidsetInterpolator(ConfigurationInterpolator ci)Sets theConfigurationInterpolator.voidsetLogger(ConfigurationLogger log)Sets the logger to be used by this object.
-
-
-
Method Detail
-
getLogger
public ConfigurationLogger getLogger()
Gets the logger used by this configuration object.- Returns:
- the logger
-
resolveEntity
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXExceptionImplements the
resolveEntitymethod 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:
resolveEntityin interfaceorg.xml.sax.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:
org.xml.sax.SAXException- if an error occurs.
-
setBaseDir
public void setBaseDir(java.lang.String baseDir)
Sets the base path.- Parameters:
baseDir- The base path String.
-
setCatalogFiles
public void setCatalogFiles(java.lang.String catalogs)
Sets the list of catalog file names- Parameters:
catalogs- The delimited list of catalog files.
-
setDebug
public void setDebug(boolean debug)
Enables debug logging of xml-commons Catalog processing.- Parameters:
debug- True if debugging should be enabled, false otherwise.
-
setFileSystem
public void setFileSystem(FileSystem fileSystem)
Sets the FileSystem.- Parameters:
fileSystem- The FileSystem.
-
setInterpolator
public void setInterpolator(ConfigurationInterpolator ci)
Sets theConfigurationInterpolator.- Parameters:
ci- theConfigurationInterpolator
-
setLogger
public void setLogger(ConfigurationLogger log)
Sets the logger to be used by this 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. Passing in null as argument disables logging.- Parameters:
log- the new logger
-
-