Debian Codegraph @

net/sf/saxon/s9api/ExtensionFunction.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.s9api;
9
10 /**
11 * This is an interface for simple external/extension functions. Users can implement this
12 * interface and register the implementation with the {@link net.sf.saxon.s9api.Processor}; the function will
13 * then be available for calling from all queries, stylesheets, and XPath expressions compiled
14 * under this Processor.
15 * <p>Extension functions implemented using this interface are expected to be free of side-effects,
16 * and to have no dependencies on the static or dynamic context. A richer interface for extension
17 * functions is provided via the {@link net.sf.saxon.lib.ExtensionFunctionDefinition} class.</p>
18 */
19 public interface ExtensionFunction {
20
21 /**
22 * Return the name of the external function
23 *
24 * @return the name of the function, as a QName.
25 */
26 QName getName();
27
28 /**
29 * Declare the result type of the external function
30 *
31 * @return the result type of the external function
32 */
33
34 SequenceType getResultType();
35
36 /**
37 * Declare the types of the arguments
38 *
39 * @return an array of SequenceType objects, one for each argument to the function,
40 * representing the expected types of the arguments
41 */
42
43 SequenceType[] getArgumentTypes();
44
45 /**
46 * Call the function. The implementation of this method represents the body of the external function.
47 *
48 * @param arguments the arguments, as supplied in the XPath function call. These will always be of
49 * the declared types. Arguments are converted to the required types according to the standard XPath
50 * function conversion rules - for example, if the expected type is atomic and a node is supplied in the
51 * call, the node will be atomized
52 * @return the result of the function. This must be an instance of the declared return type; if it is not,
53 * a dynamic error will be reported
54 * @throws SaxonApiException can be thrown if the implementation of the function detects a dynamic error
55 */
56
57 /*@NotNull*/
58 XdmValue call(XdmValue[] arguments) throws SaxonApiException;
59 }