public final class DataTypeDescriptor
extends java.lang.Object
A DataTypeDescriptor is immutable.
Modifier and Type | Field and Description |
---|---|
static DataTypeDescriptor |
INTEGER
Runtime INTEGER type that is nullable.
|
static DataTypeDescriptor |
INTEGER_NOT_NULL
Runtime INTEGER type that is not nullable.
|
static int |
MAXIMUM_WIDTH_UNKNOWN |
static DataTypeDescriptor |
MEDIUMINT |
static DataTypeDescriptor |
MEDIUMINT_NOT_NULL |
static DataTypeDescriptor |
SMALLINT
Runtime SMALLINT type that is nullable.
|
static DataTypeDescriptor |
SMALLINT_NOT_NULL
Runtime INTEGER type that is not nullable.
|
Constructor and Description |
---|
DataTypeDescriptor(DataTypeDescriptor source,
CharacterTypeAttributes characterAttributes) |
DataTypeDescriptor(TypeId typeId,
boolean isNullable) |
DataTypeDescriptor(TypeId typeId,
boolean isNullable,
int maximumWidth)
Constructor for use with non-numeric types
|
DataTypeDescriptor(TypeId typeId,
boolean isNullable,
int maximumWidth,
CharacterTypeAttributes characterAttributes) |
DataTypeDescriptor(TypeId typeId,
int precision,
int scale,
boolean isNullable,
int maximumWidth)
Constructor for use with numeric types
|
Modifier and Type | Method and Description |
---|---|
boolean |
comparable(DataTypeDescriptor compareWithDTD,
boolean forEquals)
Check if this type is comparable with the passed type.
|
static int |
computeMaxWidth(int precision,
int scale)
Compute the maximum width (column display width) of a decimal or numeric data value,
given its precision and scale.
|
boolean |
equals(java.lang.Object other)
Compare if two DataTypeDescriptors are exactly the same
|
static DataTypeDescriptor |
getBuiltInDataTypeDescriptor(int jdbcType)
Get a descriptor that corresponds to a nullable builtin JDBC type.
|
static DataTypeDescriptor |
getBuiltInDataTypeDescriptor(int jdbcType,
boolean isNullable)
Get a descriptor that corresponds to a builtin JDBC type.
|
static DataTypeDescriptor |
getBuiltInDataTypeDescriptor(int jdbcType,
boolean isNullable,
int maxLength)
Get a descriptor that corresponds to a builtin JDBC type.
|
static DataTypeDescriptor |
getBuiltInDataTypeDescriptor(int jdbcType,
int length)
Get a descriptor that corresponds to a nullable builtin variable
length JDBC type.
|
static DataTypeDescriptor |
getBuiltInDataTypeDescriptor(java.lang.String sqlTypeName)
Get a DataTypeDescriptor that corresponds to a nullable builtin SQL type.
|
static DataTypeDescriptor |
getBuiltInDataTypeDescriptor(java.lang.String sqlTypeName,
int length)
Get a DataTypeDescriptor that corresponds to a builtin SQL type
Collation type will be UCS_BASIC and derivation IMPLICIT.
|
CharacterTypeAttributes |
getCharacterAttributes() |
DataTypeDescriptor |
getDominantType(DataTypeDescriptor otherDTS)
Get the dominant type (DataTypeDescriptor) of the 2.
|
java.lang.String |
getFullSQLTypeName()
Return the SQL type name and, if applicable, scale/precision/length
for this DataTypeDescriptor.
|
int |
getJDBCTypeId()
Get the jdbc type id for this type.
|
int |
getMaximumWidth()
Get maximum width.
|
DataTypeDescriptor |
getNullabilityType(boolean isNullable)
Return a type descriptor identical to the this type
with the exception of its nullability.
|
int |
getPrecision()
Returns the number of decimal digits for the datatype, if applicable.
|
static DataTypeDescriptor |
getRowMultiSet(java.lang.String[] columnNames,
DataTypeDescriptor[] columnTypes)
Get a catalog type that corresponds to a SQL Row Multiset
|
int |
getScale()
Returns the number of digits to the right of the decimal for
the datatype, if applicable.
|
static DataTypeDescriptor |
getSQLDataTypeDescriptor(java.lang.String javaTypeName)
Get a DataTypeDescriptor that corresponds to a Java type
|
static DataTypeDescriptor |
getSQLDataTypeDescriptor(java.lang.String javaTypeName,
boolean isNullable)
Get a DataTypeDescriptor that corresponds to a Java type
|
static DataTypeDescriptor |
getSQLDataTypeDescriptor(java.lang.String javaTypeName,
int precision,
int scale,
boolean isNullable,
int maximumWidth)
Get a DataTypeDescriptor that corresponds to a Java type
|
java.lang.String |
getSQLstring()
Converts this data type descriptor (including length/precision)
to a string.
|
TypeId |
getTypeId()
Gets the TypeId for the datatype.
|
java.lang.String |
getTypeName()
Gets the name of this datatype.
|
DataTypeDescriptor |
getUnsigned() |
static int |
intervalMaxWidth(TypeId typeId,
int precision,
int scale) |
static boolean |
isAsciiStreamAssignable(int jdbcType)
Determine if an ASCII stream can be inserted into a column or parameter
of type
jdbcType . |
static boolean |
isBinaryStreamAssignable(int jdbcType)
Determine if a binary stream can be inserted into a column or parameter
of type
jdbcType . |
static boolean |
isCharacterStreamAssignable(int jdbcType)
Determine if a character stream can be inserted into a column or
parameter of type
jdbcType . |
static boolean |
isJDBCTypeEquivalent(int existingType,
int jdbcTypeId)
Compare JdbcTypeIds to determine if they represent equivalent
SQL types.
|
boolean |
isNullable()
Returns TRUE if the datatype can contain NULL, FALSE if not.
|
static boolean |
isNumericType(int jdbcType) |
boolean |
isRowMultiSet() |
java.lang.String |
toString() |
public static final int MAXIMUM_WIDTH_UNKNOWN
public static final DataTypeDescriptor MEDIUMINT
public static final DataTypeDescriptor MEDIUMINT_NOT_NULL
public static final DataTypeDescriptor INTEGER
public static final DataTypeDescriptor INTEGER_NOT_NULL
public static final DataTypeDescriptor SMALLINT
public static final DataTypeDescriptor SMALLINT_NOT_NULL
public DataTypeDescriptor(TypeId typeId, int precision, int scale, boolean isNullable, int maximumWidth)
typeId
- The typeId of the type being describedprecision
- The number of decimal digits.scale
- The number of digits after the decimal point.isNullable
- TRUE means it could contain NULL, FALSE means
it definitely cannot contain NULL.maximumWidth
- The maximum number of bytes for this datatypepublic DataTypeDescriptor(TypeId typeId, boolean isNullable, int maximumWidth)
typeId
- The typeId of the type being describedisNullable
- TRUE means it could contain NULL, FALSE means
it definitely cannot contain NULL.maximumWidth
- The maximum number of bytes for this datatypepublic DataTypeDescriptor(TypeId typeId, boolean isNullable)
public DataTypeDescriptor(TypeId typeId, boolean isNullable, int maximumWidth, CharacterTypeAttributes characterAttributes)
public DataTypeDescriptor(DataTypeDescriptor source, CharacterTypeAttributes characterAttributes)
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType)
jdbcType
- The int type of the JDBC type for which to get
a corresponding SQL DataTypeDescriptorpublic static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType, int length)
jdbcType
- The int type of the JDBC type for which to get
a corresponding SQL DataTypeDescriptorpublic static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType, boolean isNullable)
jdbcType
- The int type of the JDBC type for which to get
a corresponding SQL DataTypeDescriptorisNullable
- TRUE means it could contain NULL, FALSE means
it definitely cannot contain NULL.public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType, boolean isNullable, int maxLength)
jdbcType
- The int type of the JDBC type for which to get
a corresponding SQL DataTypeDescriptorisNullable
- TRUE means it could contain NULL, FALSE means
it definitely cannot contain NULL.public static DataTypeDescriptor getBuiltInDataTypeDescriptor(java.lang.String sqlTypeName)
sqlTypeName
- The name of the type for which to get
a corresponding SQL DataTypeDescriptorpublic static DataTypeDescriptor getBuiltInDataTypeDescriptor(java.lang.String sqlTypeName, int length)
sqlTypeName
- The name of the type for which to get
a corresponding SQL DataTypeDescriptorpublic static DataTypeDescriptor getSQLDataTypeDescriptor(java.lang.String javaTypeName) throws StandardException
javaTypeName
- The name of the Java type for which to get
a corresponding SQL DataTypeDescriptorStandardException
public static DataTypeDescriptor getSQLDataTypeDescriptor(java.lang.String javaTypeName, boolean isNullable) throws StandardException
javaTypeName
- The name of the Java type for which to get
a corresponding SQL DataTypeDescriptorisNullable
- TRUE means it could contain NULL, FALSE means
it definitely cannot contain NULL.StandardException
public static DataTypeDescriptor getSQLDataTypeDescriptor(java.lang.String javaTypeName, int precision, int scale, boolean isNullable, int maximumWidth) throws StandardException
javaTypeName
- The name of the Java type for which to get
a corresponding SQL DataTypeDescriptorprecision
- The number of decimal digitsscale
- The number of digits after the decimal pointisNullable
- TRUE means it could contain NULL, FALSE means
it definitely cannot contain NULL.maximumWidth
- The maximum width of a data value
represented by this type.StandardException
public static DataTypeDescriptor getRowMultiSet(java.lang.String[] columnNames, DataTypeDescriptor[] columnTypes)
columnNames
- Names of the columns in the Row MulisetcatalogTypes
- Types of the columns in the Row Mulisetpublic DataTypeDescriptor getDominantType(DataTypeDescriptor otherDTS) throws StandardException
otherDTS
- DataTypeDescriptor to compare with.StandardException
- Thrown on errorpublic int getMaximumWidth()
public TypeId getTypeId()
public java.lang.String getTypeName()
public int getJDBCTypeId()
Types
public int getPrecision()
TypeDescriptor#getPrecision()
public int getScale()
TypeDescriptor#getScale()
public boolean isNullable()
public boolean isRowMultiSet()
public DataTypeDescriptor getNullabilityType(boolean isNullable)
isNullable
- True to return a nullable type, false otherwise.public CharacterTypeAttributes getCharacterAttributes()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- the type to compare to.public boolean comparable(DataTypeDescriptor compareWithDTD, boolean forEquals)
compareWithDTD
- the type of the instance to compare with this type.forEquals
- True if this is an = or <> comparison, false
otherwise.public java.lang.String getSQLstring()
public static boolean isJDBCTypeEquivalent(int existingType, int jdbcTypeId)
existingType
- JDBC type id of Derby data typejdbcTypeId
- JDBC type id passed in from application.public static boolean isNumericType(int jdbcType)
public static boolean isAsciiStreamAssignable(int jdbcType)
jdbcType
.jdbcType
- JDBC type of column or parametertrue
if an ASCII stream can be inserted;
false
otherwisepublic static boolean isBinaryStreamAssignable(int jdbcType)
jdbcType
.jdbcType
- JDBC type of column or parametertrue
if a binary stream can be inserted;
false
otherwisepublic static boolean isCharacterStreamAssignable(int jdbcType)
jdbcType
.jdbcType
- JDBC type of column or parametertrue
if a character stream can be inserted;
false
otherwisepublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getFullSQLTypeName()
public static int computeMaxWidth(int precision, int scale)
precision
- The precision (number of digits) of the data value.scale
- The number of fractional digits (digits to the right of the decimal point).public DataTypeDescriptor getUnsigned() throws StandardException
StandardException
public static int intervalMaxWidth(TypeId typeId, int precision, int scale)
Copyright © 2013. All Rights Reserved.