Class CatalogResolver

  • All Implemented Interfaces:
    ResourceResolver

    public class CatalogResolver
    extends java.lang.Object
    implements ResourceResolver
    The CatalogResolver returns resolved resources in a uniform way. The various resolver APIs want different return results. This class wraps those up in a uniform interface so that the details about resolution are more readily available.g
    • Field Detail

    • Constructor Detail

      • CatalogResolver

        public CatalogResolver()
        Creates a new instance of ResourceResolver using a default configuration.
      • CatalogResolver

        public CatalogResolver​(XMLResolverConfiguration conf)
        Creates a new instance of ResourceResolver with the specified resolver configuration.
        Parameters:
        conf - The XMLResolverConfiguration to use.
        Throws:
        java.lang.NullPointerException - if the configuration is null.
    • Method Detail

      • resolveURI

        public ResolvedResource resolveURI​(java.lang.String href,
                                           java.lang.String baseURI)
        Resolve a URI.

        The catalog is interrogated for the specified href. If it is found, its mapping is returned. Otherwise, the href is made absolute with respect to the specified base and the catalog is interrogated for the resulting absolute URI. If it is found, its mapping is returned.

        Specified by:
        resolveURI in interface ResourceResolver
        Parameters:
        href - The URI of the resource
        baseURI - The base URI against which href should be made absolute, if necessary.
        Returns:
        The resolved resource or null if no resolution was possible.
        Throws:
        java.lang.IllegalArgumentException - if the THROW_URI_EXCEPTIONS feature is true and an exception occurs resolving a URI.
      • resolveEntity

        public ResolvedResource resolveEntity​(java.lang.String name,
                                              java.lang.String publicId,
                                              java.lang.String systemId,
                                              java.lang.String baseURI)
        Resolve external identifiers and other entity-like resources.

        If the systemId is null and the baseURI is not, the systemId is taken to be the baseURI and the baseURI is treated as if it were null.

        If name, publicId and systemId are all null, null is returned.

        If systemId or publicId are not null, the method attempts to resolve an external identifier with the specified external identifier and the (possibly null) name and publicId. (Because public identifiers can be encoded in URNs, it's possible for this method to receive a publicId and not a systemId, even in XML systems.)

        If name is not null, but systemId is, name is assumed to be document type name and the method attempts to resolve an external identifier that matches. A doctype catalog entry, for example.

        If the systemId is relative, resolution fails, and baseURI is not null, the systemId is made absolute with respect to the baseURI and resolution is attempted a second time.

        Specified by:
        resolveEntity in interface ResourceResolver
        Parameters:
        name - The possibly null entity (or document type) name.
        publicId - The possibly null public identifier.
        systemId - The possibly relative system identifier to resolve.
        baseURI - The possibly null base URI to use if systemId is relative and not resolved.
        Returns:
        The resolved resource or null if no resolution was possible.
        Throws:
        java.lang.IllegalArgumentException - if the THROW_URI_EXCEPTIONS feature is true and an exception occurs resolving a URI.
      • resolveNamespace

        public ResolvedResource resolveNamespace​(java.lang.String uri,
                                                 java.lang.String baseURI,
                                                 java.lang.String nature,
                                                 java.lang.String purpose)
        Resolve a Namespace URI.

        The catalog is interrogated for the specified namespace. If it is found, it is returned.

        The resolver attempts to parse the resource as an XML document. If it finds RDDL 1.0 markup, it will attempt to locate the resource with the specified nature and purpose. That resource will be downloaded and returned. If it cannot parse the document or cannot find the markup that it is looking for, it will return the resource that represents the namespace URI.

        Specified by:
        resolveNamespace in interface ResourceResolver
        Parameters:
        uri - The namespace URI.
        baseURI - The base URI of the resource.
        nature - The RDDL nature of the resource.
        purpose - The RDDL purpose of the resource.
        Returns:
        The resolved resource or null if no resolution was possible.
        Throws:
        java.lang.IllegalArgumentException - if the THROW_URI_EXCEPTIONS feature is true and an exception occurs resolving a URI.