com.saxonica.functions.hof
Class CoercedFunction

java.lang.Object
  extended by com.saxonica.functions.hof.AbstractFunctionItem
      extended by com.saxonica.functions.hof.CoercedFunction
All Implemented Interfaces:
PullEvent, FunctionItem, Item, ValueRepresentation

public class CoercedFunction
extends AbstractFunctionItem

A function item obtained by coercing a supplied function; this adds a wrapper to perform dynamic type checking of the arguments in any call, and type checking of the result.


Field Summary
 
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
 
Constructor Summary
CoercedFunction(FunctionItem targetFunction)
          Create a CoercedFunction as a wrapper around a target function
 
Method Summary
static CoercedFunction coerce(FunctionItem suppliedFunction, FunctionType requiredType, RoleLocator role, TypeCheckerEnvironment visitor)
          Factory method to create a CoercedFunction with a given type, for a given targetFunction.
 int getArity()
          Get the arity of the function
 FunctionItemType getFunctionItemType(TypeHierarchy th)
          Get the item type of the function item
 StructuredQName getFunctionName()
          Get the name of the function, or null if it is anonymous
 SequenceIterator invoke(SequenceIterator[] args, XPathContext context)
          Invoke the function
 void setArgumentConverter(int arg, Expression converter)
          Set the argument converter for one argument
 void setResultConverter(Expression converter)
          Set the converter used to process the returned value
 void setStackFrameMap(SlotManager stackFrame)
          Set the stack frame map identifying the arguments for conversion
 
Methods inherited from class com.saxonica.functions.hof.AbstractFunctionItem
bind, curry, deepEquals, explain, getStringValue, getStringValueCS, getTypedValue, optimize, simplify, typeCheck
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoercedFunction

public CoercedFunction(FunctionItem targetFunction)
Create a CoercedFunction as a wrapper around a target function

Parameters:
targetFunction - the function to be wrapped by a type-checking layer
Method Detail

setArgumentConverter

public void setArgumentConverter(int arg,
                                 Expression converter)
Set the argument converter for one argument

Parameters:
arg - identifies the argument to be converted
converter - the expression used to perform the conversion

setResultConverter

public void setResultConverter(Expression converter)
Set the converter used to process the returned value

Parameters:
converter - the expression used to perform the conversion

setStackFrameMap

public void setStackFrameMap(SlotManager stackFrame)
Set the stack frame map identifying the arguments for conversion

Parameters:
stackFrame -

getFunctionItemType

public FunctionItemType getFunctionItemType(TypeHierarchy th)
Get the item type of the function item

Parameters:
th -
Returns:
the function item's type

getFunctionName

public StructuredQName getFunctionName()
Get the name of the function, or null if it is anonymous

Returns:
null indicating that this is an anonymous inline function

getArity

public int getArity()
Get the arity of the function

Returns:
the number of arguments in the function signature

invoke

public SequenceIterator invoke(SequenceIterator[] args,
                               XPathContext context)
                        throws XPathException
Invoke the function

Parameters:
args - the actual arguments to be supplied
context - the XPath dynamic evaluation context
Returns:
the result of invoking the function
Throws:
XPathException

coerce

public static CoercedFunction coerce(FunctionItem suppliedFunction,
                                     FunctionType requiredType,
                                     RoleLocator role,
                                     TypeCheckerEnvironment visitor)
                              throws XPathException
Factory method to create a CoercedFunction with a given type, for a given targetFunction. It is assumed that we have already established that coercion is needed

Throws:
XPathException


Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.