Class TupleItemType

java.lang.Object
net.sf.saxon.type.AnyFunctionType
net.sf.saxon.ma.map.TupleItemType
All Implemented Interfaces:
TupleType, FunctionItemType, ItemType

public class TupleItemType extends AnyFunctionType implements TupleType
An instance of this class represents a specific tuple item type, for example tuple(x as xs:double, y as element(employee)). Tuple types are a Saxon extension introduced in Saxon 9.8. The syntax for constructing a tuple type requires Saxon-PE or higher, but the supporting code is included in Saxon-HE for convenience. Extended in 10.0 to distinguish extensible vs non-extensible tuple types. Extensible tuple types permit fields other than those listed to appear; non-extensible tuple types do not. An extensible tuple type is denoted by tuple(... ,*).
  • Constructor Details

  • Method Details

    • getGenre

      public Genre getGenre()
      Determine the Genre (top-level classification) of this type
      Specified by:
      getGenre in interface FunctionItemType
      Specified by:
      getGenre in interface ItemType
      Returns:
      the Genre to which this type belongs, specifically Genre.MAP
    • 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
    • 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 interface FunctionItemType
      Overrides:
      isArrayType in class AnyFunctionType
      Returns:
      true if this FunctionItemType is an array type
    • getFieldNames

      public Iterable<String> getFieldNames()
      Get the names of all the fields
      Specified by:
      getFieldNames in interface TupleType
      Returns:
      the names of the fields (in arbitrary order)
    • getFieldType

      public SequenceType getFieldType(String field)
      Get the type of a given field
      Specified by:
      getFieldType in interface TupleType
      Parameters:
      field - the name of the field
      Returns:
      the type of the field if it is defined, or null otherwise
    • isExtensible

      public boolean isExtensible()
      Ask whether the tuple type is extensible, that is, whether fields other than those named are permitted
      Specified by:
      isExtensible in interface TupleType
      Returns:
      true if fields other than the named fields are permitted to appear
    • matches

      public boolean matches(Item item, TypeHierarchy th) throws XPathException
      Test whether a given item conforms to this type
      Specified by:
      matches in interface ItemType
      Overrides:
      matches in class AnyFunctionType
      Parameters:
      item - The item to be tested
      th - type hierarchy data
      Returns:
      true if the item is an instance of this type; false otherwise
      Throws:
      XPathException
    • 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 tuple type, viewed as a function
      Specified by:
      getResultType in interface FunctionItemType
      Overrides:
      getResultType in class AnyFunctionType
      Returns:
      the result type of this tuple type, viewed as a function
    • getDefaultPriority

      public double getDefaultPriority()
      Get the default priority when this ItemType is used as an XSLT pattern
      Specified by:
      getDefaultPriority in interface ItemType
      Overrides:
      getDefaultPriority in class AnyFunctionType
      Returns:
      the default priority
    • toString

      public String toString()
      Produce a representation of this type name for use in error messages.
      Specified by:
      toString in interface ItemType
      Overrides:
      toString in class AnyFunctionType
      Returns:
      a string representation of the type, in notation resembling but not necessarily identical to XPath syntax
    • toExportString

      public String 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.
      Specified by:
      toExportString in interface ItemType
      Returns:
      the string representation as an instance of the XPath ItemType construct
    • getBasicAlphaCode

      public String 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 interface ItemType
      Overrides:
      getBasicAlphaCode in class AnyFunctionType
      Returns:
      the alphacode for the nearest containing built-in type
    • 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 Affinity 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 Affinity.SUBSUMES, Affinity.SAME_TYPE
    • explainMismatch

      public Optional<String> explainMismatch(Item item, TypeHierarchy th)
      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.
      Specified by:
      explainMismatch in interface ItemType
      Parameters:
      item - the item being matched
      th - 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 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
      Returns:
      the sequence of coerced functions, each on a function that calls the corresponding original function after checking the parameters
      Throws:
      XPathException