Package net.sf.saxon.resource
Class StandardCollectionFinder
- java.lang.Object
-
- net.sf.saxon.resource.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:- Any URI may be explicitly registered and associated with an instance of
ResourceCollection
- 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
- 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 ofJarCollection
- 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 Summary
Constructors Constructor Description StandardCollectionFinder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
checkFileExists(java.io.File file, java.net.URI resolvedURI, XPathContext context)
static void
checkNotNull(java.lang.String collectionURI, XPathContext context)
If the collectionURI is null, report that no default collection existsResourceCollection
findCollection(XPathContext context, java.lang.String collectionURI)
Locate the collection of resources corresponding to a collection URI.protected boolean
isJarFileURI(java.lang.String collectionURI)
Ask whether the collection URI should be interpreted as identifying a JAR (or ZIP) file.void
registerCollection(java.lang.String collectionURI, ResourceCollection collection)
Register a specific URI and bind it to a specific ResourceCollection
-
-
-
Method Detail
-
registerCollection
public void registerCollection(java.lang.String collectionURI, ResourceCollection collection)
Register a specific URI and bind it to a specific ResourceCollection- Parameters:
collectionURI
- the collection URI to be registered. Must not be null.collection
- the ResourceCollection to be associated with this URI. Must not be null.
-
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 interfaceCollectionFinder
- Parameters:
context
- The XPath dynamic evaluation contextcollectionURI
- 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
-
checkNotNull
public static void checkNotNull(java.lang.String collectionURI, XPathContext context) throws XPathException
If the collectionURI is null, report that no default collection exists- Parameters:
collectionURI
- the collection URI to be testedcontext
- XPath evaluation context- Throws:
XPathException
- if the collectionURI is null
-
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
-
checkFileExists
public static void checkFileExists(java.io.File file, java.net.URI resolvedURI, XPathContext context) throws XPathException
- Throws:
XPathException
-
-