Package org.h2.value
Class TypeInfo
- java.lang.Object
-
- org.h2.value.ExtTypeInfo
-
- org.h2.value.TypeInfo
-
public class TypeInfo extends ExtTypeInfo implements Typed
Data type with parameters.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeInfoTYPE_ARRAY_UNKNOWNARRAY type with unknown parameters.static TypeInfoTYPE_BIGINTBIGINT type with parameters.static TypeInfoTYPE_BINARYBINARY type with default parameters.static TypeInfoTYPE_BLOBBINARY LARGE OBJECT type with maximum parameters.static TypeInfoTYPE_BOOLEANBOOLEAN type with parameters.static TypeInfoTYPE_CHARCHAR type with default parameters.static TypeInfoTYPE_CLOBCHARACTER LARGE OBJECT type with maximum parameters.static TypeInfoTYPE_DATEDATE type with parameters.static TypeInfoTYPE_DECFLOATDECFLOAT type with maximum parameters.static TypeInfoTYPE_DECFLOAT_BIGINTDECFLOAT type with parameters enough to hold a BIGINT value.static TypeInfoTYPE_DOUBLEDOUBLE PRECISION type with parameters.static TypeInfoTYPE_ENUM_UNDEFINEDENUM type with undefined parameters.static TypeInfoTYPE_GEOMETRYGEOMETRY type with default parameters.static TypeInfoTYPE_INTEGERINTEGER type with parameters.static TypeInfoTYPE_INTERVAL_DAYINTERVAL DAY type with maximum parameters.static TypeInfoTYPE_INTERVAL_DAY_TO_SECONDINTERVAL DAY TO SECOND type with maximum parameters.static TypeInfoTYPE_INTERVAL_HOUR_TO_SECONDINTERVAL HOUR TO SECOND type with maximum parameters.static TypeInfoTYPE_INTERVAL_YEAR_TO_MONTHINTERVAL YEAR TO MONTH type with maximum parameters.static TypeInfoTYPE_JAVA_OBJECTJAVA_OBJECT type with maximum parameters.static TypeInfoTYPE_JSONJSON type.static TypeInfoTYPE_NULLNULL type with parameters.static TypeInfoTYPE_NUMERIC_BIGINTNUMERIC type with parameters enough to hold a BIGINT value.static TypeInfoTYPE_NUMERIC_FLOATING_POINTNUMERIC type that can hold values with floating point.static TypeInfoTYPE_NUMERIC_SCALE_0NUMERIC type with maximum precision and scale 0.static TypeInfoTYPE_REALREAL type with parameters.static TypeInfoTYPE_ROW_EMPTYROW (row value) type without fields.static TypeInfoTYPE_SMALLINTSMALLINT type with parameters.static TypeInfoTYPE_TIMETIME type with maximum parameters.static TypeInfoTYPE_TIME_TZTIME WITH TIME ZONE type with maximum parameters.static TypeInfoTYPE_TIMESTAMPTIMESTAMP type with maximum parameters.static TypeInfoTYPE_TIMESTAMP_TZTIMESTAMP WITH TIME ZONE type with maximum parameters.static TypeInfoTYPE_TINYINTTINYINT type with parameters.static TypeInfoTYPE_UNKNOWNUNKNOWN type with parameters.static TypeInfoTYPE_UUIDUUID type with parameters.static TypeInfoTYPE_VARBINARYBINARY VARYING type with maximum parameters.static TypeInfoTYPE_VARCHARCHARACTER VARYING type with maximum parameters.static TypeInfoTYPE_VARCHAR_IGNORECASEVARCHAR_IGNORECASE type with maximum parameters.-
Fields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS
-
-
Constructor Summary
Constructors Constructor Description TypeInfo(int valueType, long precision, int scale, ExtTypeInfo extTypeInfo)Creates new instance of data type with parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanareSameTypes(TypeInfo t1, TypeInfo t2)Determines whether two specified types are the same data types without taking precision or scale into account.static voidcheckComparable(TypeInfo t1, TypeInfo t2)Checks whether two specified types are comparable and throws an exception otherwise.booleanequals(java.lang.Object obj)longgetDecimalPrecision()Returns approximate precision in decimal digits for binary numeric data types and precision for all other types.longgetDeclaredPrecision()Returns the precision, or-1Lif not specified in data type definition.intgetDeclaredScale()Returns the scale, or-1if not specified in data type definition.java.lang.StringgetDeclaredTypeName()Returns the declared name of this data type with precision, scale, length, cardinality etc.intgetDisplaySize()Returns the display size in characters.ExtTypeInfogetExtTypeInfo()Returns the extended type information, or null.static TypeInfogetHigherType(Typed[] values)Get the higher data type of all values.static TypeInfogetHigherType(TypeInfo type1, TypeInfo type2)Get the higher data type of two data types.longgetPrecision()Returns the precision.intgetScale()Returns the scale.java.lang.StringBuildergetSQL(java.lang.StringBuilder builder, int sqlFlags)Appends the SQL statement of this object to the specified builder.TypeInfogetType()Returns this type information.static TypeInfogetTypeInfo(int type)Get the data type with parameters object for the given value type and maximum parameters.static TypeInfogetTypeInfo(int type, long precision, int scale, ExtTypeInfo extTypeInfo)Get the data type with parameters object for the given value type and the specified parameters.intgetValueType()Returns the value type.inthashCode()static booleanhaveSameOrdering(TypeInfo t1, TypeInfo t2)Determines whether two specified types have the same ordering rules.TypeInfotoDecfloatType()Convert this type information to compatible DECFLOAT type information.TypeInfotoNumericType()Convert this type information to compatible NUMERIC type information.TypeInfounwrapRow()Returns unwrapped data type if this data type is a row type with degree 1 or this type otherwise.-
Methods inherited from class org.h2.value.ExtTypeInfo
toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.h2.util.HasSQL
getSQL, getTraceSQL
-
-
-
-
Field Detail
-
TYPE_UNKNOWN
public static final TypeInfo TYPE_UNKNOWN
UNKNOWN type with parameters.
-
TYPE_NULL
public static final TypeInfo TYPE_NULL
NULL type with parameters.
-
TYPE_CHAR
public static final TypeInfo TYPE_CHAR
CHAR type with default parameters.
-
TYPE_VARCHAR
public static final TypeInfo TYPE_VARCHAR
CHARACTER VARYING type with maximum parameters.
-
TYPE_VARCHAR_IGNORECASE
public static final TypeInfo TYPE_VARCHAR_IGNORECASE
VARCHAR_IGNORECASE type with maximum parameters.
-
TYPE_CLOB
public static final TypeInfo TYPE_CLOB
CHARACTER LARGE OBJECT type with maximum parameters.
-
TYPE_BINARY
public static final TypeInfo TYPE_BINARY
BINARY type with default parameters.
-
TYPE_VARBINARY
public static final TypeInfo TYPE_VARBINARY
BINARY VARYING type with maximum parameters.
-
TYPE_BLOB
public static final TypeInfo TYPE_BLOB
BINARY LARGE OBJECT type with maximum parameters.
-
TYPE_BOOLEAN
public static final TypeInfo TYPE_BOOLEAN
BOOLEAN type with parameters.
-
TYPE_TINYINT
public static final TypeInfo TYPE_TINYINT
TINYINT type with parameters.
-
TYPE_SMALLINT
public static final TypeInfo TYPE_SMALLINT
SMALLINT type with parameters.
-
TYPE_INTEGER
public static final TypeInfo TYPE_INTEGER
INTEGER type with parameters.
-
TYPE_BIGINT
public static final TypeInfo TYPE_BIGINT
BIGINT type with parameters.
-
TYPE_NUMERIC_SCALE_0
public static final TypeInfo TYPE_NUMERIC_SCALE_0
NUMERIC type with maximum precision and scale 0.
-
TYPE_NUMERIC_BIGINT
public static final TypeInfo TYPE_NUMERIC_BIGINT
NUMERIC type with parameters enough to hold a BIGINT value.
-
TYPE_NUMERIC_FLOATING_POINT
public static final TypeInfo TYPE_NUMERIC_FLOATING_POINT
NUMERIC type that can hold values with floating point.
-
TYPE_REAL
public static final TypeInfo TYPE_REAL
REAL type with parameters.
-
TYPE_DOUBLE
public static final TypeInfo TYPE_DOUBLE
DOUBLE PRECISION type with parameters.
-
TYPE_DECFLOAT
public static final TypeInfo TYPE_DECFLOAT
DECFLOAT type with maximum parameters.
-
TYPE_DECFLOAT_BIGINT
public static final TypeInfo TYPE_DECFLOAT_BIGINT
DECFLOAT type with parameters enough to hold a BIGINT value.
-
TYPE_DATE
public static final TypeInfo TYPE_DATE
DATE type with parameters.
-
TYPE_TIME
public static final TypeInfo TYPE_TIME
TIME type with maximum parameters.
-
TYPE_TIME_TZ
public static final TypeInfo TYPE_TIME_TZ
TIME WITH TIME ZONE type with maximum parameters.
-
TYPE_TIMESTAMP
public static final TypeInfo TYPE_TIMESTAMP
TIMESTAMP type with maximum parameters.
-
TYPE_TIMESTAMP_TZ
public static final TypeInfo TYPE_TIMESTAMP_TZ
TIMESTAMP WITH TIME ZONE type with maximum parameters.
-
TYPE_INTERVAL_DAY
public static final TypeInfo TYPE_INTERVAL_DAY
INTERVAL DAY type with maximum parameters.
-
TYPE_INTERVAL_YEAR_TO_MONTH
public static final TypeInfo TYPE_INTERVAL_YEAR_TO_MONTH
INTERVAL YEAR TO MONTH type with maximum parameters.
-
TYPE_INTERVAL_DAY_TO_SECOND
public static final TypeInfo TYPE_INTERVAL_DAY_TO_SECOND
INTERVAL DAY TO SECOND type with maximum parameters.
-
TYPE_INTERVAL_HOUR_TO_SECOND
public static final TypeInfo TYPE_INTERVAL_HOUR_TO_SECOND
INTERVAL HOUR TO SECOND type with maximum parameters.
-
TYPE_JAVA_OBJECT
public static final TypeInfo TYPE_JAVA_OBJECT
JAVA_OBJECT type with maximum parameters.
-
TYPE_ENUM_UNDEFINED
public static final TypeInfo TYPE_ENUM_UNDEFINED
ENUM type with undefined parameters.
-
TYPE_GEOMETRY
public static final TypeInfo TYPE_GEOMETRY
GEOMETRY type with default parameters.
-
TYPE_JSON
public static final TypeInfo TYPE_JSON
JSON type.
-
TYPE_UUID
public static final TypeInfo TYPE_UUID
UUID type with parameters.
-
TYPE_ARRAY_UNKNOWN
public static final TypeInfo TYPE_ARRAY_UNKNOWN
ARRAY type with unknown parameters.
-
TYPE_ROW_EMPTY
public static final TypeInfo TYPE_ROW_EMPTY
ROW (row value) type without fields.
-
-
Constructor Detail
-
TypeInfo
public TypeInfo(int valueType, long precision, int scale, ExtTypeInfo extTypeInfo)Creates new instance of data type with parameters.- Parameters:
valueType- the value typeprecision- the precisionscale- the scaleextTypeInfo- the extended type information, or null
-
-
Method Detail
-
getTypeInfo
public static TypeInfo getTypeInfo(int type)
Get the data type with parameters object for the given value type and maximum parameters.- Parameters:
type- the value type- Returns:
- the data type with parameters object
-
getTypeInfo
public static TypeInfo getTypeInfo(int type, long precision, int scale, ExtTypeInfo extTypeInfo)
Get the data type with parameters object for the given value type and the specified parameters.- Parameters:
type- the value typeprecision- the precision or-1Lfor defaultscale- the scale or-1for defaultextTypeInfo- the extended type information or null- Returns:
- the data type with parameters object
-
getHigherType
public static TypeInfo getHigherType(Typed[] values)
Get the higher data type of all values.- Parameters:
values- the values- Returns:
- the higher data type
-
getHigherType
public static TypeInfo getHigherType(TypeInfo type1, TypeInfo type2)
Get the higher data type of two data types. If values need to be converted to match the other operands data type, the value with the lower order is converted to the value with the higher order.- Parameters:
type1- the first data typetype2- the second data type- Returns:
- the higher data type of the two
-
areSameTypes
public static boolean areSameTypes(TypeInfo t1, TypeInfo t2)
Determines whether two specified types are the same data types without taking precision or scale into account.- Parameters:
t1- first data typet2- second data type- Returns:
- whether types are the same
-
checkComparable
public static void checkComparable(TypeInfo t1, TypeInfo t2)
Checks whether two specified types are comparable and throws an exception otherwise.- Parameters:
t1- first data typet2- second data type- Throws:
DbException- if types aren't comparable
-
haveSameOrdering
public static boolean haveSameOrdering(TypeInfo t1, TypeInfo t2)
Determines whether two specified types have the same ordering rules.- Parameters:
t1- first data typet2- second data type- Returns:
- whether types are comparable
-
getType
public TypeInfo getType()
Returns this type information.
-
getValueType
public int getValueType()
Returns the value type.- Returns:
- the value type
-
getPrecision
public long getPrecision()
Returns the precision.- Returns:
- the precision
-
getDeclaredPrecision
public long getDeclaredPrecision()
Returns the precision, or-1Lif not specified in data type definition.- Returns:
- the precision, or
-1Lif not specified in data type definition
-
getScale
public int getScale()
Returns the scale.- Returns:
- the scale
-
getDeclaredScale
public int getDeclaredScale()
Returns the scale, or-1if not specified in data type definition.- Returns:
- the scale, or
-1if not specified in data type definition
-
getDisplaySize
public int getDisplaySize()
Returns the display size in characters.- Returns:
- the display size
-
getExtTypeInfo
public ExtTypeInfo getExtTypeInfo()
Returns the extended type information, or null.- Returns:
- the extended type information, or null
-
getSQL
public java.lang.StringBuilder getSQL(java.lang.StringBuilder builder, int sqlFlags)Description copied from interface:HasSQLAppends the SQL statement of this object to the specified builder.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toNumericType
public TypeInfo toNumericType()
Convert this type information to compatible NUMERIC type information.- Returns:
- NUMERIC type information
-
toDecfloatType
public TypeInfo toDecfloatType()
Convert this type information to compatible DECFLOAT type information.- Returns:
- DECFLOAT type information
-
unwrapRow
public TypeInfo unwrapRow()
Returns unwrapped data type if this data type is a row type with degree 1 or this type otherwise.- Returns:
- unwrapped data type if this data type is a row type with degree 1 or this type otherwise
-
getDecimalPrecision
public long getDecimalPrecision()
Returns approximate precision in decimal digits for binary numeric data types and precision for all other types.- Returns:
- precision in decimal digits
-
getDeclaredTypeName
public java.lang.String getDeclaredTypeName()
Returns the declared name of this data type with precision, scale, length, cardinality etc. parameters removed, excluding parameters of ENUM data type, GEOMETRY data type, ARRAY elements, and ROW fields.- Returns:
- the declared name
-
-