Debian Codegraph @

net/sf/saxon/resource/FailedResource.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.resource;
9
10 import net.sf.saxon.expr.XPathContext;
11 import net.sf.saxon.lib.Resource;
12 import net.sf.saxon.om.Item;
13 import net.sf.saxon.trans.XPathException;
14
15 /**
16 * FailedResource represents an item in a collection that could not be processed because of some kind of error
17 */
18 public class FailedResource implements Resource {
19
20 private String uri;
21 private XPathException error;
22
23 /**
24 * Create a FailedResource
25 * @param uri the URI of the resource
26 * @param error the error that occurred when attempting to process the resource
27 */
28
29 public FailedResource(String uri, XPathException error) {
30 this.uri = uri;
31 this.error = error;
32 }
33
34 /**
35 * Get the media type (MIME type) of the resource if known
36 *
37 * @return always null for this kind of resource
38 */
39 public String getContentType() {
40 return null;
41 }
42
43 /**
44 * Get a URI that identifies this resource
45 *
46 * @return a URI identifying this resource
47 */
48 public String getResourceURI() {
49 return uri;
50 }
51
52 /**
53 * Get an XDM Item holding the contents of this resource. This method always
54 * throws the error associated with the resource.
55 *
56 * @param context the XPath evaluation context
57 * @return an item holding the contents of the resource. This version of the method
58 * never returns an item; it always throws an error
59 * @throws XPathException if a failure occurs materializing the resource
60 */
61
62 public Item getItem(XPathContext context) throws XPathException {
63 throw error;
64 }
65
66 /**
67 * Get the underlying error
68 */
69
70 public XPathException getError() {
71 return error;
72 }
73 }
74