Class CatalogResolver
java.lang.Object
org.apache.commons.configuration2.resolver.CatalogResolver
- All Implemented Interfaces:
EntityResolver
Thin wrapper around xml commons CatalogResolver to allow list of catalogs to be provided.
- Since:
- 1.7
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Overrides the Catalog implementation to use the underlying FileSystem.static class
Extends the CatalogManager to make the FileSystem and base directory accessible. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
Debug everything.private static final int
Debug nothing.private static final int
Normal debug setting.private FileSystem
The FileSystem in use.private ConfigurationLogger
Stores the logger.private final CatalogResolver.CatalogManager
The CatalogManagerprivate org.apache.xml.resolver.tools.CatalogResolver
The CatalogResolver -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the logger used by this configuration object.private org.apache.xml.resolver.tools.CatalogResolver
private void
Initializes the logger.private static URL
locate
(FileSystem fs, String basePath, String name) Locates a given file.resolveEntity
(String publicId, String systemId) Implements theresolveEntity
method for the SAX interface.void
setBaseDir
(String baseDir) Sets the base path.void
setCatalogFiles
(String catalogs) Sets the list of catalog file namesvoid
setDebug
(boolean debug) Enables debug logging of xml-commons Catalog processing.void
setFileSystem
(FileSystem fileSystem) Sets the FileSystem.void
Sets theConfigurationInterpolator
.void
Allows setting the logger to be used by this object.
-
Field Details
-
DEBUG_ALL
private static final int DEBUG_ALLDebug everything.- See Also:
-
DEBUG_NORMAL
private static final int DEBUG_NORMALNormal debug setting.- See Also:
-
DEBUG_NONE
private static final int DEBUG_NONEDebug nothing.- See Also:
-
manager
The CatalogManager -
fs
The FileSystem in use. -
resolver
private org.apache.xml.resolver.tools.CatalogResolver resolverThe CatalogResolver -
log
Stores the logger.
-
-
Constructor Details
-
CatalogResolver
public CatalogResolver()Constructs the CatalogResolver
-
-
Method Details
-
setCatalogFiles
Sets the list of catalog file names- Parameters:
catalogs
- The delimited list of catalog files.
-
setFileSystem
Sets the FileSystem.- Parameters:
fileSystem
- The FileSystem.
-
setBaseDir
Sets the base path.- Parameters:
baseDir
- The base path String.
-
setInterpolator
Sets theConfigurationInterpolator
.- Parameters:
ci
- theConfigurationInterpolator
-
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
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 interfaceEntityResolver
- 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
Gets the logger used by this configuration object.- Returns:
- the logger
-
setLogger
Allows setting 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
-
initLogger
Initializes the logger. Checks for null parameters.- Parameters:
log
- the new logger
-
getResolver
private org.apache.xml.resolver.tools.CatalogResolver getResolver() -
locate
Locates a given file. This implementation delegates to the corresponding method inFileLocatorUtils
.- Parameters:
fs
- theFileSystem
basePath
- the base pathname
- the file name- Returns:
- the URL pointing to the file
-