org.apache.xml.resolver

Class Resolver

public class Resolver extends Catalog

An extension to OASIS Open Catalog files, this class supports suffix-based matching and an external RFC2483 resolver.

Version: 1.0

Author: Norman Walsh Norman.Walsh@Sun.COM

See Also:

Field Summary
static intRESOLVER

The RESOLVER Catalog Entry type.

A hook for providing support for web-based backup resolvers.

static intSYSTEMREVERSE

The SYSTEMREVERSE Catalog Entry type.

This is a bit of a hack.

static intSYSTEMSUFFIX

The SYSTEMSUFFIX Catalog Entry type.

System suffix entries match system identifiers that end in a specified suffix.

static intURISUFFIX

The URISUFFIX Catalog Entry type.

URI suffix entries match URIs that end in a specified suffix.

Method Summary
voidaddEntry(CatalogEntry entry)

Cleanup and process a Catalog entry.

This method processes each Catalog entry, changing mapped relative system identifiers into absolute ones (based on the current base URI), and maintaining other information about the current catalog.

protected ResolverqueryResolver(String resolver, String command, String arg1, String arg2)

Query an external RFC2483 resolver.

VectorresolveAllSystem(String systemId)

Return the applicable SYSTEM system identifiers

If one or more SYSTEM entries exists in the Catalog for the system ID specified, return the mapped values.

The caller is responsible for doing any necessary normalization of the system identifier before calling this method.

VectorresolveAllSystemReverse(String systemId)

Find the URNs for a given system identifier in all catalogs.

protected StringresolveExternalPublic(String publicId, String resolver)

Query an external RFC2483 resolver for a public identifier.

protected StringresolveExternalSystem(String systemId, String resolver)

Query an external RFC2483 resolver for a system identifier.

StringresolvePublic(String publicId, String systemId)

Return the applicable PUBLIC or SYSTEM identifier, resorting to external resolvers if necessary.

This method searches the Catalog and returns the system identifier specified for the given system or public identifiers.

StringresolveSystem(String systemId)

Return the applicable SYSTEM system identifier, resorting to external RESOLVERs if necessary.

If a SYSTEM entry exists in the Catalog for the system ID specified, return the mapped value.

In the Resolver (as opposed to the Catalog) class, if the URI isn't found by the usual algorithm, SYSTEMSUFFIX entries are considered.

On Windows-based operating systems, the comparison between the system identifier provided and the SYSTEM entries in the Catalog is case-insensitive.

StringresolveSystemReverse(String systemId)

Find the URN for a given system identifier.

StringresolveURI(String uri)

Return the applicable URI

If a URI entry exists in the Catalog for the URI specified, return the mapped value.

In the Resolver (as opposed to the Catalog) class, if the URI isn't found by the usual algorithm, URISUFFIX entries are considered.

URI comparison is case sensitive.

voidsetupReaders()

Setup readers.

Field Detail

RESOLVER

public static final int RESOLVER

The RESOLVER Catalog Entry type.

A hook for providing support for web-based backup resolvers.

SYSTEMREVERSE

public static final int SYSTEMREVERSE

The SYSTEMREVERSE Catalog Entry type.

This is a bit of a hack. There's no actual SYSTEMREVERSE entry, but this entry type is used to indicate that a reverse lookup is being performed. (This allows the Resolver to implement RFC2483 I2N and I2NS.)

SYSTEMSUFFIX

public static final int SYSTEMSUFFIX

The SYSTEMSUFFIX Catalog Entry type.

System suffix entries match system identifiers that end in a specified suffix.

URISUFFIX

public static final int URISUFFIX

The URISUFFIX Catalog Entry type.

URI suffix entries match URIs that end in a specified suffix.

Method Detail

addEntry

public void addEntry(CatalogEntry entry)

Cleanup and process a Catalog entry.

This method processes each Catalog entry, changing mapped relative system identifiers into absolute ones (based on the current base URI), and maintaining other information about the current catalog.

Parameters: entry The CatalogEntry to process.

queryResolver

protected Resolver queryResolver(String resolver, String command, String arg1, String arg2)

Query an external RFC2483 resolver.

Parameters: resolver The URL of the RFC2483 resolver. command The command to send the resolver. arg1 The first argument to the resolver. arg2 The second argument to the resolver, usually null.

Returns: The Resolver constructed.

resolveAllSystem

public Vector resolveAllSystem(String systemId)

Return the applicable SYSTEM system identifiers

If one or more SYSTEM entries exists in the Catalog for the system ID specified, return the mapped values.

The caller is responsible for doing any necessary normalization of the system identifier before calling this method. For example, a relative system identifier in a document might be converted to an absolute system identifier before attempting to resolve it.

Note that this function will force all subordinate catalogs to be loaded.

On Windows-based operating systems, the comparison between the system identifier provided and the SYSTEM entries in the Catalog is case-insensitive.

Parameters: systemId The system ID to locate in the catalog.

Returns: The system identifier to use for the notation.

Throws: MalformedURLException The formal system identifier of a subordinate catalog cannot be turned into a valid URL. IOException Error reading subordinate catalog file.

resolveAllSystemReverse

public Vector resolveAllSystemReverse(String systemId)

Find the URNs for a given system identifier in all catalogs.

Parameters: systemId The system ID to locate.

Returns: A vector of URNs that map to the systemId.

resolveExternalPublic

protected String resolveExternalPublic(String publicId, String resolver)

Query an external RFC2483 resolver for a public identifier.

Parameters: publicId The system ID to locate. resolver The name of the resolver to use.

Returns: The system identifier to use for the systemId.

resolveExternalSystem

protected String resolveExternalSystem(String systemId, String resolver)

Query an external RFC2483 resolver for a system identifier.

Parameters: systemId The system ID to locate. resolver The name of the resolver to use.

Returns: The system identifier to use for the systemId.

resolvePublic

public String resolvePublic(String publicId, String systemId)

Return the applicable PUBLIC or SYSTEM identifier, resorting to external resolvers if necessary.

This method searches the Catalog and returns the system identifier specified for the given system or public identifiers. If no appropriate PUBLIC or SYSTEM entry is found in the Catalog, null is returned.

Note that a system or public identifier in the current catalog (or subordinate catalogs) will be used in preference to an external resolver. Further, if a systemId is present, the external resolver(s) will be queried for that before the publicId.

Parameters: publicId The public identifier to locate in the catalog. Public identifiers are normalized before comparison. systemId The nominal system identifier for the entity in question (as provided in the source document).

Returns: The system identifier to use. Note that the nominal system identifier is not returned if a match is not found in the catalog, instead null is returned to indicate that no match was found.

Throws: MalformedURLException The formal system identifier of a subordinate catalog cannot be turned into a valid URL. IOException Error reading subordinate catalog file.

resolveSystem

public String resolveSystem(String systemId)

Return the applicable SYSTEM system identifier, resorting to external RESOLVERs if necessary.

If a SYSTEM entry exists in the Catalog for the system ID specified, return the mapped value.

In the Resolver (as opposed to the Catalog) class, if the URI isn't found by the usual algorithm, SYSTEMSUFFIX entries are considered.

On Windows-based operating systems, the comparison between the system identifier provided and the SYSTEM entries in the Catalog is case-insensitive.

Parameters: systemId The system ID to locate in the catalog.

Returns: The system identifier to use for systemId.

Throws: MalformedURLException The formal system identifier of a subordinate catalog cannot be turned into a valid URL. IOException Error reading subordinate catalog file.

resolveSystemReverse

public String resolveSystemReverse(String systemId)

Find the URN for a given system identifier.

Parameters: systemId The system ID to locate.

Returns: A (single) URN that maps to the systemId.

resolveURI

public String resolveURI(String uri)

Return the applicable URI

If a URI entry exists in the Catalog for the URI specified, return the mapped value.

In the Resolver (as opposed to the Catalog) class, if the URI isn't found by the usual algorithm, URISUFFIX entries are considered.

URI comparison is case sensitive.

Parameters: uri The URI to locate in the catalog.

Returns: The resolved URI.

Throws: MalformedURLException The system identifier of a subordinate catalog cannot be turned into a valid URL. IOException Error reading subordinate catalog file.

setupReaders

public void setupReaders()

Setup readers.

Copyright B) 2001 Apache. All Rights Reserved.