Class StandardCollectionFinder

  • All Implemented Interfaces:
    CollectionFinder

    public class StandardCollectionFinder
    extends java.lang.Object
    implements CollectionFinder
    Default implementation of the CollectionFinder interface. The standard CollectionFinder recognizes four types of collection:
    1. Any URI may be explicitly registered and associated with an instance of ResourceCollection
    2. If the file: URI scheme is used, and the relevant file identifies a directory, the directory is treated as a collection: it is returned as an instance of DirectoryCollection
    3. If the URI ends with ".jar" or ".zip", or more generally, if the method isJarFileURI(String) returns true, the URI is treated as identifying a JAR or ZIP archive, whose contents form the resources in the collection: it is returned as an instance of JarCollection
    4. In all other cases, the URI is treated as the URI of an XML document listing the URIs of the resources in the collection, which are then retrieved using the URIResolver
    • Constructor Detail

      • StandardCollectionFinder

        public StandardCollectionFinder()
    • Method Detail

      • findCollection

        public ResourceCollection findCollection​(XPathContext context,
                                                 java.lang.String collectionURI)
                                          throws XPathException
        Locate the collection of resources corresponding to a collection URI.
        Specified by:
        findCollection in interface CollectionFinder
        Parameters:
        context - The XPath dynamic evaluation context
        collectionURI - The collection URI: an absolute URI, formed by resolving the argument supplied to the fn:collection or fn:uri-collection against the static base URI
        Returns:
        a ResourceCollection object representing the resources in the collection identified by this collection URI
        Throws:
        XPathException - if the collection URI cannot be resolved to a collection
      • isJarFileURI

        protected boolean isJarFileURI​(java.lang.String collectionURI)
        Ask whether the collection URI should be interpreted as identifying a JAR (or ZIP) file. This method is provided so that it can be overridden in subclasses. The default implementation returns true if the collection URI ends with the extension ".jar", ".zip", or ".docx", or if it is a URI using the "jar" scheme.

        The set of URIs recognized as ZIP collections can also be extended by setting the configuration property Feature.ZIP_URI_PATTERN.

        Parameters:
        collectionURI - the requested absolute collection URI
        Returns:
        true if the collection URI should be interpreted as a JAR or ZIP file