Debian Codegraph @

net/sf/saxon/functions/UnparsedTextAvailable.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.functions;
9
10 import net.sf.saxon.expr.Callable;
11 import net.sf.saxon.expr.XPathContext;
12 import net.sf.saxon.om.Sequence;
13 import net.sf.saxon.trans.XPathException;
14 import net.sf.saxon.value.BooleanValue;
15 import net.sf.saxon.value.StringValue;
16
17
18 public class UnparsedTextAvailable extends UnparsedTextFunction implements Callable {
19
20 /**
21 * Evaluate the expression
22 *
23 * @param context the dynamic evaluation context
24 * @param arguments the values of the arguments, supplied as SequenceIterators
25 * @return the result of the evaluation, in the form of a SequenceIterator
26 * @throws net.sf.saxon.trans.XPathException
27 * if a dynamic error occurs during the evaluation of the expression
28 */
29 public BooleanValue call(XPathContext context, Sequence[] arguments) throws XPathException {
30 StringValue hrefVal = (StringValue) arguments[0].head();
31 if (hrefVal == null) {
32 return BooleanValue.FALSE;
33 }
34 String encoding = getArity() == 2 ? arguments[1].head().getStringValue() : null;
35 return BooleanValue.get(
36 evalUnparsedTextAvailable(hrefVal, encoding, context));
37 }
38
39 public boolean evalUnparsedTextAvailable(StringValue hrefVal, String encoding, XPathContext context) {
40 try {
41 UnparsedText.evalUnparsedText(hrefVal, getStaticBaseUriString(), encoding, context);
42 return true;
43 } catch (XPathException err) {
44 return false;
45 }
46 }
47
48
49 }
50