Debian Codegraph @

net/sf/saxon/functions/Data_1.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.Atomizer;
11 import net.sf.saxon.expr.Expression;
12 import net.sf.saxon.expr.XPathContext;
13 import net.sf.saxon.om.Item;
14 import net.sf.saxon.om.Sequence;
15 import net.sf.saxon.om.SequenceIterator;
16 import net.sf.saxon.om.SequenceTool;
17 import net.sf.saxon.trans.XPathException;
18 import net.sf.saxon.value.AtomicValue;
19
20 /**
21 * Implement XPath function fn:data() with a single argument
22 */
23
24 public class Data_1 extends SystemFunction {
25
26
27 /**
28 * Make an expression that either calls this function, or that is equivalent to a call
29 * on this function
30 *
31 * @param arguments the supplied arguments to the function call
32 * @return either a function call on this function, or an expression that delivers
33 * the same result
34 */
35 @Override
36 public Expression makeFunctionCall(Expression... arguments) {
37 return Atomizer.makeAtomizer(arguments[0], null);
38 }
39
40 /**
41 * Evaluate the expression. (Used for run-time evaluation only)
42 *
43 * @param context the dynamic evaluation context
44 * @param arguments the values of the arguments, supplied as Sequences
45 * @return the result of the evaluation, in the form of a Sequence
46 * @throws net.sf.saxon.trans.XPathException
47 * if a dynamic error occurs during the evaluation of the expression
48 */
49 public Sequence<? extends AtomicValue> call(XPathContext context, Sequence[] arguments) throws XPathException {
50 Sequence<?> arg = arguments[0];
51 if (arg instanceof Item) {
52 return ((Item)arg).atomize();
53 } else {
54 SequenceIterator<? extends AtomicValue> a = Atomizer.getAtomizingIterator(arg.iterate(), false);
55 return SequenceTool.toLazySequence(a);
56 }
57 }
58 }
59