com.saxonica.functions.map
Class MapType

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

public class MapType
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
static MapType ANY_MAP_TYPE
           
 
Fields inherited from class net.sf.saxon.type.AnyFunctionType
ANY_FUNCTION, SINGLE_FUNCTION
 
Constructor Summary
MapType(AtomicType keyType, SequenceType valueType)
           
 
Method Summary
 boolean equals(Object other)
          Test whether this function type equals another function type
 SequenceType[] getArgumentTypes()
          Get the argument types of this map, viewed as a function
 int getArity()
          Get the arity (number of arguments) of this function type
 SequenceType getResultType()
          Get the result type of this map, viewed as a function
 ItemType getSuperType(TypeHierarchy th)
          Get the type from which this item type is derived by restriction.
 int hashCode()
          Returns a hash code value for the object.
 boolean isMapType()
          Ask whether this function item type is a map type.
 Expression makeFunctionSequenceCoercer(Expression exp, RoleLocator role, TypeCheckerEnvironment 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.
 void visitNamedSchemaComponents(SchemaComponentVisitor visitor)
          Visit all the schema components used in this ItemType definition
 
Methods inherited from class net.sf.saxon.type.AnyFunctionType
getAtomizedItemType, getDefaultPriority, getInstance, getPrimitiveItemType, getPrimitiveType, isAtomicType, isAtomizable, isPlainType, matches
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ANY_MAP_TYPE

public static final MapType ANY_MAP_TYPE
Constructor Detail

MapType

public MapType(AtomicType keyType,
               SequenceType valueType)
Method Detail

isMapType

public boolean isMapType()
Ask whether this function item type is a map type. In this case function coercion (to the map type) will never succeed.

Specified by:
isMapType in interface FunctionItemType
Overrides:
isMapType in class AnyFunctionType
Returns:
true if this FunctionItemType is a map type

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 of this map, viewed as a function

Specified by:
getArgumentTypes in interface FunctionItemType
Overrides:
getArgumentTypes in class AnyFunctionType
Returns:
the list of argument types of this map, viewed as a function

getResultType

public SequenceType getResultType()
Get the result type of this map, viewed as a function

Specified by:
getResultType in interface FunctionItemType
Overrides:
getResultType in class AnyFunctionType
Returns:
the result type of this map, viewed as a function

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 - true if promotion from URI to string is allowed
config - the Saxon configuration
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

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode 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,
                                              TypeCheckerEnvironment 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

visitNamedSchemaComponents

public void visitNamedSchemaComponents(SchemaComponentVisitor visitor)
                                throws XPathException
Visit all the schema components used in this ItemType definition

Specified by:
visitNamedSchemaComponents in interface ItemType
Overrides:
visitNamedSchemaComponents in class AnyFunctionType
Parameters:
visitor - the visitor class to be called when each component is visited
Throws:
XPathException - if an error occurs


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