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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classXMLResolverConfiguration.FallbackLogger
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringaccessExternalDocumentprivate java.lang.StringaccessExternalEntityprivate java.util.List<java.lang.String>additionalCatalogsprivate java.lang.BooleanallowCatalogPIprivate java.lang.BooleanalwaysResolveprivate java.lang.BooleanarchivedCatalogsprivate ResourceCachecacheprivate java.lang.StringcacheDirectoryprivate java.lang.BooleancacheEnabledprivate java.lang.BooleancacheUnderHomeprivate java.lang.StringcatalogLoaderprivate java.util.List<java.lang.String>catalogsprivate java.lang.ClassLoaderclassLoaderprivate static java.util.List<java.lang.String>classpathCatalogListprivate java.lang.BooleanclasspathCatalogsprivate java.lang.StringdefaultLoggerLogLevelprivate java.lang.BooleanfixWindowsSystemIdentifiersprivate static ResolverFeature<?>[]knownFeaturesprivate CatalogManagermanagerprivate java.lang.BooleanmaskJarUrisprivate java.lang.BooleanmergeHttpsprivate java.lang.BooleanparseRddlprivate java.lang.BooleanpreferPropertyFileprivate java.lang.BooleanpreferPublicprivate ResolverLoggerresolverLoggerprivate java.lang.StringresolverLoggerClassprivate java.lang.StringsaxParserFactoryClassprivate java.lang.BooleanshowConfigChangesprivate java.lang.BooleanthrowUriExceptionsprivate java.lang.BooleanuriForSystemprivate java.util.function.Supplier<org.xml.sax.XMLReader>xmlReaderSupplier
-
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 Static 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.private java.util.List<java.lang.String>findClasspathCatalogFiles()private java.lang.StringgetConfigProperty(java.lang.String name)<T> TgetFeature(ResolverFeature<T> feature)Return the value of a feature.java.util.Iterator<ResolverFeature<?>>getFeatures()Iterate over all the known features.private static booleanisTrue(java.lang.String aString)private voidloadConfiguration(java.util.List<java.net.URL> propertyFiles, java.util.List<java.lang.String> catalogFiles)private voidloadPropertiesConfiguration(java.net.URL propertiesURL, java.util.Properties properties)private voidloadSystemPropertiesConfiguration()booleanremoveCatalog(java.lang.String catalog)Remove a catalog from the list of catalogs.<T> voidsetFeature(ResolverFeature<T> feature, T value)Set a configuration feature.private voidshowConfig()private voidshowConfigChange(java.lang.String message)private voidshowConfigChange(java.lang.String message, java.lang.Object value)
-
-
-
Field Detail
-
knownFeatures
private static final ResolverFeature<?>[] knownFeatures
-
classpathCatalogList
private static java.util.List<java.lang.String> classpathCatalogList
-
catalogs
private final java.util.List<java.lang.String> catalogs
-
additionalCatalogs
private final java.util.List<java.lang.String> additionalCatalogs
-
preferPublic
private java.lang.Boolean preferPublic
-
preferPropertyFile
private java.lang.Boolean preferPropertyFile
-
allowCatalogPI
private java.lang.Boolean allowCatalogPI
-
alwaysResolve
private java.lang.Boolean alwaysResolve
-
cacheDirectory
private java.lang.String cacheDirectory
-
cacheUnderHome
private java.lang.Boolean cacheUnderHome
-
cacheEnabled
private java.lang.Boolean cacheEnabled
-
cache
private ResourceCache cache
-
manager
private CatalogManager manager
-
uriForSystem
private java.lang.Boolean uriForSystem
-
mergeHttps
private java.lang.Boolean mergeHttps
-
maskJarUris
private java.lang.Boolean maskJarUris
-
catalogLoader
private java.lang.String catalogLoader
-
parseRddl
private java.lang.Boolean parseRddl
-
classpathCatalogs
private java.lang.Boolean classpathCatalogs
-
classLoader
private java.lang.ClassLoader classLoader
-
archivedCatalogs
private java.lang.Boolean archivedCatalogs
-
throwUriExceptions
private java.lang.Boolean throwUriExceptions
-
showConfigChanges
private java.lang.Boolean showConfigChanges
-
resolverLoggerClass
private java.lang.String resolverLoggerClass
-
defaultLoggerLogLevel
private java.lang.String defaultLoggerLogLevel
-
accessExternalEntity
private java.lang.String accessExternalEntity
-
accessExternalDocument
private java.lang.String accessExternalDocument
-
saxParserFactoryClass
private java.lang.String saxParserFactoryClass
-
xmlReaderSupplier
private java.util.function.Supplier<org.xml.sax.XMLReader> xmlReaderSupplier
-
fixWindowsSystemIdentifiers
private java.lang.Boolean fixWindowsSystemIdentifiers
-
resolverLogger
private ResolverLogger resolverLogger
-
-
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
-
getConfigProperty
private java.lang.String getConfigProperty(java.lang.String name)
-
loadConfiguration
private void loadConfiguration(java.util.List<java.net.URL> propertyFiles, java.util.List<java.lang.String> catalogFiles)
-
loadSystemPropertiesConfiguration
private void loadSystemPropertiesConfiguration()
-
loadPropertiesConfiguration
private void loadPropertiesConfiguration(java.net.URL propertiesURL, java.util.Properties properties)
-
showConfig
private void showConfig()
-
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
-
showConfigChange
private void showConfigChange(java.lang.String message)
-
showConfigChange
private void showConfigChange(java.lang.String message, java.lang.Object value)
-
findClasspathCatalogFiles
private java.util.List<java.lang.String> findClasspathCatalogFiles()
-
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.
-
isTrue
private static boolean isTrue(java.lang.String aString)
-
-