Top Description Fields Constructors Methods
org.apache.derby.iapi.types

public final Class DataTypeDescriptor

extends Object
implements Formatable
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.io.Formatable, org.apache.derby.iapi.services.io.TypedFormat, java.io.Externalizable, java.io.Serializable
Imports
java.io.IOException, .ObjectInput, .ObjectOutput, java.sql.Types, java.text.RuleBasedCollator, org.apache.derby.catalog.TypeDescriptor, org.apache.derby.catalog.types.RowMultiSetImpl, .TypeDescriptorImpl, .UserDefinedTypeIdImpl, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.Property, .SQLState, org.apache.derby.iapi.services.io.Formatable, .StoredFormatIds, org.apache.derby.iapi.services.loader.ClassFactory, .ClassInspector, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.conn.ConnectionUtil

DataTypeDescriptor describes a runtime SQL type. It consists of a catalog type (TypeDescriptor) and runtime attributes. The list of runtime attributes is:

A DataTypeDescriptor is immutable.

Field Summary

Modifier and TypeField and Description
private int
collationDerivation

Derivation of this type.

public static final DataTypeDescriptor
DOUBLE

Runtime INTEGER type that is nullable.

public static final DataTypeDescriptor
INTEGER

Runtime INTEGER type that is nullable.

public static final DataTypeDescriptor
INTEGER_NOT_NULL

Runtime INTEGER type that is not nullable.

public static final int
public static final int
public static final int
public static final DataTypeDescriptor
SMALLINT

Runtime SMALLINT type that is nullable.

public static final DataTypeDescriptor
SMALLINT_NOT_NULL

Runtime INTEGER type that is not nullable.

private TypeDescriptorImpl
private TypeId

Constructor Summary

AccessConstructor and Description
public
DataTypeDescriptor()

Public niladic constructor.

public
DataTypeDescriptor(TypeId
The typeId of the type being described
typeId
,
int
The number of decimal digits.
precision
,
int
The number of digits after the decimal point.
scale
,
boolean
TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.
isNullable
,
int
The maximum number of bytes for this datatype
maximumWidth
)

Constructor for use with numeric types

public
DataTypeDescriptor(TypeId
The typeId of the type being described
typeId
,
int
The number of decimal digits.
precision
,
int
The number of digits after the decimal point.
scale
,
boolean
TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.
isNullable
,
int
The maximum number of bytes for this datatype
maximumWidth
,
int
The collation type of a string data type
collationType
,
int
Collation Derivation of a string data type
collationDerivation
)

Constructor to use when the caller doesn't know if it is requesting numeric or no-numeric DTD.

public
DataTypeDescriptor(TypeId
The typeId of the type being described
typeId
,
boolean
TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.
isNullable
,
int
The maximum number of bytes for this datatype
maximumWidth
)

Constructor for use with non-numeric types

public
DataTypeDescriptor(TypeId typeId, boolean isNullable)

private
DataTypeDescriptor(DataTypeDescriptor source, boolean isNullable)

private
DataTypeDescriptor(DataTypeDescriptor source, int collationType, int collationDerivation)

public
DataTypeDescriptor(DataTypeDescriptor
The DTSI to copy
source
,
int
The number of decimal digits.
precision
,
int
The number of digits after the decimal point.
scale
,
boolean
TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.
isNullable
,
int
The maximum number of bytes for this datatype
maximumWidth
)

Constructor for internal uses only.

public
DataTypeDescriptor(DataTypeDescriptor
The DTSI to copy
source
,
boolean
TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.
isNullable
,
int
The maximum number of bytes for this datatype
maximumWidth
)

Constructor for internal uses only

private
DataTypeDescriptor(TypeDescriptorImpl
The TypeDescriptorImpl to construct this DTSI from
source
,
TypeId typeId)

Constructor for use in reconstructing a DataTypeDescriptor from a TypeDescriptorImpl and a TypeId

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if compareWithDTD is comparable to this type, else false.
comparable
(DataTypeDescriptor
the type of the instance to compare with this type.
compareWithDTD
,
boolean
True if this is an = or != comparison, false otherwise.
forEquals
,
ClassFactory
A ClassFactory
cf
)

Check if this type is comparable with the passed type.

public boolean

Returns:

value depends on the algorithm above.
compareCollationInfo
(DataTypeDescriptor
compare this DTD's collation info
compareWithDTD
)

Compare the collation info on this DTD with the passed DTD.

public boolean
equals(Object
the type to compare to.
other
)

Overrides java.lang.Object.equals.

Compare if two DataTypeDescriptors are exactly the same

public double
estimatedMemoryUsage()

Get the estimated memory usage for this type descriptor.

public static DataTypeDescriptor

Returns:

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type
getBuiltInDataTypeDescriptor
(int
The int type of the JDBC type for which to get a corresponding SQL DataTypeDescriptor
jdbcType
)

Get a descriptor that corresponds to a nullable builtin JDBC type.

public static DataTypeDescriptor

Returns:

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type
getBuiltInDataTypeDescriptor
(int
The int type of the JDBC type for which to get a corresponding SQL DataTypeDescriptor
jdbcType
,
int length)

Get a descriptor that corresponds to a nullable builtin variable length JDBC type.

public static DataTypeDescriptor

Returns:

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type
getBuiltInDataTypeDescriptor
(int
The int type of the JDBC type for which to get a corresponding SQL DataTypeDescriptor
jdbcType
,
boolean
TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.
isNullable
)

Get a descriptor that corresponds to a builtin JDBC type.

public static DataTypeDescriptor

Returns:

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type
getBuiltInDataTypeDescriptor
(int
The int type of the JDBC type for which to get a corresponding SQL DataTypeDescriptor
jdbcType
,
boolean
TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.
isNullable
,
int maxLength)

Get a descriptor that corresponds to a builtin JDBC type.

public static DataTypeDescriptor

Returns:

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type (only for 'char')
getBuiltInDataTypeDescriptor
(String
The name of the type for which to get a corresponding SQL DataTypeDescriptor
sqlTypeName
)

Get a DataTypeServices that corresponds to a nullable builtin SQL type.

public static DataTypeDescriptor

Returns:

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type (only for 'char')
getBuiltInDataTypeDescriptor
(String
The name of the type for which to get a corresponding SQL DataTypeDescriptor
sqlTypeName
,
int length)

Get a DataTypeServices that corresponds to a builtin SQL type Collation type will be UCS_BASIC and derivation IMPLICIT.

public static TypeDescriptor
getCatalogType(int jdbcType, int length)

Return a nullable catalog type for a JDBC builtin type and length.

public static TypeDescriptor
getCatalogType(int jdbcType)

Return a nullable catalog type for a fixed length JDBC builtin type.

public static TypeDescriptor

Returns:

catalogType if it already has the correct collation, otherwise a new TypeDescriptor with the correct collation.
getCatalogType
(TypeDescriptor
Type to be based upon.
catalogType
,
int
Collation type of returned type.
collationType
)

Get a catlog type identical to the passed in type exception that the collationType is set to the passed in value.

public TypeDescriptor
getCatalogType()

Get the simplified type descriptor that is intended to be stored in the system tables.

public DataTypeDescriptor

Returns:

This if collation would be unchanged otherwise a new type.
getCollatedType
(int collationType, int collationDerivation)

Return a type description identical to this type with the exception that its collation information is taken from the passed in information.

public int

Returns:

Should be COLLATION_DERIVATION_NONE or COLLATION_DERIVATION_IMPLICIT
getCollationDerivation
()

Get the collation derivation for this type.

public String

Returns:

the name of the collation being used in this type.
getCollationName
()

Gets the name of the collation type in this descriptor if the collation derivation is not NONE.

public static String

Returns:

The name, e g "TERRITORY_BASED:PRIMARY".
getCollationName
(int
The collation type.
collationType
)

Gets the name of the specified collation type.

public int
getCollationType()

Obtain the collation type of the underlying catalog type.

public static int

Returns:

The collation type, or -1 if not recognized.
getCollationType
(String collationName)

Obtain the collation type from a collation property value.

public DataTypeDescriptor

Returns:

DataTypeDescriptor DTS for dominant type
getDominantType
(DataTypeDescriptor
DataTypeDescriptor to compare with.
otherDTS
,
ClassFactory
A ClassFactory
cf
)

Get the dominant type (DataTypeDescriptor) of the 2.

public String
getFullSQLTypeName()

Return the SQL type name and, if applicable, scale/precision/length for this DataTypeDescriptor.

public int

Returns:

a jdbc type, e.g. java.sql.Types.DECIMAL
getJDBCTypeId
()

Get the jdbc type id for this type.

public int
getMaximumWidth()

Shorthand method for getCatalogType().getMaximumWidth().

public DataValueDescriptor
getNull()

Get a Null for this type.

public DataTypeDescriptor
getNullabilityType(boolean
True to return a nullable type, false otherwise.
isNullable
)

Return a type descriptor identical to the this type with the exception of its nullability.

public long[]
getNumericBounds()

Get the maximum and minimum value for a fixed numeric type.

public int

Returns:

The number of decimal digits for the datatype. Returns zero for non-numeric datatypes.
getPrecision
()

Returns the number of decimal digits for the datatype, if applicable.

public static TypeDescriptor

Returns:

A new DataTypeDescriptor describing the SQL Row Multiset
getRowMultiSet
(String[]
Names of the columns in the Row Muliset
columnNames
,
TypeDescriptor[]
Types of the columns in the Row Muliset
catalogTypes
)

Get a catalog type that corresponds to a SQL Row Multiset

private static TypeDescriptor

Returns:

this will be returned if no changes are required (e.g. no string types or collation is already correct), otherwise a new instance is returned (leaving this unchanged).
getRowMultiSetCollation
(TypeDescriptor catalogType, int collationType)

For a row multi set type return an identical type with the collation type changed.

public int

Returns:

The number of digits to the right of the decimal for the datatype. Returns zero for non-numeric datatypes.
getScale
()

Returns the number of digits to the right of the decimal for the datatype, if applicable.

public static DataTypeDescriptor

Returns:

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type (only for 'char')
getSQLDataTypeDescriptor
(String
The name of the Java type for which to get a corresponding SQL DataTypeDescriptor
javaTypeName
)

Get a DataTypeServices that corresponds to a Java type

public static DataTypeDescriptor

Returns:

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type (only for 'char')
getSQLDataTypeDescriptor
(String
The name of the Java type for which to get a corresponding SQL DataTypeDescriptor
javaTypeName
,
boolean
TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.
isNullable
)

Get a DataTypeServices that corresponds to a Java type

public static DataTypeDescriptor

Returns:

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type.
getSQLDataTypeDescriptor
(String
The name of the Java type for which to get a corresponding SQL DataTypeDescriptor
javaTypeName
,
int
The number of decimal digits
precision
,
int
The number of digits after the decimal point
scale
,
boolean
TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.
isNullable
,
int
The maximum width of a data value represented by this type.
maximumWidth
)

Get a DataTypeDescriptor that corresponds to a Java type

public String

Returns:

String version of datatype, suitable for running through the Parser.
getSQLstring
()

Converts this data type descriptor (including length/precision) to a string.

public String
public static DataTypeDescriptor
getType(TypeDescriptor catalogType)

Return a runtime type for a catalog type.

public int

Returns:

the formatID of this class
getTypeFormatId
()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get the formatID which corresponds to this class.

public TypeId

Returns:

The TypeId for the datatype.
getTypeId
()

Gets the TypeId for the datatype.

public String

Returns:

the name of this datatype
getTypeName
()

Gets the name of this datatype.

public static boolean

Returns:

true if an ASCII stream can be inserted; false otherwise
isAsciiStreamAssignable
(int
JDBC type of column or parameter
jdbcType
)

Determine if an ASCII stream can be inserted into a column or parameter of type jdbcType.

public static boolean

Returns:

true if a binary stream can be inserted; false otherwise
isBinaryStreamAssignable
(int
JDBC type of column or parameter
jdbcType
)

Determine if a binary stream can be inserted into a column or parameter of type jdbcType.

private static boolean

Returns:

true iff jdbcType is compatible with byte[]
isBinaryType
(int
a JDBC type
jdbcType
)

Check whether a JDBC type is compatible with the Java type byte[].

public static boolean

Returns:

true if a character stream can be inserted; false otherwise
isCharacterStreamAssignable
(int
JDBC type of column or parameter
jdbcType
)

Determine if a character stream can be inserted into a column or parameter of type jdbcType.

private static boolean

Returns:

true iff jdbcType is a character type and compatible with String
isCharacterType
(int
a JDBC type
jdbcType
)

Check whether a JDBC type is one of the character types that are compatible with the Java type String.

public boolean

Returns:

boolean Whether or not the 2 DTSs have the same type and length.
isExactTypeAndLengthMatch
(DataTypeDescriptor
DataTypeDescriptor to compare with.
otherDTS
)

Check whether or not the 2 types (DataTypeDescriptor) have the same type and length.

public static boolean

Returns:

boolean true if types are equivalent, false if not
isJDBCTypeEquivalent
(int
JDBC type id of Derby data type
existingType
,
int
JDBC type id passed in from application.
jdbcTypeId
)

Compare JdbcTypeIds to determine if they represent equivalent SQL types.

public boolean

Returns:

TRUE if the datatype can contain NULL, FALSE if not.
isNullable
()

Returns TRUE if the datatype can contain NULL, FALSE if not.

public static boolean
isNumericType(int jdbcType)

public boolean

Returns:

True if the type associated with this DTD can be created via the CREATE TABLE syntax; false otherwise.
isUserCreatableType
()

Check to make sure that this type id is something a user can create him/herself directly through an SQL CREATE TABLE statement.

public DataValueDescriptor
public void
readExternal(ObjectInput
read this.
in
)

Implements java.io.Externalizable.readExternal.

Read this object from a stream of stored objects.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
writeExternal(ObjectOutput
write bytes here.
out
)

Implements java.io.Externalizable.writeExternal.

Write this object to a stream of stored objects.

Inherited from java.lang.Object:
clonefinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

collationDerivationback to summary
private int collationDerivation

Derivation of this type. All catalog types are by definition implicit.

DOUBLEback to summary
public static final DataTypeDescriptor DOUBLE

Runtime INTEGER type that is nullable.

INTEGERback to summary
public static final DataTypeDescriptor INTEGER

Runtime INTEGER type that is nullable.

INTEGER_NOT_NULLback to summary
public static final DataTypeDescriptor INTEGER_NOT_NULL

Runtime INTEGER type that is not nullable.

MAX_MIN_ARRAY_SIZEback to summary
public static final int MAX_MIN_ARRAY_SIZE
MAX_VALUE_IDXback to summary
public static final int MAX_VALUE_IDX
MIN_VALUE_IDXback to summary
public static final int MIN_VALUE_IDX
SMALLINTback to summary
public static final DataTypeDescriptor SMALLINT

Runtime SMALLINT type that is nullable.

SMALLINT_NOT_NULLback to summary
public static final DataTypeDescriptor SMALLINT_NOT_NULL

Runtime INTEGER type that is not nullable.

typeDescriptorback to summary
private TypeDescriptorImpl typeDescriptor
typeIdback to summary
private TypeId typeId

Constructor Detail

DataTypeDescriptorback to summary
public DataTypeDescriptor()

Public niladic constructor. Needed for Formatable interface to work.

DataTypeDescriptorback to summary
public DataTypeDescriptor(TypeId typeId, int precision, int scale, boolean isNullable, int maximumWidth)

Constructor for use with numeric types

Parameters
typeId:TypeId

The typeId of the type being described

precision:int

The number of decimal digits.

scale:int

The number of digits after the decimal point.

isNullable:boolean

TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.

maximumWidth:int

The maximum number of bytes for this datatype

DataTypeDescriptorback to summary
public DataTypeDescriptor(TypeId typeId, int precision, int scale, boolean isNullable, int maximumWidth, int collationType, int collationDerivation)

Constructor to use when the caller doesn't know if it is requesting numeric or no-numeric DTD. For instance, when dealing with MAX/MIN aggregrate operators, AggregateNode.bindExpression could be dealing with a character string operand or a numeric operand. The result of MAX/MIN will depend on the type of it's operand. And hence when this constructor gets called by AggregateNode.bindExpression, we don't know what type we are constructing and hence this constructor supports arguments for both numeric and non-numeric types.

Parameters
typeId:TypeId

The typeId of the type being described

precision:int

The number of decimal digits.

scale:int

The number of digits after the decimal point.

isNullable:boolean

TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.

maximumWidth:int

The maximum number of bytes for this datatype

collationType:int

The collation type of a string data type

collationDerivation:int

Collation Derivation of a string data type

DataTypeDescriptorback to summary
public DataTypeDescriptor(TypeId typeId, boolean isNullable, int maximumWidth)

Constructor for use with non-numeric types

Parameters
typeId:TypeId

The typeId of the type being described

isNullable:boolean

TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.

maximumWidth:int

The maximum number of bytes for this datatype

DataTypeDescriptorback to summary
public DataTypeDescriptor(TypeId typeId, boolean isNullable)
DataTypeDescriptorback to summary
private DataTypeDescriptor(DataTypeDescriptor source, boolean isNullable)
DataTypeDescriptorback to summary
private DataTypeDescriptor(DataTypeDescriptor source, int collationType, int collationDerivation)
DataTypeDescriptorback to summary
public DataTypeDescriptor(DataTypeDescriptor source, int precision, int scale, boolean isNullable, int maximumWidth)

Constructor for internal uses only. (This is useful when the precision and scale are potentially wider than those in the source, like when determining the dominant data type.)

Parameters
source:DataTypeDescriptor

The DTSI to copy

precision:int

The number of decimal digits.

scale:int

The number of digits after the decimal point.

isNullable:boolean

TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.

maximumWidth:int

The maximum number of bytes for this datatype

DataTypeDescriptorback to summary
public DataTypeDescriptor(DataTypeDescriptor source, boolean isNullable, int maximumWidth)

Constructor for internal uses only

Parameters
source:DataTypeDescriptor

The DTSI to copy

isNullable:boolean

TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.

maximumWidth:int

The maximum number of bytes for this datatype

DataTypeDescriptorback to summary
private DataTypeDescriptor(TypeDescriptorImpl source, TypeId typeId)

Constructor for use in reconstructing a DataTypeDescriptor from a TypeDescriptorImpl and a TypeId

Parameters
source:TypeDescriptorImpl

The TypeDescriptorImpl to construct this DTSI from

Method Detail

comparableback to summary
public boolean comparable(DataTypeDescriptor compareWithDTD, boolean forEquals, ClassFactory cf)

Check if this type is comparable with the passed type.

Parameters
compareWithDTD:DataTypeDescriptor

the type of the instance to compare with this type.

forEquals:boolean

True if this is an = or != comparison, false otherwise.

cf:ClassFactory

A ClassFactory

Returns:boolean

true if compareWithDTD is comparable to this type, else false.

compareCollationInfoback to summary
public boolean compareCollationInfo(DataTypeDescriptor compareWithDTD)

Compare the collation info on this DTD with the passed DTD. The rules for comparison are as follows (these are as per SQL standard 2003 Section 9.13) 1)If both the DTDs have collation derivation of NONE, then they can't be compared and we return false. 2)If both the DTDs have same collation derivation (which in Derby's case at this point will mean collation derivation of IMPLICIT), then check the collation types. If they match, then return true. If they do not match, then they can't be compared and hence return false. 3)If one DTD has collation derivation of IMPLICIT and other DTD has collation derivation of NONE, then 2 DTDs are comparable using the collation type of DTD with collation derivation of IMPLICIT. Derby does not implement this rule currently and it is being traked as DERBY-2678. Derby's current behavior is to throw an exception if both the DTDs involved in collation operation do not have collation derivation of IMPLICIT. This behavior is a subset of SQL standard. 4)Derby currently does not support collation derivation of EXPLICIT and hence we do not have the code to enforce rules as mentioned in Section 9.13 of SQL spec for collation derivation of EXPLICIT. When we implement collation derivation of EXPLICIT, we should make sure that we follow the rules as specified in the SQL spec for comparability.

Parameters
compareWithDTD:DataTypeDescriptor

compare this DTD's collation info

Returns:boolean

value depends on the algorithm above.

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Compare if two DataTypeDescriptors are exactly the same

Parameters
other:Object

the type to compare to.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

estimatedMemoryUsageback to summary
public double estimatedMemoryUsage()

Get the estimated memory usage for this type descriptor.

getBuiltInDataTypeDescriptorback to summary
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType)

Get a descriptor that corresponds to a nullable builtin JDBC type. If a variable length type then the size information will be set to the maximum possible. Collation type will be UCS_BASIC and derivation IMPLICIT. For well known types code may also use the pre-defined runtime types that are fields of this class, such as INTEGER.

Parameters
jdbcType:int

The int type of the JDBC type for which to get a corresponding SQL DataTypeDescriptor

Returns:DataTypeDescriptor

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type

getBuiltInDataTypeDescriptorback to summary
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType, int length)

Get a descriptor that corresponds to a nullable builtin variable length JDBC type. Collation type will be UCS_BASIC and derivation IMPLICIT.

Parameters
jdbcType:int

The int type of the JDBC type for which to get a corresponding SQL DataTypeDescriptor

Returns:DataTypeDescriptor

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type

getBuiltInDataTypeDescriptorback to summary
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType, boolean isNullable)

Get a descriptor that corresponds to a builtin JDBC type. For well known types code may also use the pre-defined runtime types that are fields of this class, such as INTEGER. E.g. using DataTypeDescriptor.INTEGER is preferred to DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.INTEGER, true) (both will return the same immutable object).

Parameters
jdbcType:int

The int type of the JDBC type for which to get a corresponding SQL DataTypeDescriptor

isNullable:boolean

TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.

Returns:DataTypeDescriptor

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type

getBuiltInDataTypeDescriptorback to summary
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType, boolean isNullable, int maxLength)

Get a descriptor that corresponds to a builtin JDBC type. Collation type will be UCS_BASIC and derivation IMPLICIT.

Parameters
jdbcType:int

The int type of the JDBC type for which to get a corresponding SQL DataTypeDescriptor

isNullable:boolean

TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.

Returns:DataTypeDescriptor

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type

getBuiltInDataTypeDescriptorback to summary
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(String sqlTypeName)

Get a DataTypeServices that corresponds to a nullable builtin SQL type. Collation type will be UCS_BASIC and derivation IMPLICIT.

Parameters
sqlTypeName:String

The name of the type for which to get a corresponding SQL DataTypeDescriptor

Returns:DataTypeDescriptor

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type (only for 'char')

getBuiltInDataTypeDescriptorback to summary
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(String sqlTypeName, int length)

Get a DataTypeServices that corresponds to a builtin SQL type Collation type will be UCS_BASIC and derivation IMPLICIT.

Parameters
sqlTypeName:String

The name of the type for which to get a corresponding SQL DataTypeDescriptor

Returns:DataTypeDescriptor

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type (only for 'char')

getCatalogTypeback to summary
public static TypeDescriptor getCatalogType(int jdbcType, int length)

Return a nullable catalog type for a JDBC builtin type and length.

getCatalogTypeback to summary
public static TypeDescriptor getCatalogType(int jdbcType)

Return a nullable catalog type for a fixed length JDBC builtin type.

getCatalogTypeback to summary
public static TypeDescriptor getCatalogType(TypeDescriptor catalogType, int collationType)

Get a catlog type identical to the passed in type exception that the collationType is set to the passed in value.

Parameters
catalogType:TypeDescriptor

Type to be based upon.

collationType:int

Collation type of returned type.

Returns:TypeDescriptor

catalogType if it already has the correct collation, otherwise a new TypeDescriptor with the correct collation.

getCatalogTypeback to summary
public TypeDescriptor getCatalogType()

Get the simplified type descriptor that is intended to be stored in the system tables.

getCollatedTypeback to summary
public DataTypeDescriptor getCollatedType(int collationType, int collationDerivation)

Return a type description identical to this type with the exception that its collation information is taken from the passed in information. If the type does not represent a string type then the collation will be unchanged and this is returned.

Returns:DataTypeDescriptor

This if collation would be unchanged otherwise a new type.

getCollationDerivationback to summary
public int getCollationDerivation()

Get the collation derivation for this type. This applies only for character string types. For the other types, this api should be ignored. SQL spec talks about character string types having collation type and collation derivation associated with them (SQL spec Section 4.2.2 Comparison of character strings). If collation derivation says explicit or implicit, then it means that there is a valid collation type associated with the charcter string type. If the collation derivation is none, then it means that collation type can't be established for the character string type. 1)Collation derivation will be explicit if SQL COLLATE clause has been used for character string type (this is not a possibility for Derby 10.3 because we are not planning to support SQL COLLATE clause in the 10.3 release). 2)Collation derivation will be implicit if the collation can be determined w/o the COLLATE clause eg CREATE TABLE t1(c11 char(4)) then c11 will have collation of USER character set. Another eg, TRIM(c11) then the result character string of TRIM operation will have collation of the operand, c11. 3)Collation derivation will be none if the aggregate methods are dealing with character strings with different collations (Section 9.3 Data types of results of aggregations Syntax Rule 3aii). Collation derivation will be initialized to COLLATION_DERIVATION_IMPLICIT if not explicitly set.

Returns:int

Should be COLLATION_DERIVATION_NONE or COLLATION_DERIVATION_IMPLICIT

See Also
StringDataValue#COLLATION_DERIVATION_NONE, StringDataValue#COLLATION_DERIVATION_IMPLICIT, StringDataValue#COLLATION_DERIVATION_EXPLICIT
getCollationNameback to summary
public String getCollationName()

Gets the name of the collation type in this descriptor if the collation derivation is not NONE. If the collation derivation is NONE, then this method will return "NONE".

This method is used for generating error messages which will use correct string describing collation type/derivation.

Returns:String

the name of the collation being used in this type.

getCollationNameback to summary
public static String getCollationName(int collationType)

Gets the name of the specified collation type.

Parameters
collationType:int

The collation type.

Returns:String

The name, e g "TERRITORY_BASED:PRIMARY".

getCollationTypeback to summary
public int getCollationType()

Obtain the collation type of the underlying catalog type. Shorthand method for getCatalogType().getCollationType().

See Also
TypeDescriptor#getCollationType()
getCollationTypeback to summary
public static int getCollationType(String collationName)

Obtain the collation type from a collation property value.

Returns:int

The collation type, or -1 if not recognized.

getDominantTypeback to summary
public DataTypeDescriptor getDominantType(DataTypeDescriptor otherDTS, ClassFactory cf)

Get the dominant type (DataTypeDescriptor) of the 2. For variable length types, the resulting type will have the biggest max length of the 2. If either side is nullable, then the result will also be nullable. If dealing with character string types, then make sure to set the collation info on the dominant type. Following algorithm will be used for dominant DTD's collation determination. Each of the steps of the algorithm have been numbered in the comments below and those same numbers are used in the actual algorithm below so it is easier to understand and maintain. Step 1 If the DTD for "this" node has the same collation derivation as the otherDTS, then check if their collation types match too. If the collation types match too, then DTD for dominant type will get the same collation derivation and type. Step 2 If the collation derivation for DTD for "this" node and otherDTS do not match, then check if one of them has the collation derivation of NONE. If that is the case, then dominant DTD will get the collation type and derivation of DTD whose collation derivation is not NONE. Step 3 If the collation derivation for DTD for "this" node and otherDTS do not match, and none of them have the derivation of NONE then it means that we are dealing with collation derivation of IMPLICIT and EXPLICIT and hence the dominant DTD should get collation derivation of NONE. This is not a possibility in Derby 10.3 because the only 2 possible collation derivation supported are IMPLICIT and NONE. Step 4 If the collation derivation for DTD for "this" node and otherDTS match, then check if the collation types match too. If not, then the dominant DTD should get collation derivation of NONE.

Parameters
otherDTS:DataTypeDescriptor

DataTypeDescriptor to compare with.

cf:ClassFactory

A ClassFactory

Returns:DataTypeDescriptor

DataTypeDescriptor DTS for dominant type

getFullSQLTypeNameback to summary
public String getFullSQLTypeName()

Return the SQL type name and, if applicable, scale/precision/length for this DataTypeDescriptor. Note that we want the values from *this* object specifically, not the max values defined on this.typeId.

getJDBCTypeIdback to summary
public int getJDBCTypeId()

Get the jdbc type id for this type. JDBC type can be found in java.sql.Types. Shorthand method for getCatalogType().getJDBCTypeId().

Returns:int

a jdbc type, e.g. java.sql.Types.DECIMAL

See Also
Types
getMaximumWidthback to summary
public int getMaximumWidth()

Shorthand method for getCatalogType().getMaximumWidth().

See Also
TypeDescriptor#getMaximumWidth
getNullback to summary
public DataValueDescriptor getNull() throws StandardException

Get a Null for this type.

getNullabilityTypeback to summary
public DataTypeDescriptor getNullabilityType(boolean isNullable)

Return a type descriptor identical to the this type with the exception of its nullability. If the nullablity required matches the nullability of this then this is returned.

Parameters
isNullable:boolean

True to return a nullable type, false otherwise.

getNumericBoundsback to summary
public long[] getNumericBounds() throws StandardException

Get the maximum and minimum value for a fixed numeric type. Throws an unimplemented feature exception for a non-numeric type.

getPrecisionback to summary
public int getPrecision()

Returns the number of decimal digits for the datatype, if applicable. Shorthand method for getCatalogType().getPrecision().

Returns:int

The number of decimal digits for the datatype. Returns zero for non-numeric datatypes.

See Also
TypeDescriptor#getPrecision()
getRowMultiSetback to summary
public static TypeDescriptor getRowMultiSet(String[] columnNames, TypeDescriptor[] catalogTypes)

Get a catalog type that corresponds to a SQL Row Multiset

Parameters
columnNames:String[]

Names of the columns in the Row Muliset

catalogTypes:TypeDescriptor[]

Types of the columns in the Row Muliset

Returns:TypeDescriptor

A new DataTypeDescriptor describing the SQL Row Multiset

getRowMultiSetCollationback to summary
private static TypeDescriptor getRowMultiSetCollation(TypeDescriptor catalogType, int collationType)

For a row multi set type return an identical type with the collation type changed. Note that since row types are only ever catalog types the derivation is not used (since derivation is a property of runtime types).

Returns:TypeDescriptor

this will be returned if no changes are required (e.g. no string types or collation is already correct), otherwise a new instance is returned (leaving this unchanged).

getScaleback to summary
public int getScale()

Returns the number of digits to the right of the decimal for the datatype, if applicable. Shorthand method for getCatalogType().getScale().

Returns:int

The number of digits to the right of the decimal for the datatype. Returns zero for non-numeric datatypes.

See Also
TypeDescriptor#getScale()
getSQLDataTypeDescriptorback to summary
public static DataTypeDescriptor getSQLDataTypeDescriptor(String javaTypeName) throws StandardException

Get a DataTypeServices that corresponds to a Java type

Parameters
javaTypeName:String

The name of the Java type for which to get a corresponding SQL DataTypeDescriptor

Returns:DataTypeDescriptor

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type (only for 'char')

getSQLDataTypeDescriptorback to summary
public static DataTypeDescriptor getSQLDataTypeDescriptor(String javaTypeName, boolean isNullable) throws StandardException

Get a DataTypeServices that corresponds to a Java type

Parameters
javaTypeName:String

The name of the Java type for which to get a corresponding SQL DataTypeDescriptor

isNullable:boolean

TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.

Returns:DataTypeDescriptor

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type (only for 'char')

getSQLDataTypeDescriptorback to summary
public static DataTypeDescriptor getSQLDataTypeDescriptor(String javaTypeName, int precision, int scale, boolean isNullable, int maximumWidth) throws StandardException

Get a DataTypeDescriptor that corresponds to a Java type

Parameters
javaTypeName:String

The name of the Java type for which to get a corresponding SQL DataTypeDescriptor

precision:int

The number of decimal digits

scale:int

The number of digits after the decimal point

isNullable:boolean

TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.

maximumWidth:int

The maximum width of a data value represented by this type.

Returns:DataTypeDescriptor

A new DataTypeDescriptor that corresponds to the Java type. A null return value means there is no corresponding SQL type.

getSQLstringback to summary
public String getSQLstring()

Converts this data type descriptor (including length/precision) to a string. E.g. VARCHAR(30) or java.util.Hashtable

Returns:String

String version of datatype, suitable for running through the Parser.

getSQLTypeNameWithCollationback to summary
public String getSQLTypeNameWithCollation()
getTypeback to summary
public static DataTypeDescriptor getType(TypeDescriptor catalogType)

Return a runtime type for a catalog type.

getTypeFormatIdback to summary
public int getTypeFormatId()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get the formatID which corresponds to this class.

Returns:int

the formatID of this class

getTypeIdback to summary
public TypeId getTypeId()

Gets the TypeId for the datatype.

Returns:TypeId

The TypeId for the datatype.

getTypeNameback to summary
public String getTypeName()

Gets the name of this datatype.

Returns:String

the name of this datatype

isAsciiStreamAssignableback to summary
public static boolean isAsciiStreamAssignable(int jdbcType)

Determine if an ASCII stream can be inserted into a column or parameter of type jdbcType.

Parameters
jdbcType:int

JDBC type of column or parameter

Returns:boolean

true if an ASCII stream can be inserted; false otherwise

isBinaryStreamAssignableback to summary
public static boolean isBinaryStreamAssignable(int jdbcType)

Determine if a binary stream can be inserted into a column or parameter of type jdbcType.

Parameters
jdbcType:int

JDBC type of column or parameter

Returns:boolean

true if a binary stream can be inserted; false otherwise

isBinaryTypeback to summary
private static boolean isBinaryType(int jdbcType)

Check whether a JDBC type is compatible with the Java type byte[].

Note

BLOB is not compatible with byte[]. See tables B-4, B-5 and B-6 in the JDBC 3.0 Specification.

Parameters
jdbcType:int

a JDBC type

Returns:boolean

true iff jdbcType is compatible with byte[]

See Also
java.sql.Types
isCharacterStreamAssignableback to summary
public static boolean isCharacterStreamAssignable(int jdbcType)

Determine if a character stream can be inserted into a column or parameter of type jdbcType.

Parameters
jdbcType:int

JDBC type of column or parameter

Returns:boolean

true if a character stream can be inserted; false otherwise

isCharacterTypeback to summary
private static boolean isCharacterType(int jdbcType)

Check whether a JDBC type is one of the character types that are compatible with the Java type String.

Note

CLOB is not compatible with String. See tables B-4, B-5 and B-6 in the JDBC 3.0 Specification.

There are some non-character types that are compatible with String (examples: numeric types, binary types and time-related types), but they are not covered by this method.

Parameters
jdbcType:int

a JDBC type

Returns:boolean

true iff jdbcType is a character type and compatible with String

See Also
java.sql.Types
isExactTypeAndLengthMatchback to summary
public boolean isExactTypeAndLengthMatch(DataTypeDescriptor otherDTS)

Check whether or not the 2 types (DataTypeDescriptor) have the same type and length. This is useful for UNION when trying to decide whether a NormalizeResultSet is required.

Parameters
otherDTS:DataTypeDescriptor

DataTypeDescriptor to compare with.

Returns:boolean

boolean Whether or not the 2 DTSs have the same type and length.

isJDBCTypeEquivalentback to summary
public static boolean isJDBCTypeEquivalent(int existingType, int jdbcTypeId)

Compare JdbcTypeIds to determine if they represent equivalent SQL types. For example Types.NUMERIC and Types.DECIMAL are equivalent

Parameters
existingType:int

JDBC type id of Derby data type

jdbcTypeId:int

JDBC type id passed in from application.

Returns:boolean

boolean true if types are equivalent, false if not

isNullableback to summary
public boolean isNullable()

Returns TRUE if the datatype can contain NULL, FALSE if not. JDBC supports a return value meaning "nullability unknown" - I assume we will never have columns where the nullability is unknown. Shorthand method for getCatalogType().isNullable();

Returns:boolean

TRUE if the datatype can contain NULL, FALSE if not.

isNumericTypeback to summary
public static boolean isNumericType(int jdbcType)
isUserCreatableTypeback to summary
public boolean isUserCreatableType() throws StandardException

Check to make sure that this type id is something a user can create him/herself directly through an SQL CREATE TABLE statement. This method is used for CREATE TABLE AS ... WITH [NO] DATA binding because it's possible for the query to return types which are not actually creatable for a user. DERBY-2605. Three examples are: JAVA_OBJECT: A user can select columns of various java object types from system tables, but s/he is not allowed to create such a column him/herself. DECIMAL: A user can specify a VALUES clause with a constant that has a precision of greater than 31. Derby can apparently handle such a value internally, but the user is not supposed to be able create such a column him/herself.

Returns:boolean

True if the type associated with this DTD can be created via the CREATE TABLE syntax; false otherwise.

normalizeback to summary
public DataValueDescriptor normalize(DataValueDescriptor source, DataValueDescriptor cachedDest) throws StandardException
readExternalback to summary
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Implements java.io.Externalizable.readExternal.

Read this object from a stream of stored objects.

Parameters
in:ObjectInput

read this.

Exceptions
IOException:
thrown on error
ClassNotFoundException:
thrown on error
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

writeExternalback to summary
public void writeExternal(ObjectOutput out) throws IOException

Implements java.io.Externalizable.writeExternal.

Write this object to a stream of stored objects.

Parameters
out:ObjectOutput

write bytes here.

Exceptions
IOException:
thrown on error