com.novell.xml.xpath
Class FunctionCall

java.lang.Object
  extended bycom.novell.xml.xpath.FunctionCall
All Implemented Interfaces:
Expression

public class FunctionCall
extends Object
implements Expression

Implements an XPath FunctionCall.

See Also:
Function

Nested Class Summary
protected static interface FunctionCall.DoubleCaster
          An interface for casting an XPath number value to a java Number type (especially a java primitive number type)
protected static class FunctionCall.NumberCaster
          An implementation class for casting an XPath number value to a java Number-derived object (especially a java primitive number type)
 
Constructor Summary
FunctionCall(Function function)
          Construct a function call with no arguments.
FunctionCall(Function function, ArgumentList argList)
          Construct a function call with a list of arguments.
 
Method Summary
 void dump(PrintWriter writer, int indent)
          Print the expression in a readable form for debugging.
 ExpressionValue evaluate(Node contextNode, ExpressionContext context)
          Evaluate the expression with repect to the passed context
protected  void frameArguments(ExpressionValue[] args, Node contextNode, ExpressionContext context)
          Build a list of arguments for invoking the function.
 Function getFunction()
          Return the Function object that is the target of this FunctionCall
 Class getResultType()
          Return the Class object describing the result type of the expression.
 boolean isConstant()
          Return true if the expression is a constant value.
 void registerForReset(XPathResetRegistrar registrar)
          Register this expression or any subexpression that implements XPathResetCache with an object that wants to call resetCache()
protected  void setupArgs()
          Check the argument list for correct number and type.
 String toString()
          Provide a readable description for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FunctionCall

public FunctionCall(Function function)
             throws XPathParserException
Construct a function call with no arguments.

Parameters:
function - function object

FunctionCall

public FunctionCall(Function function,
                    ArgumentList argList)
             throws XPathParserException
Construct a function call with a list of arguments.

Parameters:
function - function object
argList - Array of expressions to be used as function arguments
Method Detail

getFunction

public Function getFunction()
Return the Function object that is the target of this FunctionCall

Returns:
The target Function

toString

public String toString()
Provide a readable description for debugging.

Returns:
String representation

evaluate

public ExpressionValue evaluate(Node contextNode,
                                ExpressionContext context)
                         throws XPathEvaluationException
Evaluate the expression with repect to the passed context

Specified by:
evaluate in interface Expression
Parameters:
contextNode - context node for expression evaluation
context - expression context for expression evaluation
Returns:
result of evaluating expression
Throws:
XPathEvaluationException

isConstant

public boolean isConstant()
Return true if the expression is a constant value.

Specified by:
isConstant in interface Expression
Returns:
True is expression is constant, false otherwise.

getResultType

public Class getResultType()
Return the Class object describing the result type of the expression.

Specified by:
getResultType in interface Expression
Returns:
A Class object.

registerForReset

public void registerForReset(XPathResetRegistrar registrar)
Register this expression or any subexpression that implements XPathResetCache with an object that wants to call resetCache()

Specified by:
registerForReset in interface Expression

dump

public void dump(PrintWriter writer,
                 int indent)
Print the expression in a readable form for debugging.

Specified by:
dump in interface Expression
Parameters:
writer - The output device.
indent - Number of tabs to indent the result.

frameArguments

protected void frameArguments(ExpressionValue[] args,
                              Node contextNode,
                              ExpressionContext context)
                       throws XPathEvaluationException
Build a list of arguments for invoking the function. This method handles converting the types, if required, and will throw an exception when argument types don't match the signature (casting actually setup in setupArgs(). This method also handles passing the expression context to those functions that require it (as indicated in their signatures).

Parameters:
args - The argument list (a list of expression results)
contextNode - The context node for expression evaluation
context - The expression evaluation context.
Throws:
XPathEvaluationException

setupArgs

protected void setupArgs()
                  throws XPathParserException
Check the argument list for correct number and type. This depends on this.function and this.args having been setup in the constructor. This will throw an XPathParserException if the number or types of the arguments don't match the function signature.

Throws:
XPathParserException