Class XMLResolverConfiguration
- java.lang.Object
-
- org.xmlresolver.XMLResolverConfiguration
-
- All Implemented Interfaces:
ResolverConfiguration
public class XMLResolverConfiguration extends java.lang.Object implements ResolverConfiguration
Configures an XML resolver.Many aspects of catalog processing can be configured. This class examines both system properties and the properties specified in a separate properties file. The initial list of catalog files can be provided as a property or directly when the configuration is created.
The following table lays out the features recognized by this class and the system properties and configuration file properties that can be used to specify them.
Resolver features and properties that set them Feature System property File property Type ResolverFeature.ACCESS_EXTERNAL_DOCUMENTxml.catalog.accessExternalDocument access-external-document String ResolverFeature.ACCESS_EXTERNAL_ENTITYxml.catalog.accessExternalEntity access-external-entity String ResolverFeature.ALLOW_CATALOG_PIxml.catalog.allowPI allow-oasis-xml-catalog-pi Boolean¹ ResolverFeature.ALWAYS_RESOLVExml.catalog.alwaysResolve always-resolve Boolean¹ ResolverFeature.ARCHIVED_CATALOGSxml.catalog.archivedCatalogs archived-catalogs Boolean¹ ResolverFeature.CACHE_DIRECTORYxml.catalog.cache cache String ResolverFeature.CACHE_UNDER_HOMExml.catalog.cacheUnderHome cache-under-home Boolean¹ ResolverFeature.CACHE_ENABLEDxml.catalog.cacheEnabled cache-enabled Boolean¹ ResolverFeature.CATALOG_ADDITIONSxml.catalog.additions catalog-additions List of strings² ResolverFeature.CATALOG_FILESxml.catalog.files catalogs List of strings² ResolverFeature.CATALOG_LOADER_CLASSxml.catalog.catalogLoaderClass catalog-loader-class String ResolverFeature.CLASSPATH_CATALOGSxml.catalog.classpathCatalogs classpath-catalogs String ResolverFeature.DEFAULT_LOGGER_LOG_LEVELxml.catalog.defaultLoggerLogLevel default-logger-log-level String ResolverFeature.MASK_JAR_URISxml.catalog.maskJarUris mask-jar-uris Boolean¹ ResolverFeature.MERGE_HTTPSxml.catalog.mergeHttps merge-https Boolean¹ ResolverFeature.PARSE_RDDLxml.catalog.parseRddl parse-rddl Boolean¹ ResolverFeature.PREFER_PROPERTY_FILExml.catalog.preferPropertyFile prefer-property-file Boolean¹ ResolverFeature.PREFER_PUBLICxml.catalog.prefer prefer " public" or "system"³ResolverFeature.RESOLVER_LOGGER_CLASSxml.catalog.resolverLoggerClass resolver-logger-class String ResolverFeature.SAXPARSERFACTORY_CLASSxml.catalog.saxParserFactoryClass saxparserfactory-class String ResolverFeature.URI_FOR_SYSTEMxml.catalog.uriForSystem uri-for-system Boolean¹ ResolverFeature.XMLREADER_SUPPLIER- - Supplier<XMLReader> ¹ Any of "true", "yes", or "1" is true; everything else is false. ² The list of strings is semicolon delimited ³ Public is preferred if the value is "public", any other value is equivalent to "system". Several additional features can only be set to objects at runtime and have no corresponding properties.
-
-
Constructor Summary
Constructors Constructor Description XMLResolverConfiguration()Construct a default configuration.XMLResolverConfiguration(java.lang.String catalogFiles)Construct a configuration from a delimited string of catalog files.XMLResolverConfiguration(java.util.List<java.lang.String> catalogFiles)Construct a configuration from a list of catalog files.XMLResolverConfiguration(java.util.List<java.net.URL> propertyFiles, java.util.List<java.lang.String> catalogFiles)Construct a resolver configuration with specific properties and catalog files.XMLResolverConfiguration(XMLResolverConfiguration current)A copying constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCatalog(java.lang.String catalog)Add a catalog file to the list of catalogs.voidaddCatalog(java.net.URI catalog, org.xml.sax.InputSource data)Add a catalog file to the list of catalogs.<T> TgetFeature(ResolverFeature<T> feature)Return the value of a feature.java.util.Iterator<ResolverFeature<?>>getFeatures()Iterate over all the known features.booleanremoveCatalog(java.lang.String catalog)Remove a catalog from the list of catalogs.<T> voidsetFeature(ResolverFeature<T> feature, T value)Set a configuration feature.
-
-
-
Constructor Detail
-
XMLResolverConfiguration
public XMLResolverConfiguration()
Construct a default configuration.The default configuration uses system properties and searches the classpath for an
xmlcatalog.propertiesfile. It uses the settings found there to configure the resolver.
-
XMLResolverConfiguration
public XMLResolverConfiguration(java.lang.String catalogFiles)
Construct a configuration from a delimited string of catalog files.The default configuration uses system properties and searches the classpath for an
xmlcatalog.propertiesfile. It uses the settings found there to configure the resolver, but replaces any list of catalog files found there with the catalog files provided in the constructor.- Parameters:
catalogFiles- A semi-colon (;) delimited list of catalog files
-
XMLResolverConfiguration
public XMLResolverConfiguration(java.util.List<java.lang.String> catalogFiles)
Construct a configuration from a list of catalog files.The default configuration uses system properties and searches the classpath for an
xmlcatalog.propertiesfile. It uses the settings found there to configure the resolver, but replaces any list of catalog files found there with the catalog files provided in the constructor.- Parameters:
catalogFiles- A list of catalog files.
-
XMLResolverConfiguration
public XMLResolverConfiguration(java.util.List<java.net.URL> propertyFiles, java.util.List<java.lang.String> catalogFiles)Construct a resolver configuration with specific properties and catalog files.The default configuration uses system properties and the properties found in the first
propertyFilesproperty file that it can read. (It uses at most one property file.) It uses those settings to configure the resolver, but replaces any list of catalog files found there with the catalog files provided in the constructor.- Parameters:
propertyFiles- A list of property files from which to attempt to load configuration properties.catalogFiles- A list of catalog files.
-
XMLResolverConfiguration
public XMLResolverConfiguration(XMLResolverConfiguration current)
A copying constructor.This constructor creates a new resolver configuration with the same properties as an existing configuration. It gets its own copy of the catalog file list and
CatalogManager.- Parameters:
current- The configuration to copy.
-
-
Method Detail
-
addCatalog
public void addCatalog(java.lang.String catalog)
Add a catalog file to the list of catalogs.This adds a catalog file to the end of the list of catalogs. This file will be loaded by opening the specified file.
- Parameters:
catalog- The catalog file.
-
addCatalog
public void addCatalog(java.net.URI catalog, org.xml.sax.InputSource data)Add a catalog file to the list of catalogs.This adds a catalog file to the end of the list of catalogs. This file will be loaded by reading from the specified input source.
- Parameters:
catalog- The catalog file.data- The input source that provides the catalog content.- Throws:
java.lang.NullPointerException- if either catalog or data is null.
-
removeCatalog
public boolean removeCatalog(java.lang.String catalog)
Remove a catalog from the list of catalogs.Removes the specified catalog from the list of catalogs (if it was present in the list).
- Parameters:
catalog- The catalog file.- Returns:
- True if the catalog was removed.
-
setFeature
public <T> void setFeature(ResolverFeature<T> feature, T value)
Set a configuration feature.Sets the specified feature to the specified value. Unknown features are ignored.
- Specified by:
setFeaturein interfaceResolverConfiguration- Type Parameters:
T- A type appropriate for the feature.- Parameters:
feature- The feature.value- The new value.- Throws:
java.lang.NullPointerException- if the value is null for features that cannot be null
-
getFeature
public <T> T getFeature(ResolverFeature<T> feature)
Return the value of a feature.Returns the value of the specified feature.
- Specified by:
getFeaturein interfaceResolverConfiguration- Type Parameters:
T- A type appropriate to the feature.- Parameters:
feature- The feature or null if the feature is unknown.- Returns:
- The feature value.
-
getFeatures
public java.util.Iterator<ResolverFeature<?>> getFeatures()
Iterate over all the known features.- Specified by:
getFeaturesin interfaceResolverConfiguration- Returns:
- An iterator over all the known features.
-
-