Package com.icl.saxon.expr
Class FunctionProxy
java.lang.Object
com.icl.saxon.expr.Expression
com.icl.saxon.expr.Function
com.icl.saxon.expr.FunctionProxy
This class acts as a proxy for an extension function defined as a method
in a user-defined class
-
Field Summary
Fields inherited from class com.icl.saxon.expr.Expression
staticContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Value
convertJavaObjectToXPath
(Object result, Controller controller) Convert a Java object to an XPath value.Return an enumeration of nodes in a nodeset.Evaluate the function.boolean
evaluateAsBoolean
(Context context) Evaluate an expression as a Boolean.
The result of x.evaluateAsBoolean(c) must be equivalent to x.evaluate(c).asBoolean(); but optimisations are possible when it is known that a boolean result is required, especially in the case of a NodeSet.double
evaluateAsNumber
(Context context) Evaluate an expression as a Number.
The result of x.evaluateAsNumber(c) must be equivalent to x.evaluate(c).asNumber(); but optimisations are possible when it is known that a numeric result is required, especially in the case of a NodeSet.evaluateAsString
(Context context) Evaluate an expression as a String.
The result of x.evaluateAsString(c) must be equivalent to x.evaluate(c).asString(); but optimisations are possible when it is known that a string result is required, especially in the case of a NodeSet.getBestFit
(Value[] argValues) Get the best fit amongst all the candidate methods or constructorsint
Determine the data type of the expression, if possibleint
Determine which aspects of the context the expression depends on.getName()
Get the name of the functionPerform a partial evaluation of the expression, by eliminating specified dependencies on the context.boolean
setFunctionName
(Class reqClass, String localName) setFunctionName: locates the external class and the method (or candidate methods) to which this function relates.simplify()
Simplify the function (by simplifying its arguments)Methods inherited from class com.icl.saxon.expr.Function
addArgument, checkArgumentCount, display, getNumberOfArguments
Methods inherited from class com.icl.saxon.expr.Expression
containsReferences, evaluateAsNodeSet, getStaticContext, indent, isContextDocumentNodeSet, make, outputStringValue, setStaticContext, usesCurrent
-
Constructor Details
-
FunctionProxy
public FunctionProxy()Constructor: creates an uncommitted FunctionProxy
-
-
Method Details
-
setFunctionName
setFunctionName: locates the external class and the method (or candidate methods) to which this function relates. At this stage addArguments() will have normally been called, so the number of arguments is known. If no method of the required name is located, an exception is saved, but it is not thrown until an attempt is made to evaluate the function. All methods that match the required number of arguments are saved in a list (candidateMethods), a decision among these methods is made at run-time when the types of the actual arguments are known.The method is also used while calling function-available(). In this case the number of arguments is not known (it will be set to zero). We return true if a match was found, regardless of the number of arguments.
- Parameters:
reqClass
- The Java class namelocalName
- The local name used in the XPath function call- Returns:
- true if the function is available (with some number of arguments).
-
getDataType
public int getDataType()Determine the data type of the expression, if possible- Specified by:
getDataType
in classExpression
- Returns:
- Value.ANY (meaning not known in advance)
-
getName
Get the name of the function -
simplify
Simplify the function (by simplifying its arguments)- Overrides:
simplify
in classExpression
- Returns:
- the simplified expression
- Throws:
XPathException
-
getDependencies
public int getDependencies()Determine which aspects of the context the expression depends on. The result is a bitwise-or'ed value composed from constants such as Context.VARIABLES and Context.CURRENT_NODE- Specified by:
getDependencies
in classExpression
-
reduce
Perform a partial evaluation of the expression, by eliminating specified dependencies on the context.- Specified by:
reduce
in classExpression
- Parameters:
dependencies
- The dependencies to be removedcontext
- The context to be used for the partial evaluation- Returns:
- a new expression that does not have any of the specified dependencies
- Throws:
XPathException
-
getBestFit
Get the best fit amongst all the candidate methods or constructors- Returns:
- the result is either a Method or a Constructor. In JDK 1.2 these have a common superclass, AccessibleObject, but this is not available in JDK 1.1, which we still support.
- Throws:
XPathException
-
evaluate
Evaluate the function.- Specified by:
evaluate
in classExpression
- Parameters:
context
- The context in which the function is to be evaluated- Returns:
- a Value representing the result of the function.
- Throws:
XPathException
- if the function cannot be evaluated.
-
evaluateAsString
Description copied from class:Expression
Evaluate an expression as a String.
The result of x.evaluateAsString(c) must be equivalent to x.evaluate(c).asString(); but optimisations are possible when it is known that a string result is required, especially in the case of a NodeSet.- Overrides:
evaluateAsString
in classExpression
- Parameters:
context
- The context in which the expression is to be evaluated- Returns:
- the value of the expression, evaluated in the current context
- Throws:
XPathException
-
evaluateAsNumber
Description copied from class:Expression
Evaluate an expression as a Number.
The result of x.evaluateAsNumber(c) must be equivalent to x.evaluate(c).asNumber(); but optimisations are possible when it is known that a numeric result is required, especially in the case of a NodeSet.- Overrides:
evaluateAsNumber
in classExpression
- Parameters:
context
- The context in which the expression is to be evaluated- Returns:
- the value of the expression, evaluated in the current context
- Throws:
XPathException
-
evaluateAsBoolean
Description copied from class:Expression
Evaluate an expression as a Boolean.
The result of x.evaluateAsBoolean(c) must be equivalent to x.evaluate(c).asBoolean(); but optimisations are possible when it is known that a boolean result is required, especially in the case of a NodeSet.- Overrides:
evaluateAsBoolean
in classExpression
- Parameters:
context
- The context in which the expression is to be evaluated- Returns:
- the value of the expression, evaluated in the current context
- Throws:
XPathException
-
enumerate
Description copied from class:Expression
Return an enumeration of nodes in a nodeset.- Overrides:
enumerate
in classExpression
- Parameters:
context
- The context in which the expression is to be evaluatedrequireSorted
- Indicates whether the nodes are required in document order. If this is false, they may come in any order, but there will be no duplicates.- Throws:
XPathException
- when the expression does not return a nodeset.
-
convertJavaObjectToXPath
public static Value convertJavaObjectToXPath(Object result, Controller controller) throws XPathException Convert a Java object to an XPath value. This method is called to handle the result of an external function call (but only if the required type is not known), and also to process global parameters passed to the stylesheet.- Throws:
XPathException
-