Class JarCollection

  • All Implemented Interfaces:
    ResourceCollection

    public class JarCollection
    extends AbstractResourceCollection
    A JarCollection represents a collection of resources held in a JAR or ZIP archive, accessed typically using a URI using the (Java-defined) "jar" URI scheme, or simply a "file" URI where the target file is a JAR or ZIP file.
    • Constructor Detail

      • JarCollection

        public JarCollection​(XPathContext context,
                             java.lang.String collectionURI,
                             URIQueryParameters params)
        Create a JarCollection
        Parameters:
        context - The XPath dynamic context
        collectionURI - the collection URI used to identify this collection (typically but not necessarily the location of the JAR file)
        params - URI query parameters appearing on the collection URI
    • Method Detail

      • stripWhitespace

        public boolean stripWhitespace​(SpaceStrippingRule rules)
        Supply information about the whitespace stripping rules that apply to this collection. This method will only be called when the collection() function is invoked from XSLT.
        Specified by:
        stripWhitespace in interface ResourceCollection
        Overrides:
        stripWhitespace in class AbstractResourceCollection
        Parameters:
        rules - the space-stripping rules that apply to this collection, derived from the xsl:strip-space and xsl:preserve-space declarations in the stylesheet package containing the call to the collection() function.
        Returns:
        true if the collection finder intends to take responsibility for whitespace stripping according to these rules; false if it wishes Saxon itself to post-process any returned XML documents to strip whitespace. Returning true may either indicate that the collection finder will strip whitespace before returning a document, or it may indicate that it does not wish the space stripping rules to be applied. The default (returned by this method if not overridden) is false.
      • getResourceURIs

        public java.util.Iterator<java.lang.String> getResourceURIs​(XPathContext context)
                                                             throws XPathException
        Get the URIs of the resources within the collection
        Parameters:
        context - dynamic evaluation context
        Returns:
        a list of all the URIs of resources within the collection. The resources are identified by URIs of the form collection-uri!entry-path
        Throws:
        XPathException - if any error occurs accessing the JAR file contents
      • getResources

        public java.util.Iterator<Resource> getResources​(XPathContext context)
                                                  throws XPathException
        Get an iterator over the resources in the collection
        Parameters:
        context - the XPath evaluation context
        Returns:
        an iterator over the resources in the collection. This may include instances of FailedResource if there are resources that cannot be processed for some reason.
        Throws:
        XPathException - if it is not possible to get an iterator.
      • makeProperties

        protected java.util.Map<java.lang.String,​GroundedValue> makeProperties​(java.util.zip.ZipEntry entry)
        Get the properties of a Zip file entry, for use when returning a MetadataResource containing this information
        Parameters:
        entry - the current Zip file entry
        Returns:
        a map containing the properties of this entry: comment, compressed-size, crc, extra, compression-method, entry-name, size, and last-modified.