Debian Codegraph @

net/sf/saxon/lib/Resource.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
11 import net.sf.saxon.expr.XPathContext;
12 import net.sf.saxon.om.Item;
13 import net.sf.saxon.trans.XPathException;
14
15 /**
16 * This interface defines a Resource. The Resource objects belong to a collection.
17 * It is used to support the fn:collection() and fn:uri-collection() functions.
18 *
19 * <p>It is recommended (but is not universally the case) that fetching (and where necessary parsing)
20 * the content of a Resource should be delayed until the {@link #getItem} method is called. This means
21 * that errors in fetching the resource or parsing its contents may go undetected until the resource
22 * is materialized in this way.</p>
23 * @since 9.7
24 */
25 public interface Resource {
26
27 /**
28 * Get a URI that identifies this resource
29 * @return a URI identifying this resource
30 */
31
32 String getResourceURI();
33
34 /**
35 * Get an XDM Item holding the contents of this resource.
36 * @param context the XPath evaluation context
37 * @return an item holding the contents of the resource. The type of item will
38 * reflect the type of the resource: a document node for XML resources, a string
39 * for text resources, a map or array for JSON resources, a base64Binary value
40 * for binary resource. May also return null if the resource cannot be materialized
41 * and this is not to be treated as an error.
42 * @throws XPathException if a failure occurs materializing the resource
43 */
44
45 Item<?> getItem(XPathContext context) throws XPathException;
46
47 /**
48 * Get the media type (MIME type) of the resource if known
49 * @return the media type if known; otherwise null
50 */
51
52 String getContentType();
53
54
55 }