|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mckoi.database.TType
public abstract class TType
A TType object represents a type in a database engine. For example, an implementation might represent a STRING or a NUMBER. This is an immutable class. See implementations of this object for further examples.
Field Summary | |
---|---|
static TArrayType |
ARRAY_TYPE
A type that represents an array. |
static TBinaryType |
BINARY_TYPE
A default binary (SQL BLOB) type of unlimited maximum size. |
static TBooleanType |
BOOLEAN_TYPE
A default boolean (SQL BIT) type. |
static TDateType |
DATE_TYPE
A default date (SQL TIMESTAMP) type. |
static TNullType |
NULL_TYPE
A default NULL type. |
static TNumericType |
NUMERIC_TYPE
A default numeric (SQL NUMERIC) type of unlimited size and scale. |
static TQueryPlanType |
QUERY_PLAN_TYPE
A type that represents a query plan (sub-select). |
static TStringType |
STRING_TYPE
A default string (SQL VARCHAR) type of unlimited maximum size and null locale. |
Constructor Summary | |
---|---|
protected |
TType(int sql_type)
Constructs the type object. |
Method Summary | |
---|---|
static java.lang.String |
asEncodedString(TType type)
Encodes a TType into a string which is a useful way to serialize a TType. |
static java.lang.String |
asEncodedString(TType[] types)
Given an array of TType, returns a String that that is the encoded form of the array and that can be later decoded back into an array of TType. |
java.lang.String |
asSQLString()
Returns this TType as a fully parsable declared SQL type. |
static TType |
binaryType(int sql_type,
int size)
Returns a TBinaryType object. |
static TType |
booleanType(int sql_type)
Returns a TBooleanType object. |
abstract int |
calculateApproximateMemoryUse(java.lang.Object ob)
Calculates the approximate memory usage of an object of this type in bytes. |
static java.lang.Object |
castObjectToTType(java.lang.Object ob,
TType type)
Casts the given Java object to the given type. |
abstract boolean |
comparableTypes(TType type)
Returns true if the type of this object is logically comparable to the type of the given object. |
abstract int |
compareObs(java.lang.Object ob1,
java.lang.Object ob2)
Compares two objects that are logically comparable under this type. |
static TType |
dateType(int sql_type)
Returns a TDateType object. |
static TType |
decodeString(java.lang.String encoded_str)
Decodes a String that has been encoded with the 'asEncodedString' method and returns a TType that represented the type. |
static TType[] |
decodeTypes(java.lang.String encoded_str)
Decodes a list (or array) of TType objects that was previously encoded with the 'asEncodedString(Type[])' method. |
static TType |
fromClass(java.lang.Class c)
Given a java class, this will return a default TType object that can encapsulate Java objects of this type. |
int |
getSQLType()
Returns the SQL type of this. |
static TType |
getWidestType(TType t1,
TType t2)
Assuming that the two types are numeric types, this will return the 'widest' of the two types. |
abstract java.lang.Class |
javaClass()
Returns the Java Class that is used to represent this type of object. |
static TType |
javaObjectType(java.lang.String class_name)
Returns a TBinaryType constrained for the given class. |
static TType |
numericType(int sql_type,
int size,
int scale)
Returns a TNumericType object of the given size and scale. |
static TType |
stringType(int sql_type,
int size,
java.lang.String locale,
int strength,
int decomposition)
Returns a TStringType object of the given size and locale information. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final TBooleanType BOOLEAN_TYPE
public static final TStringType STRING_TYPE
public static final TNumericType NUMERIC_TYPE
public static final TDateType DATE_TYPE
public static final TBinaryType BINARY_TYPE
public static final TNullType NULL_TYPE
public static final TQueryPlanType QUERY_PLAN_TYPE
public static final TArrayType ARRAY_TYPE
Constructor Detail |
---|
protected TType(int sql_type)
Method Detail |
---|
public int getSQLType()
public java.lang.String asSQLString()
public abstract boolean comparableTypes(TType type)
public abstract int compareObs(java.lang.Object ob1, java.lang.Object ob2)
public abstract int calculateApproximateMemoryUse(java.lang.Object ob)
public abstract java.lang.Class javaClass()
public static java.lang.String asEncodedString(TType type)
public static java.lang.String asEncodedString(TType[] types)
public static TType decodeString(java.lang.String encoded_str)
public static TType[] decodeTypes(java.lang.String encoded_str)
public static TType javaObjectType(java.lang.String class_name)
public static TType stringType(int sql_type, int size, java.lang.String locale, int strength, int decomposition)
public static TType numericType(int sql_type, int size, int scale)
public static TType booleanType(int sql_type)
public static TType dateType(int sql_type)
public static TType binaryType(int sql_type, int size)
public static java.lang.Object castObjectToTType(java.lang.Object ob, TType type)
public static TType fromClass(java.lang.Class c)
Note that using this method is generally not recommended unless you really can't determine more type information than from the Java object itself.
public static TType getWidestType(TType t1, TType t2)
Code by Jim McBeath.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |