Debian Codegraph @

net/sf/saxon/lib/ResourceCollection.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.lib;
9
10 import net.sf.saxon.expr.XPathContext;
11 import net.sf.saxon.om.SpaceStrippingRule;
12 import net.sf.saxon.trans.XPathException;
13
14 import java.util.Iterator;
15
16 /**
17 * This interface defines a ResourceCollection. This is a counterpart to the JAXP
18 * URIResolver, but is used to map the URI of collection into a sequence of Resource objects.
19 * It is used to support the fn:collection() and fn:uri-collection() functions.
20 * @since 9.7
21 */
22 public interface ResourceCollection {
23
24
25 /**
26 * Get the URI of the collection
27 *
28 * @return The URI as passed to the fn:collection() or fn:uri-collection()
29 * function, resolved if it is relative against the static base URI.
30 * If the collection() or uri-collection() function
31 * was called with no arguments (to get the "default collection") this
32 * will be the URI of the default collection registered with the Configuration.
33 */
34
35 String getCollectionURI();
36
37 /**
38 * Get the URIs of the resources in the collection. This supports the fn:uri-collection()
39 * function. It is not required that all collections expose a list of URIs in this way, or
40 * that the URIs bear any particular relationship to the resources returned by the
41 * getResources() method for the same collection URI. The URIs that are returned should be
42 * suitable for passing to the registered URIResolver (in the case of XML resources),
43 * or the {@link UnparsedTextURIResolver} (in the case of unparsed text and JSON resources), etc.
44 * @param context the XPath evaluation context
45 * @return an iterator over the URIs of the resources in the collection. The URIs are represented
46 * as Strings. They should preferably be absolute URIs.
47 * @throws XPathException in the event of any error (for example, if the collection URI
48 * is not recognized)
49 */
50
51 Iterator<String> getResourceURIs(XPathContext context) throws XPathException;
52
53 /**
54 * Get the resources in the collection. This supports the fn:collection() function. It is not
55 * required that all collections expose a set of resources in this way, or that the resources
56 * returned bear any particular relationship to the URIs returned by the getResourceURIs() method
57 * for the same collection URI.
58 * @param context the XPath evaluation context
59 * @return an iterator over the resources in the collection. This returns objects of class
60 * {@link Resource}.
61 * @throws XPathException in the event of any error (for example, if the collection URI
62 * is not recognized)
63 */
64
65 Iterator<? extends Resource> getResources(XPathContext context) throws XPathException;
66
67 /**
68 * Ask whether the collection is stable: in this case Saxon will retain the contents of the
69 * collection in memory, and will not make a second request on the CollectionFinder for the
70 * same collection URI.
71 * @param context the XPath dynamic evaluation context (in case the decision is context dependent)
72 */
73
74 boolean isStable(XPathContext context);
75
76
77 /**
78 * Supply information about the whitespace stripping rules that apply to this collection.
79 * This method will only be called when the collection() function is invoked from XSLT.
80 * (If in doubt, the implementation of this method should do nothing and return false.)
81 *
82 * @param rules the space-stripping rules that apply to this collection, derived from
83 * the xsl:strip-space and xsl:preserve-space declarations in the stylesheet
84 * package containing the call to the collection() function.
85 * @return true if the collection finder intends to take responsibility for whitespace
86 * stripping according to these rules; false if it wishes Saxon itself to post-process
87 * any returned XML documents to strip whitespace. Returning true may either indicate
88 * that the collection finder will strip whitespace before returning a document, or it
89 * may indicate that it does not wish the space stripping rules to be applied.
90 * @since 9.8
91 */
92
93 boolean stripWhitespace(SpaceStrippingRule rules);
94
95
96 }