Class CatalogManager
- java.lang.Object
-
- org.xmlresolver.CatalogManager
-
- All Implemented Interfaces:
XMLCatalogResolver
public class CatalogManager extends java.lang.Object implements XMLCatalogResolver
TheCatalogManager
manages a list of OASIS XML Catalogs and performs lookup operations on those catalogs.The manager's job is to implement the semantics of XML Catalogs.
This class loads OASIS XML Catalog files and provides methods for searching the catalog. All of the XML Catalog entry types defined in §6 (catalog, group, public, system, rewriteSystem, systemSuffix, delegatePublic, delegateSystem, uri, rewriteURI, uriSuffix, delegateURI, and nextCatalog) are supported. In addition, the following TR9401 Catalog entry types from §D are supported: doctype, document, entity, and notation. (The other types do not apply to XML.)
For each of the query methods, the manager either returns the mapping indicated by the catalog, or
null
to indicate that no match was found.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.net.URI>
catalogs()
CatalogLoader
getCatalogLoader()
Get the catalog loader.ResolverConfiguration
getResolverConfiguration()
Get the resolver configuration.org.xmlresolver.catalog.entry.EntryCatalog
loadCatalog(java.net.URI catalog)
Load the specified catalog.org.xmlresolver.catalog.entry.EntryCatalog
loadCatalog(java.net.URI catalog, org.xml.sax.InputSource source)
Load the specified catalog from a given input source.org.xmlresolver.catalog.entry.EntryCatalog
loadCatalog(java.net.URI catalog, org.xmlresolver.utils.SaxProducer producer)
Load the specified catalog by sending events to the ContentHandler.java.net.URI
lookupDoctype(java.lang.String entityName, java.lang.String systemId, java.lang.String publicId)
Lookup the specified document type in the catalog.java.net.URI
lookupDocument()
Lookup the default document in the catalog.java.net.URI
lookupEntity(java.lang.String entityName, java.lang.String systemId, java.lang.String publicId)
Lookup the specified entity in the catalog.java.net.URI
lookupNamespaceURI(java.lang.String uri, java.lang.String nature, java.lang.String purpose)
Lookup the specified namespace URI in the catalog.java.net.URI
lookupNotation(java.lang.String notationName, java.lang.String systemId, java.lang.String publicId)
Lookup the specified notation in the catalog.java.net.URI
lookupPublic(java.lang.String systemId, java.lang.String publicId)
Lookup the specified system and public identifiers in the catalog.java.net.URI
lookupSystem(java.lang.String systemId)
Lookup the specified system identifier in the catalog.java.net.URI
lookupURI(java.lang.String uri)
Lookup the specified URI in the catalog.java.lang.String
normalizedForComparison(java.lang.String uri)
void
setCatalogLoader(CatalogLoader loader)
Set the catalog loader.
-
-
-
Method Detail
-
getResolverConfiguration
public ResolverConfiguration getResolverConfiguration()
Get the resolver configuration.- Returns:
- the resolver configuration
-
getCatalogLoader
public CatalogLoader getCatalogLoader()
Get the catalog loader.This method returns the catalog loader that will be used by this manager if it attempts to load a catalog.
- Returns:
- the catalog loader.
-
setCatalogLoader
public void setCatalogLoader(CatalogLoader loader)
Set the catalog loader.This method sets the catalog loader that will be used by this manager if it attempts to load a catalog.
- Parameters:
loader
- the catalog loader.
-
catalogs
public java.util.List<java.net.URI> catalogs()
-
loadCatalog
public org.xmlresolver.catalog.entry.EntryCatalog loadCatalog(java.net.URI catalog)
Load the specified catalog.The manager maintains a set of the catalogs that it has loaded. If an attempt is made to load a catalog twice, the previously loaded catalog is returned.
- Parameters:
catalog
- The catalog URI.- Returns:
- The parsed catalog.
-
loadCatalog
public org.xmlresolver.catalog.entry.EntryCatalog loadCatalog(java.net.URI catalog, org.xml.sax.InputSource source)
Load the specified catalog from a given input source.This method exists so that a catalog can be loaded even if it doesn't have a URI that can be dereferenced. It must still have a URI.
The manager maintains a set of the catalogs that it has loaded. If an attempt is made to load a catalog twice, the previously loaded catalog is returned.
- Parameters:
catalog
- The catalog URI.source
- The input source.- Returns:
- The parsed catalog.
-
loadCatalog
public org.xmlresolver.catalog.entry.EntryCatalog loadCatalog(java.net.URI catalog, org.xmlresolver.utils.SaxProducer producer)
Load the specified catalog by sending events to the ContentHandler.This method exists so that a catalog can be loaded even if it doesn't have a URI that can be dereferenced. It must still have a URI.
The manager maintains a set of the catalogs that it has loaded. If an attempt is made to load a catalog twice, the previously loaded catalog is returned.
- Parameters:
catalog
- The catalog URI.producer
- The producer that delivers events to the ContentHandler.- Returns:
- The parsed catalog.
-
lookupURI
public java.net.URI lookupURI(java.lang.String uri)
Lookup the specified URI in the catalog.If a URI entry exists in the catalog for the URI specified, return the mapped value.
- Specified by:
lookupURI
in interfaceXMLCatalogResolver
- Parameters:
uri
- The URI to locate in the catalog.- Returns:
- The mapped value, or
null
if no matching entry is found.
-
lookupNamespaceURI
public java.net.URI lookupNamespaceURI(java.lang.String uri, java.lang.String nature, java.lang.String purpose)
Lookup the specified namespace URI in the catalog.If a URI entry exists in the catalog for the URI specified, and with the specified nature and purpose, return the mapped value.
- Parameters:
uri
- The URI to locate in the catalog.nature
- The RDDL nature of the requested resourcepurpose
- The RDDL purpose of the requested resource- Returns:
- The mapped value, or
null
if no matching entry is found.
-
lookupPublic
public java.net.URI lookupPublic(java.lang.String systemId, java.lang.String publicId)
Lookup the specified system and public identifiers in the catalog.If a SYSTEM or PUBLIC entry exists in the catalog for the system and public identifiers specified, return the mapped value.
On Windows and MacOS operating systems, the comparison between the system identifier provided and the SYSTEM entries in the Catalog is case-insensitive.
- Specified by:
lookupPublic
in interfaceXMLCatalogResolver
- Parameters:
systemId
- The nominal system identifier for the entity in question (as provided in the source document).publicId
- The public identifier to locate in the catalog. Public identifiers are normalized before comparison.- Returns:
- The mapped value, or
null
if no matching entry is found.
-
lookupSystem
public java.net.URI lookupSystem(java.lang.String systemId)
Lookup the specified system identifier in the catalog.If a SYSTEM entry exists in the catalog for the system identifier specified, return the mapped value.
On Windows-based operating systems, the comparison between the system identifier provided and the SYSTEM entries in the Catalog is case-insensitive.
- Specified by:
lookupSystem
in interfaceXMLCatalogResolver
- Parameters:
systemId
- The system identifier to locate in the catalog.- Returns:
- The mapped value, or
null
if no matching entry is found.
-
lookupDoctype
public java.net.URI lookupDoctype(java.lang.String entityName, java.lang.String systemId, java.lang.String publicId)
Lookup the specified document type in the catalog.If a DOCTYPE entry exists in the catalog for the specified arguments, return the mapped value.
- Specified by:
lookupDoctype
in interfaceXMLCatalogResolver
- Parameters:
entityName
- The name of the entity (element) for which a doctype is required.publicId
- The nominal public identifier for the doctype (as provided in the source document).systemId
- The nominal system identifier for the doctype (as provided in the source document).- Returns:
- The mapped value, or
null
if no matching entry is found.
-
lookupDocument
public java.net.URI lookupDocument()
Lookup the default document in the catalog.If a DOCUMENT entry exists in the catalog, return the mapped value.
- Specified by:
lookupDocument
in interfaceXMLCatalogResolver
- Returns:
- The mapped value, or
null
if no matching entry is found.
-
lookupEntity
public java.net.URI lookupEntity(java.lang.String entityName, java.lang.String systemId, java.lang.String publicId)
Lookup the specified entity in the catalog.If an ENTITY entry exists in the catalog for the specified arguments, return the mapped value.
- Specified by:
lookupEntity
in interfaceXMLCatalogResolver
- Parameters:
entityName
- The name of the entitysystemId
- The nominal system identifier for the entitypublicId
- The nominal public identifier for the entity- Returns:
- The mapped value, or
null
if no matching entry is found.
-
lookupNotation
public java.net.URI lookupNotation(java.lang.String notationName, java.lang.String systemId, java.lang.String publicId)
Lookup the specified notation in the catalog.If a NOTATION entry exists in the catalog for the specified arguments, return the mapped value.
- Specified by:
lookupNotation
in interfaceXMLCatalogResolver
- Parameters:
notationName
- The name of the notationsystemId
- The nominal system identifier for the entitypublicId
- The nominal public identifier for the entity- Returns:
- The mapped value, or
null
if no matching entry is found.
-
normalizedForComparison
public java.lang.String normalizedForComparison(java.lang.String uri)
-
-