Package net.sf.saxon.ma.map
Class MapType
java.lang.Object
net.sf.saxon.type.AnyFunctionType
net.sf.saxon.ma.map.MapType
- All Implemented Interfaces:
FunctionItemType
,ItemType
An instance of this class represents a specific map item type, for example
map(x:integer, element(employee))
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.sf.saxon.type.ItemType
ItemType.WithSequenceTypeCache
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MapType
static final MapType
static final SequenceType
A type that allows a sequence of zero or one map itemsstatic final SequenceType
static final SequenceType
Fields inherited from class net.sf.saxon.type.AnyFunctionType
ANY_FUNCTION
-
Constructor Summary
ConstructorsConstructorDescriptionMapType
(AtomicType keyType, SequenceType valueType) MapType
(AtomicType keyType, SequenceType valueType, boolean mustBeEmpty) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Test whether this function type equals another function typeexplainMismatch
(Item item, TypeHierarchy th) Get extra diagnostic information about why a supplied item does not conform to this item type, if available.Get the argument types of this map, viewed as a functionint
getArity()
Get the arity (number of arguments) of this function typeGet an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived.double
Get the default priority when this ItemType is used as an XSLT patterngetGenre()
Determine the Genre (top-level classification) of this typeGet the type of the keysGet the result type of this map, viewed as a functionGet the type of the indexed valuesint
hashCode()
Returns a hash code value for the object.boolean
Ask whether this function item type is an array type.boolean
Ask whether values of this type are atomizableboolean
Ask whether this function item type is a map type.makeFunctionSequenceCoercer
(Expression exp, RoleDiagnostic role) Create an expression whose effect is to apply function coercion to coerce a function from this type to another typeboolean
matches
(Item item, TypeHierarchy th) Test whether a given item conforms to this typerelationship
(FunctionItemType other, TypeHierarchy th) Determine the relationship of one function item type to anotherReturn a string representation of this ItemType suitable for use in stylesheet export files.toString()
Produce a representation of this type name for use in error messages.Methods inherited from class net.sf.saxon.type.AnyFunctionType
getAnnotationAssertions, getAtomizedItemType, getInstance, getPrimitiveItemType, getPrimitiveType, getUType, isAtomicType, isPlainType
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.saxon.type.ItemType
getFullAlphaCode, getNormalizedDefaultPriority, isTrueItemType
-
Field Details
-
ANY_MAP_TYPE
-
EMPTY_MAP_TYPE
-
OPTIONAL_MAP_ITEM
A type that allows a sequence of zero or one map items -
SINGLE_MAP_ITEM
-
SEQUENCE_OF_MAPS
-
-
Constructor Details
-
MapType
-
MapType
-
-
Method Details
-
getGenre
Determine the Genre (top-level classification) of this type- Returns:
- the Genre to which this type belongs, specifically
Genre.MAP
-
getKeyType
Get the type of the keys- Returns:
- the type to which all keys must conform
-
getValueType
Get the type of the indexed values- Returns:
- the type to which all associated values must conform
-
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 interfaceFunctionItemType
- Overrides:
isMapType
in classAnyFunctionType
- Returns:
- true if this FunctionItemType is a map type
-
isArrayType
public boolean isArrayType()Ask whether this function item type is an array type. In this case function coercion (to the array type) will never succeed.- Specified by:
isArrayType
in interfaceFunctionItemType
- Overrides:
isArrayType
in classAnyFunctionType
- Returns:
- true if this FunctionItemType is an array type
-
getBasicAlphaCode
Get an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived. The codes are designed so that for any two built-in types A and B, alphaCode(A) is a prefix of alphaCode(B) if and only if A is a supertype of B.- Specified by:
getBasicAlphaCode
in interfaceItemType
- Overrides:
getBasicAlphaCode
in classAnyFunctionType
- Returns:
- the alphacode for the nearest containing built-in type
-
isAtomizable
Ask whether values of this type are atomizable- Specified by:
isAtomizable
in interfaceItemType
- Overrides:
isAtomizable
in classAnyFunctionType
- Parameters:
th
- The type hierarchy cache- Returns:
- true if some or all instances of this type can be successfully atomized; false * if no instances of this type can be atomized
-
getDefaultPriority
public double getDefaultPriority()Get the default priority when this ItemType is used as an XSLT pattern- Specified by:
getDefaultPriority
in interfaceItemType
- Overrides:
getDefaultPriority
in classAnyFunctionType
- Returns:
- the default priority
-
matches
Test whether a given item conforms to this type- Specified by:
matches
in interfaceItemType
- Overrides:
matches
in classAnyFunctionType
- Parameters:
item
- The item to be testedth
-- Returns:
- true if the item is an instance of this type; false otherwise
-
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
Get the argument types of this map, viewed as a function- Specified by:
getArgumentTypes
in interfaceFunctionItemType
- Overrides:
getArgumentTypes
in classAnyFunctionType
- Returns:
- the list of argument types of this map, viewed as a function
-
getResultType
Get the result type of this map, viewed as a function- Specified by:
getResultType
in interfaceFunctionItemType
- Overrides:
getResultType
in classAnyFunctionType
- Returns:
- the result type of this map, viewed as a function
-
toString
Produce a representation of this type name for use in error messages.- Specified by:
toString
in interfaceItemType
- Overrides:
toString
in classAnyFunctionType
- Returns:
- a string representation of the type, in notation resembling but not necessarily identical to XPath syntax
-
toExportString
Return a string representation of this ItemType suitable for use in stylesheet export files. This differs from the result of toString() in that it will not contain any references to anonymous types. Note that it may also use the Saxon extended syntax for union types and tuple types. The default implementation returns the result of calling#toString()
.- Returns:
- the string representation as an instance of the XPath SequenceType construct
-
equals
Test whether this function type equals another function type -
hashCode
public int hashCode()Returns a hash code value for the object. -
relationship
Determine the relationship of one function item type to another- Specified by:
relationship
in interfaceFunctionItemType
- Overrides:
relationship
in classAnyFunctionType
- Returns:
- for example
Affinity.SUBSUMES
,Affinity.SAME_TYPE
-
explainMismatch
Get extra diagnostic information about why a supplied item does not conform to this item type, if available. If extra information is returned, it should be in the form of a complete sentence, minus the closing full stop. No information should be returned for obvious cases.- Parameters:
item
- the item that doesn't match this typeth
- the type hierarchy cache- Returns:
- optionally, a message explaining why the item does not match the type
-
makeFunctionSequenceCoercer
public Expression makeFunctionSequenceCoercer(Expression exp, RoleDiagnostic role) 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 interfaceFunctionItemType
- Overrides:
makeFunctionSequenceCoercer
in classAnyFunctionType
- Parameters:
exp
- the expression that delivers the supplied sequence of function items (the ones in need of coercion)role
- information for use in diagnostics- Returns:
- the sequence of coerced functions, each on a function that calls the corresponding original function after checking the parameters
- Throws:
XPathException
-