com.saxonica.functions.hof
Class AbstractFunctionItem

java.lang.Object
  extended by com.saxonica.functions.hof.AbstractFunctionItem
All Implemented Interfaces:
PullEvent, FunctionItem, Item, ValueRepresentation
Direct Known Subclasses:
CoercedFunction, CurriedFunction, FirstClassFunction, UserFunctionItem

public abstract class AbstractFunctionItem
extends Object
implements FunctionItem

Abstract superclass (and factory class) for implementations of FunctionItem


Field Summary
 
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
 
Constructor Summary
AbstractFunctionItem()
           
 
Method Summary
static AbstractFunctionItem bind(StructuredQName functionName, int arity, StaticContext env, Container container)
          Factory method to create a function item representing a function item literal
 FunctionItem curry(ValueRepresentation[] values)
          Curry a function by binding one or more (but not all) of its arguments
 boolean deepEquals(FunctionItem other, XPathContext context, GenericAtomicComparer comparer, int flags)
          Test whether this FunctionItem is deep-equal to another function item, under the rules of the deep-equal function
 void explain(ExpressionPresenter out)
           
 String getStringValue()
          Get the string value of the function item
 CharSequence getStringValueCS()
          Get the string value of the function item
 SequenceIterator getTypedValue()
          Get the typed value of the item.
 void optimize(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType)
          Optimize the function (may modify it)
 void simplify(ExpressionVisitor visitor)
           
 void typeCheck(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType)
          Type check the function (may modify it by adding code for converting the arguments)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.om.FunctionItem
getArity, getFunctionItemType, getFunctionName, invoke
 

Constructor Detail

AbstractFunctionItem

public AbstractFunctionItem()
Method Detail

getStringValue

public String getStringValue()
Get the string value of the function item

Specified by:
getStringValue in interface Item
Specified by:
getStringValue in interface ValueRepresentation
Returns:
the string value of the item
Throws:
UnsupportedOperationException - (the string value of a function item is not defined)
See Also:
Item.getStringValueCS()

getStringValueCS

public CharSequence getStringValueCS()
Get the string value of the function item

Specified by:
getStringValueCS in interface Item
Specified by:
getStringValueCS in interface ValueRepresentation
Returns:
the string value of the item
Throws:
UnsupportedOperationException - (the string value of a function item is not defined)
See Also:
Item.getStringValue()

getTypedValue

public SequenceIterator getTypedValue()
                               throws XPathException
Get the typed value of the item.

Specified by:
getTypedValue in interface Item
Returns:
an iterator over the items in the typed value of the node or atomic value. The items returned by this iterator will always be atomic values.
Throws:
XPathException - (always) - a function item cannot be atomized

simplify

public void simplify(ExpressionVisitor visitor)
              throws XPathException
Throws:
XPathException

typeCheck

public void typeCheck(ExpressionVisitor visitor,
                      ExpressionVisitor.ContextItemType contextItemType)
               throws XPathException
Type check the function (may modify it by adding code for converting the arguments)

Parameters:
visitor - the expression visitor, supplies context information
contextItemType - the context item type at the point where the function definition appears
Throws:
XPathException

optimize

public void optimize(ExpressionVisitor visitor,
                     ExpressionVisitor.ContextItemType contextItemType)
              throws XPathException
Optimize the function (may modify it)

Parameters:
visitor - the expression visitor, supplies context information
contextItemType - the context item type at the point where the function definition appears
Throws:
XPathException

curry

public FunctionItem curry(ValueRepresentation[] values)
                   throws XPathException
Curry a function by binding one or more (but not all) of its arguments

Specified by:
curry in interface FunctionItem
Parameters:
values - the values to which the arguments are to be bound
Returns:
a new function item in which the specified arguments of the original function is bound to a value
Throws:
XPathException - if any dynamic error occurs

bind

public static AbstractFunctionItem bind(StructuredQName functionName,
                                        int arity,
                                        StaticContext env,
                                        Container container)
                                 throws XPathException
Factory method to create a function item representing a function item literal

Parameters:
functionName - the name of the function to be called
arity - the arity of the function
env - the static context of the function item literal
Returns:
the constructed function item
Throws:
XPathException - for example if there is no function with the specified name and arity in the static context

explain

public void explain(ExpressionPresenter out)

deepEquals

public boolean deepEquals(FunctionItem other,
                          XPathContext context,
                          GenericAtomicComparer comparer,
                          int flags)
                   throws XPathException
Test whether this FunctionItem is deep-equal to another function item, under the rules of the deep-equal function

Specified by:
deepEquals in interface FunctionItem
Parameters:
other - the other function item
context - the dynamic evaluation context
comparer - the object to perform the comparison
flags - options for how the comparison is performed
Returns:
true if the two function items are deep-equal
Throws:
XPathException - if the comparison cannot be performed


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