gnu.kawa.xml

Class XDataType

Implemented Interfaces:
TypeValue
Known Direct Subclasses:
XIntegerType, XStringType, XTimeType

public class XDataType
extends Type
implements TypeValue

An atomic type as used in XML Schema and related languages. For example the {code xs:decimal} type is XDataType.decimalType.

Field Summary

static int
ANY_ATOMIC_TYPE_CODE
static int
ANY_URI_TYPE_CODE
static int
BASE64_BINARY_TYPE_CODE
static int
BOOLEAN_TYPE_CODE
static int
BYTE_TYPE_CODE
static int
DATE_TIME_TYPE_CODE
static int
DATE_TYPE_CODE
static int
DAY_TIME_DURATION_TYPE_CODE
static BigDecimal
DECIMAL_ONE
static int
DECIMAL_TYPE_CODE
static Double
DOUBLE_ONE
static int
DOUBLE_TYPE_CODE
static Double
DOUBLE_ZERO
static int
DURATION_TYPE_CODE
static int
ENTITY_TYPE_CODE
static Float
FLOAT_ONE
static int
FLOAT_TYPE_CODE
static Float
FLOAT_ZERO
static int
G_DAY_TYPE_CODE
static int
G_MONTH_DAY_TYPE_CODE
static int
G_MONTH_TYPE_CODE
static int
G_YEAR_MONTH_TYPE_CODE
static int
G_YEAR_TYPE_CODE
static int
HEX_BINARY_TYPE_CODE
static int
IDREF_TYPE_CODE
static int
ID_TYPE_CODE
static int
INTEGER_TYPE_CODE
static int
INT_TYPE_CODE
static int
LANGUAGE_TYPE_CODE
static int
LONG_TYPE_CODE
static int
NAME_TYPE_CODE
static int
NCNAME_TYPE_CODE
static int
NEGATIVE_INTEGER_TYPE_CODE
static int
NMTOKEN_TYPE_CODE
static int
NONNEGATIVE_INTEGER_TYPE_CODE
static int
NON_POSITIVE_INTEGER_TYPE_CODE
static int
NORMALIZED_STRING_TYPE_CODE
static int
NOTATION_TYPE_CODE
static XDataType
NotationType
static int
POSITIVE_INTEGER_TYPE_CODE
static int
QNAME_TYPE_CODE
static int
SHORT_TYPE_CODE
static int
STRING_TYPE_CODE
static int
TIME_TYPE_CODE
static int
TOKEN_TYPE_CODE
static int
UNSIGNED_BYTE_TYPE_CODE
static int
UNSIGNED_INT_TYPE_CODE
static int
UNSIGNED_LONG_TYPE_CODE
static int
UNSIGNED_SHORT_TYPE_CODE
static int
UNTYPED_ATOMIC_TYPE_CODE
static int
YEAR_MONTH_DURATION_TYPE_CODE
static XDataType
anyAtomicType
static XDataType
anyURIType
static XDataType
base64BinaryType
static XDataType
booleanType
static XDataType
dayTimeDurationType
static XDataType
decimalType
static XDataType
doubleType
static XDataType
durationType
static XDataType
floatType
static XDataType
hexBinaryType
static XDataType
stringStringType
A value implemented as java.lang.String.
static XDataType
stringType
static XDataType
untypedAtomicType
static XDataType
yearMonthDurationType

Fields inherited from class gnu.bytecode.Type

booleanValue_method, boolean_ctype, boolean_type, byte_type, char_type, clone_method, doubleValue_method, double_type, floatValue_method, float_type, intValue_method, int_type, java_lang_Class_type, longValue_method, long_type, neverReturnsType, nullType, number_type, pointer_type, reflectClass, short_type, string_type, throwable_type, toString_method, tostring_type, typeArray0, void_type

Constructor Summary

XDataType(Object name, Type implementationType, int typeCode)

Method Summary

Object
cast(Object value)
boolean
castable(Object value)
Object
coerceFromObject(Object obj)
Convert an object to a value of this Type.
int
compare(Type other)
Return a numeric code showing "subtype" relationship: 1: if other is a pure subtype of this; 0: if has the same values; -1: if this is a pure subtype of other; -2: if they have values in common but neither is a subtype of the other; -3: if the types have no values in common.
void
emitCoerceFromObject(CodeAttr code)
Compile code to coerce/convert from Object to this type.
void
emitCoerceToObject(CodeAttr code)
Compile code to convert a object of this type on the stack to Object.
void
emitIsInstance(Variable incoming, Compilation comp, Target target)
void
emitTestIf(Variable incoming, Declaration decl, Compilation comp)
Procedure
getConstructor()
Type
getImplementationType()
The type used to implement types not natively understood by the JVM.
java.lang.Class
getReflectClass()
Get the java.lang.Class object for the representation type.
boolean
isInstance(Object obj)
static Double
makeDouble(double value)
static Float
makeFloat(float value)
void
print(Object value, Consumer out)
String
toString(Object value)
Object
valueOf(String value)

Methods inherited from class gnu.bytecode.Type

coerceFromObject, coerceToObject, compare, emitCoerceFromObject, emitCoerceToObject, emitIsInstance, getImplementationType, getName, getReflectClass, getSignature, getSize, getSizeInWords, getType, hashCode, isInstance, isMoreSpecific, isSubtype, isValidJavaTypeName, isVoid, lookupType, lowestCommonSuperType, make, promote, registerTypeForClass, setName, setReflectClass, setSignature, signatureLength, signatureLength, signatureToName, signatureToPrimitive, signatureToType, signatureToType, swappedCompareResult, toString

Field Details

ANY_ATOMIC_TYPE_CODE

public static final int ANY_ATOMIC_TYPE_CODE
Field Value:
1

ANY_URI_TYPE_CODE

public static final int ANY_URI_TYPE_CODE
Field Value:
31

BASE64_BINARY_TYPE_CODE

public static final int BASE64_BINARY_TYPE_CODE
Field Value:
32

BOOLEAN_TYPE_CODE

public static final int BOOLEAN_TYPE_CODE
Field Value:
29

BYTE_TYPE_CODE

public static final int BYTE_TYPE_CODE
Field Value:
9

DATE_TIME_TYPE_CODE

public static final int DATE_TIME_TYPE_CODE
Field Value:
18

DATE_TYPE_CODE

public static final int DATE_TYPE_CODE
Field Value:
19

DAY_TIME_DURATION_TYPE_CODE

public static final int DAY_TIME_DURATION_TYPE_CODE
Field Value:
28

DECIMAL_ONE

public static final BigDecimal DECIMAL_ONE

DECIMAL_TYPE_CODE

public static final int DECIMAL_TYPE_CODE
Field Value:
2

DOUBLE_ONE

public static final Double DOUBLE_ONE

DOUBLE_TYPE_CODE

public static final int DOUBLE_TYPE_CODE
Field Value:
17

DOUBLE_ZERO

public static final Double DOUBLE_ZERO

DURATION_TYPE_CODE

public static final int DURATION_TYPE_CODE
Field Value:
26

ENTITY_TYPE_CODE

public static final int ENTITY_TYPE_CODE
Field Value:
45

FLOAT_ONE

public static final Float FLOAT_ONE

FLOAT_TYPE_CODE

public static final int FLOAT_TYPE_CODE
Field Value:
16

FLOAT_ZERO

public static final Float FLOAT_ZERO

G_DAY_TYPE_CODE

public static final int G_DAY_TYPE_CODE
Field Value:
24

G_MONTH_DAY_TYPE_CODE

public static final int G_MONTH_DAY_TYPE_CODE
Field Value:
23

G_MONTH_TYPE_CODE

public static final int G_MONTH_TYPE_CODE
Field Value:
25

G_YEAR_MONTH_TYPE_CODE

public static final int G_YEAR_MONTH_TYPE_CODE
Field Value:
21

G_YEAR_TYPE_CODE

public static final int G_YEAR_TYPE_CODE
Field Value:
22

HEX_BINARY_TYPE_CODE

public static final int HEX_BINARY_TYPE_CODE
Field Value:
33

IDREF_TYPE_CODE

public static final int IDREF_TYPE_CODE
Field Value:
44

ID_TYPE_CODE

public static final int ID_TYPE_CODE
Field Value:
43

INTEGER_TYPE_CODE

public static final int INTEGER_TYPE_CODE
Field Value:
3

INT_TYPE_CODE

public static final int INT_TYPE_CODE
Field Value:
7

LANGUAGE_TYPE_CODE

public static final int LANGUAGE_TYPE_CODE
Field Value:
39

LONG_TYPE_CODE

public static final int LONG_TYPE_CODE
Field Value:
6

NAME_TYPE_CODE

public static final int NAME_TYPE_CODE
Field Value:
41

NCNAME_TYPE_CODE

public static final int NCNAME_TYPE_CODE
Field Value:
42

NEGATIVE_INTEGER_TYPE_CODE

public static final int NEGATIVE_INTEGER_TYPE_CODE
Field Value:
5

NMTOKEN_TYPE_CODE

public static final int NMTOKEN_TYPE_CODE
Field Value:
40

NONNEGATIVE_INTEGER_TYPE_CODE

public static final int NONNEGATIVE_INTEGER_TYPE_CODE
Field Value:
10

NON_POSITIVE_INTEGER_TYPE_CODE

public static final int NON_POSITIVE_INTEGER_TYPE_CODE
Field Value:
4

NORMALIZED_STRING_TYPE_CODE

public static final int NORMALIZED_STRING_TYPE_CODE
Field Value:
37

NOTATION_TYPE_CODE

public static final int NOTATION_TYPE_CODE
Field Value:
34

NotationType

public static final XDataType NotationType

POSITIVE_INTEGER_TYPE_CODE

public static final int POSITIVE_INTEGER_TYPE_CODE
Field Value:
15

QNAME_TYPE_CODE

public static final int QNAME_TYPE_CODE
Field Value:
30

SHORT_TYPE_CODE

public static final int SHORT_TYPE_CODE
Field Value:
8

STRING_TYPE_CODE

public static final int STRING_TYPE_CODE
Field Value:
36

TIME_TYPE_CODE

public static final int TIME_TYPE_CODE
Field Value:
20

TOKEN_TYPE_CODE

public static final int TOKEN_TYPE_CODE
Field Value:
38

UNSIGNED_BYTE_TYPE_CODE

public static final int UNSIGNED_BYTE_TYPE_CODE
Field Value:
14

UNSIGNED_INT_TYPE_CODE

public static final int UNSIGNED_INT_TYPE_CODE
Field Value:
12

UNSIGNED_LONG_TYPE_CODE

public static final int UNSIGNED_LONG_TYPE_CODE
Field Value:
11

UNSIGNED_SHORT_TYPE_CODE

public static final int UNSIGNED_SHORT_TYPE_CODE
Field Value:
13

UNTYPED_ATOMIC_TYPE_CODE

public static final int UNTYPED_ATOMIC_TYPE_CODE
Field Value:
35

YEAR_MONTH_DURATION_TYPE_CODE

public static final int YEAR_MONTH_DURATION_TYPE_CODE
Field Value:
27

anyAtomicType

public static final XDataType anyAtomicType

anyURIType

public static final XDataType anyURIType

base64BinaryType

public static final XDataType base64BinaryType

booleanType

public static final XDataType booleanType

dayTimeDurationType

public static final XDataType dayTimeDurationType

decimalType

public static final XDataType decimalType

doubleType

public static final XDataType doubleType

durationType

public static final XDataType durationType

floatType

public static final XDataType floatType

hexBinaryType

public static final XDataType hexBinaryType

stringStringType

public static final XDataType stringStringType
A value implemented as java.lang.String. Can be cast from CharSequence.

stringType

public static final XDataType stringType

untypedAtomicType

public static final XDataType untypedAtomicType

yearMonthDurationType

public static final XDataType yearMonthDurationType

Constructor Details

XDataType

public XDataType(Object name,
                 Type implementationType,
                 int typeCode)

Method Details

cast

public Object cast(Object value)

castable

public boolean castable(Object value)

coerceFromObject

public Object coerceFromObject(Object obj)
Convert an object to a value of this Type. Throw a ClassCastException when this is not possible.
Overrides:
coerceFromObject in interface Type

compare

public int compare(Type other)
Return a numeric code showing "subtype" relationship: 1: if other is a pure subtype of this; 0: if has the same values; -1: if this is a pure subtype of other; -2: if they have values in common but neither is a subtype of the other; -3: if the types have no values in common. "Same member" is rather loose; by "A is a subtype of B" we mean that all instance of A can be "widened" to B. More formally, A.compare(B) returns: 1: all B values can be converted to A without a coercion failure (i.e. a ClassCastException or overflow or major loss of information), but not vice versa. 0: all A values can be converted to B without a coercion failure and vice versa; -1: all A values can be converted to B without a coercion failure not not vice versa; -2: there are (potentially) some A values that can be converted to B, and some B values can be converted to A; -3: there are no A values that can be converted to B, and neither are there any B values that can be converted to A.
Overrides:
compare in interface Type

emitCoerceFromObject

public void emitCoerceFromObject(CodeAttr code)
Compile code to coerce/convert from Object to this type.
Overrides:
emitCoerceFromObject in interface Type

emitCoerceToObject

public void emitCoerceToObject(CodeAttr code)
Compile code to convert a object of this type on the stack to Object.
Overrides:
emitCoerceToObject in interface Type

emitIsInstance

public void emitIsInstance(Variable incoming,
                           Compilation comp,
                           Target target)
Specified by:
emitIsInstance in interface TypeValue

emitTestIf

public void emitTestIf(Variable incoming,
                       Declaration decl,
                       Compilation comp)
Specified by:
emitTestIf in interface TypeValue

getConstructor

public Procedure getConstructor()
Specified by:
getConstructor in interface TypeValue

getImplementationType

public Type getImplementationType()
The type used to implement types not natively understood by the JVM. Usually, the identity function. However, a language might handle union types or template types or type expressions calculated at run time. In that case return the type used at the JVM level, and known at compile time.
Specified by:
getImplementationType in interface TypeValue
Overrides:
getImplementationType in interface Type

getReflectClass

public java.lang.Class getReflectClass()
Get the java.lang.Class object for the representation type.
Overrides:
getReflectClass in interface Type

isInstance

public boolean isInstance(Object obj)
Overrides:
isInstance in interface Type

makeDouble

public static Double makeDouble(double value)

makeFloat

public static Float makeFloat(float value)

print

public void print(Object value,
                  Consumer out)

toString

public String toString(Object value)

valueOf

public Object valueOf(String value)