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.

The constant integers used for type names in earlier versions of this class have been replaced by constants in StandardNames. The constants representing AtomicType objects are now available through the BuiltInAtomicType class.

Field Summary
static shortATTRIBUTE
Item type representing an attribute node - attribute()
static shortCOMMENT
Item type representing a comment node
static shortDOCUMENT
Item type representing a document node
static shortELEMENT
Type representing an element node - element()
static shortEMPTY
Item type that matches no items (corresponds to SequenceType empty())
static shortFUNCTION
A type number for function()
static shortITEM
An item type that matches any item
static ItemTypeITEM_TYPE
static shortMAX_NODE_TYPE
static shortNAMESPACE
Item type representing a namespace node
static shortNODE
An item type that matches any node
static ItemTypeNODE_TYPE
static shortPARENT_POINTER
Dummy node kind used in the tiny tree to contain a parent pointer
static shortPROCESSING_INSTRUCTION
Item type representing a processing-instruction node
static shortSTOPPER
Dummy node kind used in the tiny tree to mark the end of the tree
static shortTEXT
Item type representing a text node - text()
static shortWHITESPACE_TEXT
Item type representing a text node stored in the tiny tree as compressed whitespace
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 ItemType object for a built-in type
static ItemTypegetCommonSuperType(ItemType t1, ItemType t2, TypeHierarchy th)
Get a type that is a common supertype of two given item types
static ItemTypegetItemType(Item item, TypeHierarchy th)
Get the ItemType of an Item
static booleanisComparable(BuiltInAtomicType t1, BuiltInAtomicType t2, boolean ordered)
Determine whether two primitive atomic types are comparable under the rules for ValueComparisons (that is, untyped atomic values treated as strings)
static booleanisGenerallyComparable(BuiltInAtomicType t1, BuiltInAtomicType t2, boolean ordered)
Determine whether two primitive atomic types are comparable under the rules for GeneralComparisons (that is, untyped atomic values treated as comparable to anything)
static booleanisNodeType(ItemType type)
Test whether a given type is (some subtype of) node()
static booleanisPrimitiveType(int code)
Determine whether this type is a primitive type.

Field Detail

ATTRIBUTE

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

COMMENT

public static final short COMMENT
Item type representing a comment node

DOCUMENT

public static final short DOCUMENT
Item type representing a document node

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())

FUNCTION

public static final short FUNCTION
A type number for function()

ITEM

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

ITEM_TYPE

public static final ItemType ITEM_TYPE

MAX_NODE_TYPE

public static final short MAX_NODE_TYPE

NAMESPACE

public static final short NAMESPACE
Item type representing a namespace node

NODE

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

NODE_TYPE

public static final ItemType NODE_TYPE

PARENT_POINTER

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

PROCESSING_INSTRUCTION

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

STOPPER

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

TEXT

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

WHITESPACE_TEXT

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

Method Detail

displayTypeName

public static 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

Parameters: item the item whose type is to be displayed

Returns: a string representation of the type of the item

getBuiltInItemType

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

Parameters: namespace the namespace URI of the type localName the local name of the type

Returns: the ItemType, or null if not found

getCommonSuperType

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

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

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

getItemType

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

Parameters: item the item whose type is required th the type hierarchy cache

Returns: the item type of the item

isComparable

public static boolean isComparable(BuiltInAtomicType t1, BuiltInAtomicType t2, boolean ordered)
Determine whether two primitive atomic types are comparable under the rules for ValueComparisons (that is, untyped atomic values treated as strings)

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

isGenerallyComparable

public static boolean isGenerallyComparable(BuiltInAtomicType t1, BuiltInAtomicType t2, boolean ordered)
Determine whether two primitive atomic types are comparable under the rules for GeneralComparisons (that is, untyped atomic values treated as comparable to anything)

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()

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, xs:dayTimeDuration and xs:yearMonthDuration; xs:untypedAtomic; the 7 node kinds; and all supertypes of these (item(), node(), xs:anyAtomicType, xs:numeric, ...)

Parameters: code the item type code to be tested

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