Package org.apache.derby.iapi.types
Class JSQLType
- java.lang.Object
-
- org.apache.derby.iapi.types.JSQLType
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,Formatable,TypedFormat
public final class JSQLType extends java.lang.Object implements Formatable
Type descriptor which wraps all 3 kinds of types supported in Derby's JSQL language: SQL types, Java primitives, Java classes. This interface was originally added to support the serializing of WorkUnit signatures.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static byteBOOLEANstatic byteBYTEprivate bytecategorystatic byteCHARstatic byteDOUBLEstatic byteFLOATstatic byteINTstatic byteJAVA_CLASSstatic byteJAVA_PRIMITIVEprivate java.lang.StringjavaClassNamestatic byteLONGstatic byteNOT_PRIMITIVEprivate byteprimitiveKindprivate static java.lang.String[]primitiveNamesstatic byteSHORTprivate DataTypeDescriptorsqlTypestatic byteSQLTYPEprivate static java.lang.String[]wrapperClassNames
-
Constructor Summary
Constructors Constructor Description JSQLType()Public 0-arg constructor for Formatable machinery.JSQLType(byte primitiveKind)Create a JSQLType for a Java primitive.JSQLType(java.lang.String javaName)Create a JSQLType given the name of a Java primitive or java class.JSQLType(DataTypeDescriptor sqlType)Create a JSQLType from a SQL type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description bytegetCategory()What kind of type is this:java.lang.StringgetJavaClassName()If this is a JAVA_CLASS, what is it's name?static bytegetPrimitiveID(java.lang.String name)Translate the name of a java primitive to an idbytegetPrimitiveKind()If this is a JAVA_PRIMITIVE, what is its name?static java.lang.StringgetPrimitiveName(byte index)DataTypeDescriptorgetSQLType()What's our SQLTYPE?intgetTypeFormatId()Get the formatID which corresponds to this class.static java.lang.StringgetWrapperClassName(byte primitive)Gets the name of the java wrapper class corresponding to a primitive.private voidinitialize(byte primitiveKind)private voidinitialize(byte category, DataTypeDescriptor sqlType, java.lang.String javaClassName, byte primitiveKind)Initialize this JSQL type.private voidinitialize(java.lang.String javaClassName)private voidinitialize(DataTypeDescriptor sqlType)voidreadExternal(java.io.ObjectInput in)voidwriteExternal(java.io.ObjectOutput out)
-
-
-
Field Detail
-
SQLTYPE
public static final byte SQLTYPE
- See Also:
- Constant Field Values
-
JAVA_CLASS
public static final byte JAVA_CLASS
- See Also:
- Constant Field Values
-
JAVA_PRIMITIVE
public static final byte JAVA_PRIMITIVE
- See Also:
- Constant Field Values
-
NOT_PRIMITIVE
public static final byte NOT_PRIMITIVE
- See Also:
- Constant Field Values
-
BOOLEAN
public static final byte BOOLEAN
- See Also:
- Constant Field Values
-
CHAR
public static final byte CHAR
- See Also:
- Constant Field Values
-
BYTE
public static final byte BYTE
- See Also:
- Constant Field Values
-
SHORT
public static final byte SHORT
- See Also:
- Constant Field Values
-
INT
public static final byte INT
- See Also:
- Constant Field Values
-
LONG
public static final byte LONG
- See Also:
- Constant Field Values
-
FLOAT
public static final byte FLOAT
- See Also:
- Constant Field Values
-
DOUBLE
public static final byte DOUBLE
- See Also:
- Constant Field Values
-
wrapperClassNames
private static final java.lang.String[] wrapperClassNames
-
primitiveNames
private static final java.lang.String[] primitiveNames
-
category
private byte category
-
sqlType
private DataTypeDescriptor sqlType
-
javaClassName
private java.lang.String javaClassName
-
primitiveKind
private byte primitiveKind
-
-
Constructor Detail
-
JSQLType
public JSQLType()
Public 0-arg constructor for Formatable machinery.
-
JSQLType
public JSQLType(DataTypeDescriptor sqlType)
Create a JSQLType from a SQL type.- Parameters:
sqlType- the SQL type to wrap
-
JSQLType
public JSQLType(java.lang.String javaName)
Create a JSQLType given the name of a Java primitive or java class.- Parameters:
javaName- name of java primitive or class to wrap
-
JSQLType
public JSQLType(byte primitiveKind)
Create a JSQLType for a Java primitive.- Parameters:
primitiveKind- primitive to wrap
-
-
Method Detail
-
getCategory
public byte getCategory()
What kind of type is this:- Returns:
- one of the following: SQLTYPE, JAVA_PRIMITIVE, JAVA_CLASS
-
getPrimitiveKind
public byte getPrimitiveKind()
If this is a JAVA_PRIMITIVE, what is its name?- Returns:
- BOOLEAN, INT, ... if this is a JAVA_PRIMITIVE. NOT_PRIMITIVE if this is SQLTYPE or JAVA_CLASS.
-
getJavaClassName
public java.lang.String getJavaClassName()
If this is a JAVA_CLASS, what is it's name?- Returns:
- java class name if this is a JAVA_CLASS null if this is SQLTYPE or JAVA_PRIMITIVE
-
getSQLType
public DataTypeDescriptor getSQLType() throws StandardException
What's our SQLTYPE?- Returns:
- the DataTypeDescriptor corresponding to this type
- Throws:
StandardException
-
getPrimitiveName
public static java.lang.String getPrimitiveName(byte index)
-
getTypeFormatId
public int getTypeFormatId()
Get the formatID which corresponds to this class.- Specified by:
getTypeFormatIdin interfaceTypedFormat- Returns:
- the formatID of this class
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException- thrown on errorjava.lang.ClassNotFoundException- thrown on error- See Also:
Externalizable.readExternal(java.io.ObjectInput)
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException- thrown on error
-
initialize
private void initialize(byte primitiveKind)
-
initialize
private void initialize(DataTypeDescriptor sqlType)
-
initialize
private void initialize(java.lang.String javaClassName)
-
initialize
private void initialize(byte category, DataTypeDescriptor sqlType, java.lang.String javaClassName, byte primitiveKind)Initialize this JSQL type. Minion of all constructors.- Parameters:
category- SQLTYPE, JAVA_CLASS, JAVA_PRIMITIVEsqlType- corresponding SQL type if category=SQLTYPEjavaClassName- corresponding java class if category=JAVA_CLASSprimitiveKind- kind of primitive if category=JAVA_PRIMITIVE
-
getWrapperClassName
public static java.lang.String getWrapperClassName(byte primitive)
Gets the name of the java wrapper class corresponding to a primitive.- Parameters:
primitive- BOOLEAN, INT, ... etc.- Returns:
- name of the java wrapper class corresponding to the primitive
-
getPrimitiveID
public static byte getPrimitiveID(java.lang.String name)
Translate the name of a java primitive to an id- Parameters:
name- name of primitive- Returns:
- BOOLEAN, INT, ... etc if the name is that of a primitive. NOT_PRIMITIVE otherwise
-
-