com.saxonica.hof
Class FunctionType

java.lang.Object
  extended by net.sf.saxon.type.AnyFunctionType
      extended by com.saxonica.hof.FunctionType
All Implemented Interfaces:
Serializable, FunctionItemType, ItemType

public class FunctionType
extends AnyFunctionType

An instance of this class represents a specific function item type, for example function(xs:int) as xs:boolean

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.type.AnyFunctionType
ANY_FUNCTION, SINGLE_FUNCTION
 
Constructor Summary
FunctionType(SequenceType[] argTypes, SequenceType resultType)
           
 
Method Summary
 boolean equals(Object other)
          Test whether this function type equals another function type
 SequenceType[] getArgumentTypes()
          Get the argument types
 int getArity()
          Get the arity (number of arguments) of this function type
 SequenceType getResultType()
          Get the result type
 ItemType getSuperType(TypeHierarchy th)
          Get the type from which this item type is derived by restriction.
 Expression makeFunctionSequenceCoercer(Expression exp, RoleLocator role, ExpressionVisitor visitor)
          Create an expression whose effect is to apply function coercion to coerce a function from this type to another type
 boolean matchesItem(Item item, boolean allowURIPromotion, Configuration config)
          Test whether a given item conforms to this type
 int relationship(FunctionItemType other, TypeHierarchy th)
          Determine the relationship of one function item type to another
 String toString()
          Produce a representation of this type name for use in error messages.
 String toString(NamePool pool)
          Produce a representation of this type name for use in error messages.
 
Methods inherited from class net.sf.saxon.type.AnyFunctionType
getAtomizedItemType, getInstance, getPrimitiveItemType, getPrimitiveType, isAtomicType, isAtomizable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FunctionType

public FunctionType(SequenceType[] argTypes,
                    SequenceType resultType)
Method Detail

getArity

public int getArity()
Get the arity (number of arguments) of this function type

Returns:
the number of argument types in the function signature

getArgumentTypes

public SequenceType[] getArgumentTypes()
Get the argument types

Returns:
the list of argument types

getResultType

public SequenceType getResultType()
Get the result type

Returns:
the result type

matchesItem

public boolean matchesItem(Item item,
                           boolean allowURIPromotion,
                           Configuration config)
Test whether a given item conforms to this type

Specified by:
matchesItem in interface ItemType
Overrides:
matchesItem in class AnyFunctionType
Parameters:
item - The item to be tested
allowURIPromotion -
config -
Returns:
true if the item is an instance of this type; false otherwise

getSuperType

public ItemType getSuperType(TypeHierarchy th)
Get the type from which this item type is derived by restriction. This is the supertype in the XPath type heirarchy, as distinct from the Schema base type: this means that the supertype of xs:boolean is xs:anyAtomicType, whose supertype is item() (rather than xs:anySimpleType).

In fact the concept of "supertype" is not really well-defined, because the types form a lattice rather than a hierarchy. The only real requirement on this function is that it returns a type that strictly subsumes this type, ideally as narrowly as possible.

Specified by:
getSuperType in interface ItemType
Overrides:
getSuperType in class AnyFunctionType
Parameters:
th - the type hierarchy cache
Returns:
the supertype, or null if this type is item()

toString

public String toString(NamePool pool)
Produce a representation of this type name for use in error messages. Where this is a QName, it will use conventional prefixes

Specified by:
toString in interface ItemType
Overrides:
toString in class AnyFunctionType
Parameters:
pool - the name pool
Returns:
a string representation of the type, in notation resembling but not necessarily identical to XPath syntax

toString

public String toString()
Produce a representation of this type name for use in error messages.

Overrides:
toString in class AnyFunctionType
Returns:
a string representation of the type, in notation resembling but not necessarily identical to XPath syntax

equals

public boolean equals(Object other)
Test whether this function type equals another function type

Overrides:
equals in class Object

relationship

public int relationship(FunctionItemType other,
                        TypeHierarchy th)
Determine the relationship of one function item type to another

Specified by:
relationship in interface FunctionItemType
Overrides:
relationship in class AnyFunctionType
Returns:
for example TypeHierarchy.SUBSUMES, TypeHierarchy.SAME_TYPE

makeFunctionSequenceCoercer

public Expression makeFunctionSequenceCoercer(Expression exp,
                                              RoleLocator role,
                                              ExpressionVisitor visitor)
                                       throws XPathException
Description copied from class: AnyFunctionType
Create an expression whose effect is to apply function coercion to coerce a function from this type to another type

Specified by:
makeFunctionSequenceCoercer in interface FunctionItemType
Overrides:
makeFunctionSequenceCoercer in class AnyFunctionType
Parameters:
exp - the expression that delivers the supplied sequence of function items (the ones in need of coercion)
role - information for use in diagnostics
visitor - the expression visitor, supplies context information
Returns:
the coerced function, a function that calls the original function after checking the parameters
Throws:
XPathException


Copyright (c) Saxonica Limited. All rights reserved.