net.sf.saxon.type

Class Type

public abstract class Type extends Object implements Serializable

This class contains static information about types and methods for constructing type codes. The class is never instantiated.
Field Summary
static intANY_ATOMIC
Constant denoting any atomic type (the union of all primitive types and types derived from primitive types by restriction or by union)
static BuiltInAtomicTypeANY_ATOMIC_TYPE
static intANY_SIMPLE_TYPE
static intANY_URI
Item type representing the type xs:anyURI
static BuiltInAtomicTypeANY_URI_TYPE
static shortATTRIBUTE
Item type representing an attribute node - attribute()
static intBASE64_BINARY
Item type representing the type xs:base64Binary
static BuiltInAtomicTypeBASE64_BINARY_TYPE
static intBOOLEAN
Item type representing the type xs:boolean
static BuiltInAtomicTypeBOOLEAN_TYPE
static intBYTE
Item type representing the type xs:byte
static shortCOMMENT
Item type representing a comment node
static intDATE
Item type representing the type xs:date
static intDATE_TIME
Item type representing the type xs:dateTime
static BuiltInAtomicTypeDATE_TIME_TYPE
static BuiltInAtomicTypeDATE_TYPE
static intDAY_TIME_DURATION
Item type representing the type xdt:dayTimeDuration
static BuiltInAtomicTypeDAY_TIME_DURATION_TYPE
static intDECIMAL
Item type representing the type xs:decimal
static BuiltInAtomicTypeDECIMAL_TYPE
static shortDOCUMENT
Item type representing a document node
static intDOUBLE
Item type representing the type xs:double
static BuiltInAtomicTypeDOUBLE_TYPE
static intDURATION
Item type representing the type xs:duration
static BuiltInAtomicTypeDURATION_TYPE
static shortELEMENT
Type representing an element node - element()
static shortEMPTY
Item type that matches no items (corresponds to SequenceType empty())
static intENTITY
Item type representing the type xs:ENTITY
static intFLOAT
Item type representing the type xs:float
static BuiltInAtomicTypeFLOAT_TYPE
static intG_DAY
Item type representing the type xs:gDay
static BuiltInAtomicTypeG_DAY_TYPE
static intG_MONTH
Item type representing the type xs:gMonth
static intG_MONTH_DAY
Item type representing the type xs:monthDay
static BuiltInAtomicTypeG_MONTH_DAY_TYPE
static BuiltInAtomicTypeG_MONTH_TYPE
static intG_YEAR
Item type representing the type xs:gYear
static intG_YEAR_MONTH
Item type representing the type xs:gYearMonth
static BuiltInAtomicTypeG_YEAR_MONTH_TYPE
static BuiltInAtomicTypeG_YEAR_TYPE
static intHEX_BINARY
Item type representing the type xs:hexBinary
static BuiltInAtomicTypeHEX_BINARY_TYPE
static intID
Item type representing the type xs:ID
static intIDREF
Item type representing the type xs:IDREF
static intIDREFS
Content type representing the complex type xs:IDREFS
static BuiltInAtomicTypeID_TYPE
static intINT
Item type representing the type xs:int
static intINTEGER
Item type representing the type xs:integer
static BuiltInAtomicTypeINTEGER_TYPE
static shortITEM
An item type that matches any item
static ItemTypeITEM_TYPE
static intLANGUAGE
Item type representing the type xs:language
static intLONG
Item type representing the type xs:long
static shortMAX_NODE_TYPE
static intNAME
Item type representing the type xs:NAME
static shortNAMESPACE
Item type representing a namespace node
static intNCNAME
Item type representing the type xs:NCNAME
static BuiltInAtomicTypeNCNAME_TYPE
static intNEGATIVE_INTEGER
Item type representing the type xs:negativeInteger
static intNMTOKEN
Item type representing the type xs:NMTOKEN
static intNMTOKENS
Content type representing the complex type xs:NMTOKENS
static shortNODE
An item type that matches any node
static ItemTypeNODE_TYPE
static intNON_NEGATIVE_INTEGER
Item type representing the type xs:nonNegativeInteger
static intNON_POSITIVE_INTEGER
Item type representing the type xs:nonPositiveInteger
static intNORMALIZED_STRING
Item type representing the type xs:normalizedString
static intNOTATION
Item type representing the type xs:NOTATION
static BuiltInAtomicTypeNOTATION_TYPE
static intNUMBER
Constant denoting any numeric type (the union of float, double, and decimal)
static BuiltInAtomicTypeNUMBER_TYPE
static intOBJECT
Constant representing the type of an external object (for use by extension functions)
static shortPARENT_POINTER
Dummy node kind used in the tiny tree to contain a parent pointer
static intPOSITIVE_INTEGER
Item type representing the type xs:positiveInteger
static shortPROCESSING_INSTRUCTION
Item type representing a processing-instruction node
static intQNAME
Item type representing the type xs:QName
static BuiltInAtomicTypeQNAME_TYPE
static intSHORT
Item type representing the type xs:short
static shortSTOPPER
Dummy node kind used in the tiny tree to mark the end of the tree
static intSTRING
Constants representing primitive data types defined in Schema Part 2
static BuiltInAtomicTypeSTRING_TYPE
static shortTEXT
Item type representing a text node - text()
static intTIME
Item type representing the type xs:time
static BuiltInAtomicTypeTIME_TYPE
static intTOKEN
Item type representing the type xs:token
static intUNSIGNED_BYTE
Item type representing the type xs:unsignedByte
static intUNSIGNED_INT
Item type representing the type xs:unsignedInt
static intUNSIGNED_LONG
Item type representing the type xs:unsignedLong
static intUNSIGNED_SHORT
Item type representing the type xs:unsignedShort
static intUNTYPED_ATOMIC
Item type representing the type xdt:untypedAtomic (the type of the content of a schema-less node)
static BuiltInAtomicTypeUNTYPED_ATOMIC_TYPE
static shortWHITESPACE_TEXT
Item type representing a text node stored in the tiny tree as compressed whitespace
static intYEAR_MONTH_DURATION
Item type representing the type xdt:yearMonthDuration
static BuiltInAtomicTypeYEAR_MONTH_DURATION_TYPE
Method Summary
static StringdisplayTypeName(Item item)
Output (for diagnostics) a representation of the type of an item.
static ItemTypegetBuiltInItemType(String namespace, String localName)
Get the SimpleType object for a built-in simple type code
static ItemTypegetCommonSuperType(ItemType t1, ItemType t2, TypeHierarchy th)
Get a type that is a common supertype of two given types
static ItemTypegetItemType(Item item)
Get the ItemType of an Item
static booleanisComparable(int t1, int t2, boolean ordered)
Determine whether two primitive atomic types are comparable
static booleanisNodeType(ItemType type)
Test whether a given type is (some subtype of) node()
static booleanisNumericPrimitiveType(ItemType t)
Test whether the supplied type, which must be a primitive type, is one of the numeric primitive types
static booleanisOrdered(int type)
Determine whether a primitive type is ordered.
static booleanisPrimitiveType(int code)
Determine whether this type is a primitive type.
static intschemaTypeRelationship(SchemaType s1, SchemaType s2)
Get the relationship of two schema types to each other

Field Detail

ANY_ATOMIC

public static final int ANY_ATOMIC
Constant denoting any atomic type (the union of all primitive types and types derived from primitive types by restriction or by union)

ANY_ATOMIC_TYPE

public static final BuiltInAtomicType ANY_ATOMIC_TYPE

ANY_SIMPLE_TYPE

public static final int ANY_SIMPLE_TYPE

ANY_URI

public static final int ANY_URI
Item type representing the type xs:anyURI

ANY_URI_TYPE

public static final BuiltInAtomicType ANY_URI_TYPE

ATTRIBUTE

public static final short ATTRIBUTE
Item type representing an attribute node - attribute()

BASE64_BINARY

public static final int BASE64_BINARY
Item type representing the type xs:base64Binary

BASE64_BINARY_TYPE

public static final BuiltInAtomicType BASE64_BINARY_TYPE

BOOLEAN

public static final int BOOLEAN
Item type representing the type xs:boolean

BOOLEAN_TYPE

public static final BuiltInAtomicType BOOLEAN_TYPE

BYTE

public static final int BYTE
Item type representing the type xs:byte

COMMENT

public static final short COMMENT
Item type representing a comment node

DATE

public static final int DATE
Item type representing the type xs:date

DATE_TIME

public static final int DATE_TIME
Item type representing the type xs:dateTime

DATE_TIME_TYPE

public static final BuiltInAtomicType DATE_TIME_TYPE

DATE_TYPE

public static final BuiltInAtomicType DATE_TYPE

DAY_TIME_DURATION

public static final int DAY_TIME_DURATION
Item type representing the type xdt:dayTimeDuration

DAY_TIME_DURATION_TYPE

public static final BuiltInAtomicType DAY_TIME_DURATION_TYPE

DECIMAL

public static final int DECIMAL
Item type representing the type xs:decimal

DECIMAL_TYPE

public static final BuiltInAtomicType DECIMAL_TYPE

DOCUMENT

public static final short DOCUMENT
Item type representing a document node

DOUBLE

public static final int DOUBLE
Item type representing the type xs:double

DOUBLE_TYPE

public static final BuiltInAtomicType DOUBLE_TYPE

DURATION

public static final int DURATION
Item type representing the type xs:duration

DURATION_TYPE

public static final BuiltInAtomicType DURATION_TYPE

ELEMENT

public static final short ELEMENT
Type representing an element node - element()

EMPTY

public static final short EMPTY
Item type that matches no items (corresponds to SequenceType empty())

ENTITY

public static final int ENTITY
Item type representing the type xs:ENTITY

FLOAT

public static final int FLOAT
Item type representing the type xs:float

FLOAT_TYPE

public static final BuiltInAtomicType FLOAT_TYPE

G_DAY

public static final int G_DAY
Item type representing the type xs:gDay

G_DAY_TYPE

public static final BuiltInAtomicType G_DAY_TYPE

G_MONTH

public static final int G_MONTH
Item type representing the type xs:gMonth

G_MONTH_DAY

public static final int G_MONTH_DAY
Item type representing the type xs:monthDay

G_MONTH_DAY_TYPE

public static final BuiltInAtomicType G_MONTH_DAY_TYPE

G_MONTH_TYPE

public static final BuiltInAtomicType G_MONTH_TYPE

G_YEAR

public static final int G_YEAR
Item type representing the type xs:gYear

G_YEAR_MONTH

public static final int G_YEAR_MONTH
Item type representing the type xs:gYearMonth

G_YEAR_MONTH_TYPE

public static final BuiltInAtomicType G_YEAR_MONTH_TYPE

G_YEAR_TYPE

public static final BuiltInAtomicType G_YEAR_TYPE

HEX_BINARY

public static final int HEX_BINARY
Item type representing the type xs:hexBinary

HEX_BINARY_TYPE

public static final BuiltInAtomicType HEX_BINARY_TYPE

ID

public static final int ID
Item type representing the type xs:ID

IDREF

public static final int IDREF
Item type representing the type xs:IDREF

IDREFS

public static final int IDREFS
Content type representing the complex type xs:IDREFS

ID_TYPE

public static final BuiltInAtomicType ID_TYPE

INT

public static final int INT
Item type representing the type xs:int

INTEGER

public static final int INTEGER
Item type representing the type xs:integer

INTEGER_TYPE

public static final BuiltInAtomicType INTEGER_TYPE

ITEM

public static final short ITEM
An item type that matches any item

ITEM_TYPE

public static final ItemType ITEM_TYPE

LANGUAGE

public static final int LANGUAGE
Item type representing the type xs:language

LONG

public static final int LONG
Item type representing the type xs:long

MAX_NODE_TYPE

public static final short MAX_NODE_TYPE

NAME

public static final int NAME
Item type representing the type xs:NAME

NAMESPACE

public static final short NAMESPACE
Item type representing a namespace node

NCNAME

public static final int NCNAME
Item type representing the type xs:NCNAME

NCNAME_TYPE

public static final BuiltInAtomicType NCNAME_TYPE

NEGATIVE_INTEGER

public static final int NEGATIVE_INTEGER
Item type representing the type xs:negativeInteger

NMTOKEN

public static final int NMTOKEN
Item type representing the type xs:NMTOKEN

NMTOKENS

public static final int NMTOKENS
Content type representing the complex type xs:NMTOKENS

NODE

public static final short NODE
An item type that matches any node

NODE_TYPE

public static final ItemType NODE_TYPE

NON_NEGATIVE_INTEGER

public static final int NON_NEGATIVE_INTEGER
Item type representing the type xs:nonNegativeInteger

NON_POSITIVE_INTEGER

public static final int NON_POSITIVE_INTEGER
Item type representing the type xs:nonPositiveInteger

NORMALIZED_STRING

public static final int NORMALIZED_STRING
Item type representing the type xs:normalizedString

NOTATION

public static final int NOTATION
Item type representing the type xs:NOTATION

NOTATION_TYPE

public static final BuiltInAtomicType NOTATION_TYPE

NUMBER

public static final int NUMBER
Constant denoting any numeric type (the union of float, double, and decimal)

NUMBER_TYPE

public static final BuiltInAtomicType NUMBER_TYPE

OBJECT

public static final int OBJECT
Constant representing the type of an external object (for use by extension functions)

PARENT_POINTER

public static final short PARENT_POINTER
Dummy node kind used in the tiny tree to contain a parent pointer

POSITIVE_INTEGER

public static final int POSITIVE_INTEGER
Item type representing the type xs:positiveInteger

PROCESSING_INSTRUCTION

public static final short PROCESSING_INSTRUCTION
Item type representing a processing-instruction node

QNAME

public static final int QNAME
Item type representing the type xs:QName

QNAME_TYPE

public static final BuiltInAtomicType QNAME_TYPE

SHORT

public static final int SHORT
Item type representing the type xs:short

STOPPER

public static final short STOPPER
Dummy node kind used in the tiny tree to mark the end of the tree

STRING

public static final int STRING
Constants representing primitive data types defined in Schema Part 2

STRING_TYPE

public static final BuiltInAtomicType STRING_TYPE

TEXT

public static final short TEXT
Item type representing a text node - text()

TIME

public static final int TIME
Item type representing the type xs:time

TIME_TYPE

public static final BuiltInAtomicType TIME_TYPE

TOKEN

public static final int TOKEN
Item type representing the type xs:token

UNSIGNED_BYTE

public static final int UNSIGNED_BYTE
Item type representing the type xs:unsignedByte

UNSIGNED_INT

public static final int UNSIGNED_INT
Item type representing the type xs:unsignedInt

UNSIGNED_LONG

public static final int UNSIGNED_LONG
Item type representing the type xs:unsignedLong

UNSIGNED_SHORT

public static final int UNSIGNED_SHORT
Item type representing the type xs:unsignedShort

UNTYPED_ATOMIC

public static final int UNTYPED_ATOMIC
Item type representing the type xdt:untypedAtomic (the type of the content of a schema-less node)

UNTYPED_ATOMIC_TYPE

public static final BuiltInAtomicType UNTYPED_ATOMIC_TYPE

WHITESPACE_TEXT

public static final short WHITESPACE_TEXT
Item type representing a text node stored in the tiny tree as compressed whitespace

YEAR_MONTH_DURATION

public static final int YEAR_MONTH_DURATION
Item type representing the type xdt:yearMonthDuration

YEAR_MONTH_DURATION_TYPE

public static final BuiltInAtomicType YEAR_MONTH_DURATION_TYPE

Method Detail

displayTypeName

public static final String displayTypeName(Item item)
Output (for diagnostics) a representation of the type of an item. This does not have to be the most specific type

getBuiltInItemType

public static ItemType getBuiltInItemType(String namespace, String localName)
Get the SimpleType object for a built-in simple type code

Returns: the SimpleType, or null if not found

getCommonSuperType

public static final ItemType getCommonSuperType(ItemType t1, ItemType t2, TypeHierarchy th)
Get a type that is a common supertype of two given types

Parameters: t1 the first item type t2 the second item type th

Returns: the item type that is a supertype of both the supplied item types

getItemType

public static ItemType getItemType(Item item)
Get the ItemType of an Item

isComparable

public static boolean isComparable(int t1, int t2, boolean ordered)
Determine whether two primitive atomic types are comparable

Parameters: t1 the first type to compared. This must be a primitive atomic type as defined by ItemType t2 the second type to compared. This must be a primitive atomic type as defined by ItemType ordered true if testing for an ordering comparison (lt, gt, le, ge). False if testing for an equality comparison (eq, ne)

Returns: true if the types are comparable, as defined by the rules of the "eq" operator

isNodeType

public static boolean isNodeType(ItemType type)
Test whether a given type is (some subtype of) node()

Parameters: type The type to be tested

Returns: true if the item type is node() or a subtype of node()

isNumericPrimitiveType

public static boolean isNumericPrimitiveType(ItemType t)
Test whether the supplied type, which must be a primitive type, is one of the numeric primitive types

Parameters: t the type being tested

Returns: true if the type is integer, double, float, decimal, or the abstract type "numeric"

isOrdered

public static boolean isOrdered(int type)
Determine whether a primitive type is ordered. Note that the rules for this differ between XPath and XML Schema: these are the XPath rules.

Parameters: type the primitive item type being tested

Returns: true if the types are potentially comparable. For abstract types (type=ATOMIC) we give the benefit of the doubt and return true.

isPrimitiveType

public static boolean isPrimitiveType(int code)
Determine whether this type is a primitive type. The primitive types are the 19 primitive types of XML Schema, plus xs:integer, xdt:dayTimeDuration and xdt:yearMonthDuration; xdt:untypedAtomic; the 7 node kinds; and all supertypes of these (item(), node(), xdt:anyAtomicType, xdt:number, ...)

Parameters: code the item type code to be tested

Returns: true if the type is considered primitive under the above rules

schemaTypeRelationship

public static int schemaTypeRelationship(SchemaType s1, SchemaType s2)
Get the relationship of two schema types to each other