net.sf.saxon.om
Interface FunctionItem<T extends FunctionItem>

All Superinterfaces:
Item<T>, PullEvent, ValueRepresentation<T>
All Known Subinterfaces:
MapItem
All Known Implementing Classes:
AbstractFunctionItem, CoercedFunction, CurriedFunction, FirstClassFunction, ImmutableMap, SingletonMap, UserFunctionItem

public interface FunctionItem<T extends FunctionItem>
extends Item<T>, ValueRepresentation<T>

XDM 3.0 introduces a third kind of item, beyond nodes and atomic values: the function item. Function items implement this marker interface. The actual implementation class is in Saxon-PE and Saxon-EE only.


Field Summary
 
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
 
Method Summary
 FunctionItem curry(ValueRepresentation<? extends Item>[] 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
 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<? extends Item> invoke(SequenceIterator<? extends Item>[] args, XPathContext context)
          Invoke the function
 
Methods inherited from interface net.sf.saxon.om.Item
getStringValue, getStringValueCS, getTypedValue
 

Method Detail

getFunctionItemType

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

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

getFunctionName

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

Returns:
the function name, or null for an anonymous inline function

getArity

int getArity()
Get the arity of the function

Returns:
the number of arguments in the function signature

invoke

SequenceIterator<? extends Item> invoke(SequenceIterator<? extends Item>[] 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 - if a dynamic error occurs within the function

curry

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

Parameters:
values - the values to which the arguments are to be bound, representing an unbound argument (a placeholder) by null
Returns:
a new function item in which the specified arguments of the original function are bound to a value
Throws:
XPathException - if any dynamic error occurs

deepEquals

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

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.