net.sf.saxon.value
Class Type

java.lang.Object
  |
  +--net.sf.saxon.value.Type
All Implemented Interfaces:
java.io.Serializable

public abstract class Type
extends java.lang.Object
implements java.io.Serializable

This class contains static information about types and methods for constructing type codes. The class is never instantiated.

See Also:
Serialized Form

Field Summary
static int ANY_SIMPLE_TYPE
          Constant denoting the type of a simple-valued element or attribute whose actual type is unknown
static int ANY_TYPE
          Constant denoting the type of a simple-or-complex-valued element that is allowed to have any content
static int ANY_URI
          Item type representing the type xs:anyURI
static int ATOMIC
          Constant denoting any atomic type (the union of all primitive types and types derived from primitive types by restriction or by union)
static short ATTRIBUTE
          Item type representing an attribute node - attribute()
static int BASE64_BINARY
          Item type representing the type xs:base64Binary
static int BOOLEAN
          Item type representing the type xs:boolean
static int BYTE
          Item type representing the type xs:byte
static short COMMENT
          Item type representing a comment node
static int DATE
          Item type representing the type xs:date
static int DATE_TIME
          Item type representing the type xs:dateTime
static int DAY_TIME_DURATION
          Item type representing the type xdt:dayTimeDuration
static int DECIMAL
          Item type representing the type xs:decimal
static short DOCUMENT
          Item type representing a document node
static int DOUBLE
          Item type representing the type xs:double
static int DURATION
          Item type representing the type xs:duration
static short ELEMENT
          Type representing an element node - element()
static short EMPTY
          Item type that matches no items (corresponds to SequenceType empty())
static int ENTITIES
          Content type representing the complex type xs:ENTITIES
static int ENTITY
          Item type representing the type xs:ENTITY
static int FLOAT
          Item type representing the type xs:float
static int G_DAY
          Item type representing the type xs:gDay
static int G_MONTH
          Item type representing the type xs:gMonth
static int G_MONTH_DAY
          Item type representing the type xs:monthDay
static int G_YEAR
          Item type representing the type xs:gYear
static int G_YEAR_MONTH
          Item type representing the type xs:gYearMonth
static int HEX_BINARY
          Item type representing the type xs:hexBinary
static int ID
          Item type representing the type xs:ID
static int IDREF
          Item type representing the type xs:IDREF
static int IDREFS
          Content type representing the complex type xs:IDREFS
static int INT
          Item type representing the type xs:int
static int INTEGER
          Item type representing the type xs:integer
static short ITEM
          An item type that matches any item
static int LANGUAGE
          Item type representing the type xs:language
static int LONG
          Item type representing the type xs:long
static short MAX_NODE_TYPE
          A type that matches nothing
static int NAME
          Item type representing the type xs:NAME
static short NAMESPACE
          Item type representing a namespace node
static int NCNAME
          Item type representing the type xs:NCNAME
static int NEGATIVE_INTEGER
          Item type representing the type xs:negativeInteger
static int NMTOKEN
          Item type representing the type xs:NMTOKEN
static int NMTOKENS
          Content type representing the complex type xs:NMTOKENS
static short NODE
          An item type that matches any node
static int NON_NEGATIVE_INTEGER
          Item type representing the type xs:nonNegativeInteger
static int NON_POSITIVE_INTEGER
          Item type representing the type xs:nonPositiveInteger
static int NORMALIZED_STRING
          Item type representing the type xs:normalizedString
static int NOTATION
          Item type representing the type xs:NOTATION
static int NUMBER
          Constant denoting any numeric type (the union of float, double, and decimal)
static int OBJECT
          Constant representing the type of an external object (for use by extension functions)
static int POSITIVE_INTEGER
          Item type representing the type xs:positiveInteger
static short PROCESSING_INSTRUCTION
          Item type representing a processing-instruction node
static int QNAME
          Item type representing the type xs:QName
static int SAME_AS_FIRST_ARGUMENT
          Pseudo-type; constant used in function signatures to indicate that the return item type of the function is the same as the actual item type of the first argument
static int SHORT
          Item type representing the type xs:short
static int STRING
          Constants representing primitive data types defined in Schema Part 2
static short TEXT
          Item type representing a text node - text()
static int TIME
          Item type representing the type xs:time
static int TOKEN
          Item type representing the type xs:token
static int UNSIGNED_BYTE
          Item type representing the type xs:unsignedByte
static int UNSIGNED_INT
          Item type representing the type xs:unsignedInt
static int UNSIGNED_LONG
          Item type representing the type xs:unsignedLong
static int UNSIGNED_SHORT
          Item type representing the type xs:unsignedShort
static int UNTYPED_ANY
          Constant denoting the type of a simple-or-complex-valued element whose actual type is unknown
static int UNTYPED_ATOMIC
          Item type representing the type xdt:untypedAtomic (the type of the content of a schema-less node)
static int YEAR_MONTH_DURATION
          Item type representing the type xdt:yearMonthDuration
 
Constructor Summary
Type()
           
 
Method Summary
static int getCommonSuperType(int t1, int t2)
          Get a type that is a common supertype of two given types
static int getNamedType(java.lang.String uri, java.lang.String localName)
          Get the type with a given expanded name
static int getPrimitiveType(int type)
          For an atomic type, get the primitive type (treating NUMBER as a primitive type)
static int getSystemType(java.lang.String name)
          Get a system type - that is, one whose name is a keyword rather than a QName.
static java.lang.String getTypeName(int type)
          Get the name of the item type with a given numeric type code
static boolean isNodeType(int type)
          Test whether a given type is (some subtype of) node()
static boolean isPromotable(int sourceType, int targetType)
          Determine whether type A is numerically promotable to type B, for example xs:integer is promotable to xs:double
static boolean isSubType(int subtype, int supertype)
          Determine whether type A is type B or one of its subtypes, recursively
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELEMENT

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

See Also:
Constant Field Values

ATTRIBUTE

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

See Also:
Constant Field Values

TEXT

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

See Also:
Constant Field Values

PROCESSING_INSTRUCTION

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

See Also:
Constant Field Values

COMMENT

public static final short COMMENT
Item type representing a comment node

See Also:
Constant Field Values

DOCUMENT

public static final short DOCUMENT
Item type representing a document node

See Also:
Constant Field Values

NAMESPACE

public static final short NAMESPACE
Item type representing a namespace node

See Also:
Constant Field Values

NODE

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

See Also:
Constant Field Values

ITEM

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

See Also:
Constant Field Values

MAX_NODE_TYPE

public static final short MAX_NODE_TYPE
A type that matches nothing

See Also:
Constant Field Values

EMPTY

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

See Also:
Constant Field Values

ATOMIC

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

See Also:
Constant Field Values

NUMBER

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

See Also:
Constant Field Values

ANY_SIMPLE_TYPE

public static final int ANY_SIMPLE_TYPE
Constant denoting the type of a simple-valued element or attribute whose actual type is unknown

See Also:
Constant Field Values

ANY_TYPE

public static final int ANY_TYPE
Constant denoting the type of a simple-or-complex-valued element that is allowed to have any content

See Also:
Constant Field Values

UNTYPED_ANY

public static final int UNTYPED_ANY
Constant denoting the type of a simple-or-complex-valued element whose actual type is unknown

See Also:
Constant Field Values

STRING

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

See Also:
Constant Field Values

BOOLEAN

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

See Also:
Constant Field Values

DECIMAL

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

See Also:
Constant Field Values

FLOAT

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

See Also:
Constant Field Values

DOUBLE

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

See Also:
Constant Field Values

DURATION

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

See Also:
Constant Field Values

DATE_TIME

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

See Also:
Constant Field Values

TIME

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

See Also:
Constant Field Values

DATE

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

See Also:
Constant Field Values

G_YEAR_MONTH

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

See Also:
Constant Field Values

G_YEAR

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

See Also:
Constant Field Values

G_MONTH_DAY

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

See Also:
Constant Field Values

G_DAY

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

See Also:
Constant Field Values

G_MONTH

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

See Also:
Constant Field Values

HEX_BINARY

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

See Also:
Constant Field Values

BASE64_BINARY

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

See Also:
Constant Field Values

ANY_URI

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

See Also:
Constant Field Values

QNAME

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

See Also:
Constant Field Values

NOTATION

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

See Also:
Constant Field Values

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)

See Also:
Constant Field Values

OBJECT

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

See Also:
Constant Field Values

INTEGER

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

See Also:
Constant Field Values

NON_POSITIVE_INTEGER

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

See Also:
Constant Field Values

NEGATIVE_INTEGER

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

See Also:
Constant Field Values

LONG

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

See Also:
Constant Field Values

INT

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

See Also:
Constant Field Values

SHORT

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

See Also:
Constant Field Values

BYTE

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

See Also:
Constant Field Values

NON_NEGATIVE_INTEGER

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

See Also:
Constant Field Values

POSITIVE_INTEGER

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

See Also:
Constant Field Values

UNSIGNED_LONG

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

See Also:
Constant Field Values

UNSIGNED_INT

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

See Also:
Constant Field Values

UNSIGNED_SHORT

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

See Also:
Constant Field Values

UNSIGNED_BYTE

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

See Also:
Constant Field Values

NORMALIZED_STRING

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

See Also:
Constant Field Values

TOKEN

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

See Also:
Constant Field Values

LANGUAGE

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

See Also:
Constant Field Values

NMTOKEN

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

See Also:
Constant Field Values

NMTOKENS

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

See Also:
Constant Field Values

NAME

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

See Also:
Constant Field Values

NCNAME

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

See Also:
Constant Field Values

ID

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

See Also:
Constant Field Values

IDREF

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

See Also:
Constant Field Values

IDREFS

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

See Also:
Constant Field Values

ENTITY

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

See Also:
Constant Field Values

ENTITIES

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

See Also:
Constant Field Values

YEAR_MONTH_DURATION

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

See Also:
Constant Field Values

DAY_TIME_DURATION

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

See Also:
Constant Field Values

SAME_AS_FIRST_ARGUMENT

public static final int SAME_AS_FIRST_ARGUMENT
Pseudo-type; constant used in function signatures to indicate that the return item type of the function is the same as the actual item type of the first argument

See Also:
Constant Field Values
Constructor Detail

Type

public Type()
Method Detail

isNodeType

public static boolean isNodeType(int 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()

getTypeName

public static final java.lang.String getTypeName(int type)
Get the name of the item type with a given numeric type code

Parameters:
type - the numeric code of the required item type
Returns:
the name of the type, as a QName using a conventional prefix such as "xs" or "xdt" or "java"

isSubType

public static boolean isSubType(int subtype,
                                int supertype)
Determine whether type A is type B or one of its subtypes, recursively

Parameters:
subtype - numeric code identifying the first type
supertype - numeric code identifying the second type
Returns:
true if the first type is the second type or a (direct or indirect) subtype of the second type

isPromotable

public static boolean isPromotable(int sourceType,
                                   int targetType)
Determine whether type A is numerically promotable to type B, for example xs:integer is promotable to xs:double


getPrimitiveType

public static int getPrimitiveType(int type)
For an atomic type, get the primitive type (treating NUMBER as a primitive type)

Parameters:
type - the item type whose supertype is required
Returns:
the primitive type that is a supertype of the given item type

getCommonSuperType

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

Parameters:
t1 - the first item type
t2 - the second item type
Returns:
the numeric code of the item type that is a supertype of both the supplied item types

getNamedType

public static int getNamedType(java.lang.String uri,
                               java.lang.String localName)
                        throws XPathException
Get the type with a given expanded name

Parameters:
uri - the URI part of the type name
localName - the local part of the type name
Returns:
the numeric type code of the specified type
Throws:
XPathException - if the type is unknown

getSystemType

public static int getSystemType(java.lang.String name)
                         throws XPathException
Get a system type - that is, one whose name is a keyword rather than a QName. This includes the node kinds such as element and attribute, the generic types node() and item(), and the pseudo-type empty()

Parameters:
name -
Throws:
XPathException