|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> [ types overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.iapi.types
Class DataTypeDescriptor

java.lang.Objectorg.apache.derby.iapi.types.DataTypeDescriptor
- All Implemented Interfaces:
- java.io.Externalizable, org.apache.derby.iapi.services.io.Formatable, java.io.Serializable, org.apache.derby.catalog.TypeDescriptor, org.apache.derby.iapi.services.io.TypedFormat
- public final class DataTypeDescriptor
- extends java.lang.Object
- implements org.apache.derby.catalog.TypeDescriptor, org.apache.derby.iapi.services.io.Formatable
- extends java.lang.Object
This is an implementation of DataTypeDescriptor from the generic language datatype module interface.
- Version:
- 1.0
| Field Summary | |
private org.apache.derby.catalog.types.TypeDescriptorImpl |
typeDescriptor
|
private TypeId |
typeId
|
| Fields inherited from interface org.apache.derby.catalog.TypeDescriptor |
MAXIMUM_WIDTH_UNKNOWN |
| Constructor Summary | |
DataTypeDescriptor()
Public niladic constructor. |
|
DataTypeDescriptor(DataTypeDescriptor source,
boolean isNullable)
|
|
DataTypeDescriptor(DataTypeDescriptor source,
boolean isNullable,
int maximumWidth)
Constructor for internal uses only |
|
DataTypeDescriptor(DataTypeDescriptor source,
int precision,
int scale,
boolean isNullable,
int maximumWidth)
Constructor for internal uses only. |
|
DataTypeDescriptor(org.apache.derby.catalog.types.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 |
|
| Method Summary | |
boolean |
equals(java.lang.Object aTypeDescriptor)
Compare if two TypeDescriptors 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 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)
|
static DataTypeDescriptor |
getBuiltInDataTypeDescriptor(java.lang.String sqlTypeName)
Get a DataTypeServices that corresponds to a builtin SQL type |
static DataTypeDescriptor |
getBuiltInDataTypeDescriptor(java.lang.String sqlTypeName,
int length)
Get a DataTypeServices that corresponds to a builtin SQL type |
org.apache.derby.catalog.types.TypeDescriptorImpl |
getCatalogType()
Get the simplified type descriptor that is intended to be stored in the system tables. |
DataTypeDescriptor |
getDominantType(DataTypeDescriptor otherDTS,
org.apache.derby.iapi.services.loader.ClassFactory cf)
Get the dominant type (DataTypeDescriptor) of the 2. |
int |
getJDBCTypeId()
Get the jdbc type id for this type. |
int |
getMaximumWidth()
Returns the maximum width of the type. |
int |
getMaximumWidthInBytes()
Returns the maximum width of the type IN BYTES. |
DataValueDescriptor |
getNull()
Get a Null for this type. |
int |
getPrecision()
Returns the number of decimal digits for the datatype, if applicable. |
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. |
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. |
private static boolean |
isBinaryType(int jdbcType)
|
private static boolean |
isCharacterType(int jdbcType)
|
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)
|
DataValueDescriptor |
normalize(DataValueDescriptor source,
DataValueDescriptor cachedDest)
|
void |
readExternal(java.io.ObjectInput in)
Read this object from a stream of stored objects. |
void |
setNullability(boolean nullable)
Set the nullability of the datatype described by this descriptor |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
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 |
typeDescriptor
private org.apache.derby.catalog.types.TypeDescriptorImpl typeDescriptor
typeId
private TypeId typeId
| Constructor Detail |
DataTypeDescriptor
public DataTypeDescriptor()
- Public niladic constructor. Needed for Formatable interface to work.
DataTypeDescriptor
public DataTypeDescriptor(TypeId typeId, int precision, int scale, boolean isNullable, int maximumWidth)
- Constructor for use with numeric types
DataTypeDescriptor
public DataTypeDescriptor(TypeId typeId, boolean isNullable, int maximumWidth)
- Constructor for use with non-numeric types
DataTypeDescriptor
public DataTypeDescriptor(TypeId typeId, boolean isNullable)
DataTypeDescriptor
public DataTypeDescriptor(DataTypeDescriptor source, boolean isNullable)
DataTypeDescriptor
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.)
DataTypeDescriptor
public DataTypeDescriptor(DataTypeDescriptor source, boolean isNullable, int maximumWidth)
- Constructor for internal uses only
DataTypeDescriptor
public DataTypeDescriptor(org.apache.derby.catalog.types.TypeDescriptorImpl source, TypeId typeId)
- Constructor for use in reconstructing a DataTypeDescriptor from a
TypeDescriptorImpl and a TypeId
| Method Detail |
getBuiltInDataTypeDescriptor
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType)
- Get a descriptor that corresponds to a builtin JDBC type.
getBuiltInDataTypeDescriptor
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType, int length)
getBuiltInDataTypeDescriptor
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType, boolean isNullable)
- Get a descriptor that corresponds to a builtin JDBC type.
getBuiltInDataTypeDescriptor
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(int jdbcType, boolean isNullable, int maxLength)
- Get a descriptor that corresponds to a builtin JDBC type.
getBuiltInDataTypeDescriptor
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(java.lang.String sqlTypeName)
- Get a DataTypeServices that corresponds to a builtin SQL type
getBuiltInDataTypeDescriptor
public static DataTypeDescriptor getBuiltInDataTypeDescriptor(java.lang.String sqlTypeName, int length)
- Get a DataTypeServices that corresponds to a builtin SQL type
getSQLDataTypeDescriptor
public static DataTypeDescriptor getSQLDataTypeDescriptor(java.lang.String javaTypeName)
- Get a DataTypeServices that corresponds to a Java type
getSQLDataTypeDescriptor
public static DataTypeDescriptor getSQLDataTypeDescriptor(java.lang.String javaTypeName, boolean isNullable)
- Get a DataTypeServices that corresponds to a Java type
getSQLDataTypeDescriptor
public static DataTypeDescriptor getSQLDataTypeDescriptor(java.lang.String javaTypeName, int precision, int scale, boolean isNullable, int maximumWidth)
- Get a DataTypeDescriptor that corresponds to a Java type
normalize
public DataValueDescriptor normalize(DataValueDescriptor source, DataValueDescriptor cachedDest) throws org.apache.derby.iapi.error.StandardException
getDominantType
public DataTypeDescriptor getDominantType(DataTypeDescriptor otherDTS, org.apache.derby.iapi.services.loader.ClassFactory cf) throws org.apache.derby.iapi.error.StandardException
- 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.
isExactTypeAndLengthMatch
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.
getMaximumWidth
public int getMaximumWidth()
- Description copied from interface:
org.apache.derby.catalog.TypeDescriptor - Returns the maximum width of the type. This may have
different meanings for different types. For example, with char,
it means the maximum number of characters, while with int, it
is the number of bytes (i.e. 4).
- Specified by:
getMaximumWidthin interfaceorg.apache.derby.catalog.TypeDescriptor
getMaximumWidthInBytes
public int getMaximumWidthInBytes()
- Description copied from interface:
org.apache.derby.catalog.TypeDescriptor - Returns the maximum width of the type IN BYTES. This is the
maximum number of bytes that could be returned for this type
if the corresponding getXXX() method is used. For example,
if we have a CHAR type, then we want the number of bytes
that would be returned by a ResultSet.getString() call.
- Specified by:
getMaximumWidthInBytesin interfaceorg.apache.derby.catalog.TypeDescriptor
getTypeId
public TypeId getTypeId()
- Gets the TypeId for the datatype.
getNull
public DataValueDescriptor getNull()
- Get a Null for this type.
getTypeName
public java.lang.String getTypeName()
- Gets the name of this datatype.
- Specified by:
getTypeNamein interfaceorg.apache.derby.catalog.TypeDescriptor
getJDBCTypeId
public int getJDBCTypeId()
- Get the jdbc type id for this type. JDBC type can be
found in java.sql.Types.
- Specified by:
getJDBCTypeIdin interfaceorg.apache.derby.catalog.TypeDescriptor
getPrecision
public int getPrecision()
- Returns the number of decimal digits for the datatype, if applicable.
- Specified by:
getPrecisionin interfaceorg.apache.derby.catalog.TypeDescriptor
getScale
public int getScale()
- Returns the number of digits to the right of the decimal for
the datatype, if applicable.
- Specified by:
getScalein interfaceorg.apache.derby.catalog.TypeDescriptor
isNullable
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.
- Specified by:
isNullablein interfaceorg.apache.derby.catalog.TypeDescriptor
setNullability
public void setNullability(boolean nullable)
- Set the nullability of the datatype described by this descriptor
equals
public boolean equals(java.lang.Object aTypeDescriptor)
- Compare if two TypeDescriptors are exactly the same
getSQLstring
public java.lang.String getSQLstring()
- Converts this data type descriptor (including length/precision)
to a string. E.g.
VARCHAR(30)
or
java.util.Hashtable
- Specified by:
getSQLstringin interfaceorg.apache.derby.catalog.TypeDescriptor
getCatalogType
public org.apache.derby.catalog.types.TypeDescriptorImpl getCatalogType()
- Get the simplified type descriptor that is intended to be stored
in the system tables.
estimatedMemoryUsage
public double estimatedMemoryUsage()
- Get the estimated memory usage for this type descriptor.
isJDBCTypeEquivalent
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
isNumericType
public static boolean isNumericType(int jdbcType)
isCharacterType
private static boolean isCharacterType(int jdbcType)
isBinaryType
private static boolean isBinaryType(int jdbcType)
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Read this object from a stream of stored objects.
- Specified by:
readExternalin interfacejava.io.Externalizable
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Write this object to a stream of stored objects.
- Specified by:
writeExternalin interfacejava.io.Externalizable
getTypeFormatId
public int getTypeFormatId()
- Get the formatID which corresponds to this class.
- Specified by:
getTypeFormatIdin interfaceorg.apache.derby.iapi.services.io.TypedFormat
|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> [ types overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.derby.iapi.types.DataTypeDescriptor