|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.iapi.types.DataTypeDescriptor
public final class DataTypeDescriptor
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 | |
---|---|
private int |
collationDerivation
Derivation of this type. |
static DataTypeDescriptor |
INTEGER
Runtime INTEGER type that is nullable. |
static DataTypeDescriptor |
INTEGER_NOT_NULL
Runtime INTEGER type that is not nullable. |
static DataTypeDescriptor |
SMALLINT
Runtime SMALLINT type that is nullable. |
static DataTypeDescriptor |
SMALLINT_NOT_NULL
Runtime INTEGER type that is not nullable. |
private TypeDescriptorImpl |
typeDescriptor
|
private TypeId |
typeId
|
Constructor Summary | |
---|---|
|
DataTypeDescriptor()
Public niladic constructor. |
private |
DataTypeDescriptor(DataTypeDescriptor source,
boolean isNullable)
|
|
DataTypeDescriptor(DataTypeDescriptor source,
boolean isNullable,
int maximumWidth)
Constructor for internal uses only |
private |
DataTypeDescriptor(DataTypeDescriptor source,
int collationType,
int collationDerivation)
|
|
DataTypeDescriptor(DataTypeDescriptor source,
int precision,
int scale,
boolean isNullable,
int maximumWidth)
Constructor for internal uses only. |
private |
DataTypeDescriptor(TypeDescriptorImpl source,
TypeId typeId)
Constructor for use in reconstructing a DataTypeDescriptor from a TypeDescriptorImpl and a TypeId |
|
DataTypeDescriptor(TypeId typeId,
boolean isNullable)
|
|
DataTypeDescriptor(TypeId typeId,
boolean isNullable,
int maximumWidth)
Constructor for use with non-numeric types |
|
DataTypeDescriptor(TypeId typeId,
int precision,
int scale,
boolean isNullable,
int maximumWidth)
Constructor for use with numeric types |
|
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. |
Method Summary | |
---|---|
boolean |
comparable(DataTypeDescriptor compareWithDTD,
boolean forEquals,
ClassFactory cf)
Check if this type is comparable with the passed type. |
boolean |
compareCollationInfo(DataTypeDescriptor compareWithDTD)
Compare the collation info on this DTD with the passed DTD. |
boolean |
equals(java.lang.Object other)
Compare if two DataTypeDescriptors are exactly the same |
double |
estimatedMemoryUsage()
Get the estimated memory usage for this type descriptor. |
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 DataTypeServices that corresponds to a nullable builtin SQL type. |
static DataTypeDescriptor |
getBuiltInDataTypeDescriptor(java.lang.String sqlTypeName,
int length)
Get a DataTypeServices that corresponds to a builtin SQL type Collation type will be UCS_BASIC and derivation IMPLICIT. |
TypeDescriptor |
getCatalogType()
Get the simplified type descriptor that is intended to be stored in the system tables. |
static TypeDescriptor |
getCatalogType(int jdbcType)
Return a nullable catalog type for a fixed length JDBC builtin type. |
static TypeDescriptor |
getCatalogType(int jdbcType,
int length)
Return a nullable catalog type for a JDBC builtin type and length. |
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. |
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. |
int |
getCollationDerivation()
Get the collation derivation for this type. |
java.lang.String |
getCollationName()
Gets the name of the collation type in this descriptor if the collation derivation is not NONE. |
static java.lang.String |
getCollationName(int collationType)
Gets the name of the specified collation type. |
int |
getCollationType()
Obtain the collation type of the underlying catalog type. |
static int |
getCollationType(java.lang.String collationName)
Obtain the collation type from a collation property value. |
DataTypeDescriptor |
getDominantType(DataTypeDescriptor otherDTS,
ClassFactory cf)
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()
Shorthand method for getCatalogType().getMaximumWidth(). |
DataValueDescriptor |
getNull()
Get a Null for this type. |
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 TypeDescriptor |
getRowMultiSet(java.lang.String[] columnNames,
TypeDescriptor[] catalogTypes)
Get a catalog type that corresponds to a SQL Row Multiset |
private static TypeDescriptor |
getRowMultiSetCollation(TypeDescriptor catalogType,
int collationType)
For a row multi set type return an identical type with the collation type changed. |
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 DataTypeServices that corresponds to a Java type |
static DataTypeDescriptor |
getSQLDataTypeDescriptor(java.lang.String javaTypeName,
boolean isNullable)
Get a DataTypeServices 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. |
java.lang.String |
getSQLTypeNameWithCollation()
|
static DataTypeDescriptor |
getType(TypeDescriptor catalogType)
Return a runtime type for a catalog type. |
int |
getTypeFormatId()
Get the formatID which corresponds to this class. |
TypeId |
getTypeId()
Gets the TypeId for the datatype. |
java.lang.String |
getTypeName()
Gets the name of this datatype. |
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 . |
private static boolean |
isBinaryType(int jdbcType)
Check whether a JDBC type is compatible with the Java type byte[] . |
static boolean |
isCharacterStreamAssignable(int jdbcType)
Determine if a character stream can be inserted into a column or parameter of type jdbcType . |
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 . |
boolean |
isExactTypeAndLengthMatch(DataTypeDescriptor otherDTS)
Check whether or not the 2 types (DataTypeDescriptor) have the same type and length. |
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 |
isUserCreatableType()
Check to make sure that this type id is something a user can create him/herself directly through an SQL CREATE TABLE statement. |
DataValueDescriptor |
normalize(DataValueDescriptor source,
DataValueDescriptor cachedDest)
|
void |
readExternal(java.io.ObjectInput in)
Read this object from a stream of stored objects. |
java.lang.String |
toString()
|
void |
writeExternal(java.io.ObjectOutput out)
Write this object to a stream of stored objects. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final DataTypeDescriptor INTEGER
public static final DataTypeDescriptor INTEGER_NOT_NULL
public static final DataTypeDescriptor SMALLINT
public static final DataTypeDescriptor SMALLINT_NOT_NULL
private TypeDescriptorImpl typeDescriptor
private TypeId typeId
private int collationDerivation
Constructor Detail |
---|
public DataTypeDescriptor()
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, int precision, int scale, boolean isNullable, int maximumWidth, int collationType, int collationDerivation)
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 datatypecollationType
- The collation type of a string data typecollationDerivation
- Collation Derivation of a string data typepublic 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)
private DataTypeDescriptor(DataTypeDescriptor source, boolean isNullable)
private DataTypeDescriptor(DataTypeDescriptor source, int collationType, int collationDerivation)
public DataTypeDescriptor(DataTypeDescriptor source, int precision, int scale, boolean isNullable, int maximumWidth)
source
- The DTSI to copyprecision
- 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(DataTypeDescriptor source, boolean isNullable, int maximumWidth)
source
- The DTSI to copyisNullable
- TRUE means it could contain NULL, FALSE means
it definitely cannot contain NULL.maximumWidth
- The maximum number of bytes for this datatypeprivate DataTypeDescriptor(TypeDescriptorImpl source, TypeId typeId)
source
- The TypeDescriptorImpl to construct this DTSI fromMethod Detail |
---|
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType)
jdbcType
- The int type of the JDBC type for which to get
a corresponding SQL DataTypeDescriptor
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType, int length)
jdbcType
- The int type of the JDBC type for which to get
a corresponding SQL DataTypeDescriptor
public static DataTypeDescriptor getType(TypeDescriptor catalogType)
public static TypeDescriptor getCatalogType(int jdbcType, int length)
public static TypeDescriptor getCatalogType(int jdbcType)
public static TypeDescriptor getCatalogType(TypeDescriptor catalogType, int collationType)
catalogType
- Type to be based upon.collationType
- Collation type of returned type.
public 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 DataTypeDescriptor
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(java.lang.String sqlTypeName, int length)
sqlTypeName
- The name of the type for which to get
a corresponding SQL DataTypeDescriptor
public static DataTypeDescriptor getSQLDataTypeDescriptor(java.lang.String javaTypeName) throws StandardException
javaTypeName
- The name of the Java type for which to get
a corresponding SQL DataTypeDescriptor
StandardException
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 TypeDescriptor getRowMultiSet(java.lang.String[] columnNames, TypeDescriptor[] catalogTypes)
columnNames
- Names of the columns in the Row MulisetcatalogTypes
- Types of the columns in the Row Muliset
public DataValueDescriptor normalize(DataValueDescriptor source, DataValueDescriptor cachedDest) throws StandardException
StandardException
public DataTypeDescriptor getDominantType(DataTypeDescriptor otherDTS, ClassFactory cf) throws StandardException
otherDTS
- DataTypeDescriptor to compare with.cf
- A ClassFactory
StandardException
- Thrown on errorpublic boolean isExactTypeAndLengthMatch(DataTypeDescriptor otherDTS)
otherDTS
- DataTypeDescriptor to compare with.
public int getMaximumWidth()
TypeDescriptor.getMaximumWidth()
public TypeId getTypeId()
public DataValueDescriptor getNull() throws StandardException
StandardException
public java.lang.String getTypeName()
public int getJDBCTypeId()
Types
public int getPrecision()
TypeDescriptor.getPrecision()
public int getScale()
TypeDescriptor.getScale()
public int getCollationType()
TypeDescriptor.getCollationType()
public static int getCollationType(java.lang.String collationName)
public java.lang.String getCollationName()
This method is used for generating error messages which will use correct string describing collation type/derivation.
public static java.lang.String getCollationName(int collationType)
collationType
- The collation type.
public int getCollationDerivation()
StringDataValue.COLLATION_DERIVATION_NONE
,
StringDataValue.COLLATION_DERIVATION_IMPLICIT
,
StringDataValue.COLLATION_DERIVATION_EXPLICIT
public boolean isNullable()
public DataTypeDescriptor getNullabilityType(boolean isNullable)
isNullable
- True to return a nullable type, false otherwise.public DataTypeDescriptor getCollatedType(int collationType, int collationDerivation)
private static TypeDescriptor getRowMultiSetCollation(TypeDescriptor catalogType, int collationType)
collationType
-
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, ClassFactory cf)
compareWithDTD
- the type of the instance to compare with this type.forEquals
- True if this is an = or <> comparison, false
otherwise.cf
- A ClassFactory
public boolean compareCollationInfo(DataTypeDescriptor compareWithDTD)
compareWithDTD
- compare this DTD's collation info
public java.lang.String getSQLstring()
public TypeDescriptor getCatalogType()
public double estimatedMemoryUsage()
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)
private static boolean isCharacterType(int jdbcType)
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.
jdbcType
- a JDBC type
true
iff jdbcType
is a character type
and compatible with String
Types
private static boolean isBinaryType(int jdbcType)
byte[]
.
Note: BLOB
is not compatible with
byte[]
. See tables B-4, B-5 and B-6 in the JDBC 3.0
Specification.
jdbcType
- a JDBC type
true
iff jdbcType
is compatible with
byte[]
Types
public static boolean isAsciiStreamAssignable(int jdbcType)
jdbcType
.
jdbcType
- JDBC type of column or parameter
true
if an ASCII stream can be inserted;
false
otherwisepublic static boolean isBinaryStreamAssignable(int jdbcType)
jdbcType
.
jdbcType
- JDBC type of column or parameter
true
if a binary stream can be inserted;
false
otherwisepublic static boolean isCharacterStreamAssignable(int jdbcType)
jdbcType
.
jdbcType
- JDBC type of column or parameter
true
if a character stream can be inserted;
false
otherwisepublic java.lang.String toString()
toString
in class java.lang.Object
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- read this.
java.io.IOException
- thrown on error
java.lang.ClassNotFoundException
- thrown on errorpublic void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- write bytes here.
java.io.IOException
- thrown on errorpublic int getTypeFormatId()
getTypeFormatId
in interface TypedFormat
public boolean isUserCreatableType() throws StandardException
StandardException
public java.lang.String getFullSQLTypeName()
public java.lang.String getSQLTypeNameWithCollation()
|
Built on Thu 2012-03-29 21:53:33+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |