public class DataType
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
boolean |
caseSensitive
If this data type is case sensitive.
|
long |
defaultPrecision
The default precision.
|
int |
defaultScale
The default scale.
|
long |
maxPrecision
The maximum supported precision.
|
int |
maxScale
The highest possible scale.
|
long |
minPrecision
The minimum supported precision.
|
int |
minScale
The lowest possible scale.
|
java.lang.String |
params
The list of parameters used in the column definition.
|
java.lang.String |
prefix
The prefix required for the SQL literal representation.
|
boolean |
specialPrecisionScale
If precision and scale have non-standard default values.
|
int |
sqlType
The SQL type.
|
java.lang.String |
suffix
The suffix required for the SQL literal representation.
|
boolean |
supportsPrecision
If the precision parameter is supported.
|
boolean |
supportsScale
If the scale parameter is supported.
|
int |
type
The value type of this data type.
|
| Constructor and Description |
|---|
DataType() |
| Modifier and Type | Method and Description |
|---|---|
static long |
addPrecision(long p1,
long p2)
Performs saturated addition of precision values.
|
static boolean |
areStableComparable(TypeInfo type1,
TypeInfo type2)
Returns whether values of the specified data types have
session-independent compare results.
|
static int |
convertSQLTypeToValueType(int sqlType)
Convert a SQL type to a value type.
|
static int |
convertSQLTypeToValueType(int sqlType,
java.lang.String sqlTypeName)
Convert a SQL type to a value type using SQL type name, in order to
manage SQL type extension mechanism.
|
static int |
convertSQLTypeToValueType(java.sql.SQLType sqlType)
Convert a SQL type to a value type.
|
static int |
convertTypeToSQLType(TypeInfo type)
Convert a value type to a SQL type.
|
static DataType |
createDate(int maxPrecision,
int precision,
java.lang.String prefix,
boolean supportsScale,
int scale,
int maxScale)
Create a date-time data type.
|
static DataType |
createNumeric(int precision,
int scale)
Create a numeric data type without parameters.
|
static DataType |
getDataType(int type)
Get the data type object for the given value type.
|
static java.lang.Object |
getDefaultForPrimitiveType(java.lang.Class<?> clazz)
Get the default value in the form of a Java object for the given Java
class.
|
static DataType |
getTypeByName(java.lang.String s,
Mode mode)
Get a data type object from a type name.
|
static int |
getValueTypeFromResultSet(java.sql.ResultSetMetaData meta,
int columnIndex)
Get the SQL type from the result set meta data for the given column.
|
static boolean |
hasTotalOrdering(int type)
Check if the given type has total ordering.
|
static boolean |
isBinaryColumn(java.sql.ResultSetMetaData meta,
int column)
Check whether the specified column needs the binary representation.
|
static boolean |
isBinaryStringOrSpecialBinaryType(int type)
Check if the given value type is a binary string type or a compatible
special data type such as Java object, UUID, geometry object, or JSON.
|
static boolean |
isBinaryStringType(int type)
Check if the given value type is a binary string type.
|
static boolean |
isCharacterStringType(int type)
Check if the given value type is a character string type.
|
static boolean |
isDateTimeType(int type)
Check if the given value type is a date-time type (TIME, DATE, TIMESTAMP,
TIMESTAMP_TZ).
|
static boolean |
isIndexable(TypeInfo type)
Returns whether columns with the specified data type may have an index.
|
static boolean |
isIntervalType(int type)
Check if the given value type is an interval type.
|
static boolean |
isLargeObject(int type)
Check if the given value type is a large object (BLOB or CLOB).
|
static boolean |
isNumericType(int type)
Check if the given value type is a numeric type.
|
static boolean |
isStringType(int type)
Check if the given value type is a String (VARCHAR,...).
|
static boolean |
isYearMonthIntervalType(int type)
Check if the given value type is a year-month interval type.
|
static java.lang.String |
sqlTypeToString(java.sql.SQLType sqlType)
Convert a SQL type to a debug string.
|
public int type
public int sqlType
public long minPrecision
public long maxPrecision
public int minScale
public int maxScale
public java.lang.String prefix
public java.lang.String suffix
public java.lang.String params
public boolean caseSensitive
public boolean supportsPrecision
public boolean supportsScale
public long defaultPrecision
public int defaultScale
public boolean specialPrecisionScale
public static DataType createNumeric(int precision, int scale)
precision - precisionscale - scalepublic static DataType createDate(int maxPrecision, int precision, java.lang.String prefix, boolean supportsScale, int scale, int maxScale)
maxPrecision - maximum supported precisionprecision - default precisionprefix - the prefix for SQL literal representationsupportsScale - whether the scale parameter is supportedscale - default scalemaxScale - highest possible scalepublic static DataType getDataType(int type)
type - the value typepublic static int convertTypeToSQLType(TypeInfo type)
type - the typepublic static int convertSQLTypeToValueType(int sqlType,
java.lang.String sqlTypeName)
sqlType - the SQL typesqlTypeName - the SQL type namepublic static int getValueTypeFromResultSet(java.sql.ResultSetMetaData meta,
int columnIndex)
throws java.sql.SQLException
meta - the meta datacolumnIndex - the column index (1, 2,...)java.sql.SQLException - on failurepublic static boolean isBinaryColumn(java.sql.ResultSetMetaData meta,
int column)
throws java.sql.SQLException
meta - metadatacolumn - column indextrue if column needs the binary representation,
false otherwisejava.sql.SQLException - on SQL exceptionpublic static int convertSQLTypeToValueType(java.sql.SQLType sqlType)
sqlType - the SQL typepublic static int convertSQLTypeToValueType(int sqlType)
sqlType - the SQL typepublic static java.lang.String sqlTypeToString(java.sql.SQLType sqlType)
sqlType - the SQL typepublic static DataType getTypeByName(java.lang.String s, Mode mode)
s - the type namemode - database modepublic static boolean isIndexable(TypeInfo type)
type - the data typepublic static boolean areStableComparable(TypeInfo type1, TypeInfo type2)
type1 - the first data typetype2 - the second data typepublic static boolean isDateTimeType(int type)
type - the value typepublic static boolean isIntervalType(int type)
type - the value typepublic static boolean isYearMonthIntervalType(int type)
type - the value typepublic static boolean isLargeObject(int type)
type - the value typepublic static boolean isNumericType(int type)
type - the value typepublic static boolean isBinaryStringType(int type)
type - the value typepublic static boolean isCharacterStringType(int type)
type - the value typepublic static boolean isStringType(int type)
type - the value typepublic static boolean isBinaryStringOrSpecialBinaryType(int type)
type - the value typepublic static boolean hasTotalOrdering(int type)
type - the value typepublic static long addPrecision(long p1,
long p2)
p1 - the first summandp2 - the second summandLong.MAX_VALUE if either argument
is negative or sum is out of rangepublic static java.lang.Object getDefaultForPrimitiveType(java.lang.Class<?> clazz)
clazz - the Java class