org.jpox.store.rdbms.typeinfo
Class TypeInfo

java.lang.Object
  extended byorg.jpox.store.rdbms.typeinfo.TypeInfo
Direct Known Subclasses:
DB2TypeInfo, DerbyTypeInfo, FirebirdTypeInfo, HSQLTypeInfo, InformixTypeInfo, McKoiTypeInfo, MSSQLTypeInfo, MySQLTypeInfo, OracleTypeInfo, PostgreSQLTypeInfo

public class TypeInfo
extends java.lang.Object

Represents the metadata of a specific JDBC data type. This class is basically a data structure that makes accessing the JDBC type metadata easier. Each of the columns of information returned by DatabaseMetaData.getTypeInfo() is represented by a public field in this class.

Subclasses of TypeInfo can be created on a per-DBMS basis to supply missing metadata or correct faulty metadata obtained from that DBMS's JDBC driver(s).

Version:
$Revision: 1.7 $
See Also:
DatabaseMetaData.getTypeInfo()

Field Summary
 boolean allowsPrecisionSpec
          This is not defined in the JDBC type info, and defines if the type allows specification of the precision in parentheses after the type name.
 boolean autoIncrement
          true indicates the type automatically increments for each new row inserted, false otherwise.
 boolean caseSensitive
          true indicates this data type is case-sensitive in comparisons, false otherwise.
 java.lang.String createParams
          Indicates the parameters used in defining columns of this type.
 short dataType
          The JDBC (SQL) data type number of this data type.
 boolean fixedPrecScale
          true indicates the type can be assigned a fixed scale value, such as for decimal or currency types, false otherwise.
 java.lang.String literalPrefix
          The prefix used to quote a literal of this data type; may be null.
 java.lang.String literalSuffix
          The suffix used to quote a literal of this data type; may be null.
 java.lang.String localTypeName
          Localized version of the DBMS-specific type name of this data type.
 short maximumScale
          The maximum supported scale value for this data type.
 short minimumScale
          The minimum supported scale value for this data type.
 int nullable
          Indicates whether null values are allowed for this data type.
 int numPrecRadix
          Indicates the numeric radix of this data type, which is usually 2 or 10.
 int precision
          The maximum precision/length allowed for this data type.
 short searchable
          Indicates searchability of this data type in terms of the kinds of SQL WHERE clauses that are allowed.
 java.lang.String typeName
          The DBMS-specific name for this data type.
 boolean unsignedAttribute
          true indicates the type is unsigned, false otherwise.
 
Constructor Summary
TypeInfo(java.sql.ResultSet rs)
          Constructs a type information objectd from the current row of the given result set.
TypeInfo(java.lang.String typeName, short dataType, int precision, java.lang.String literalPrefix, java.lang.String literalSuffix, java.lang.String createParams, int nullable, boolean caseSensitive, short searchable, boolean unsignedAttribute, boolean fixedPrecScale, boolean autoIncrement, java.lang.String localTypeName, short minimumScale, short maximumScale, int numPrecRadix)
          /** Constructs a type information object from its individual attributes.
 
Method Summary
static boolean areCompatibleTypes(int expected, int actual)
          Method to return if 2 types are compatible.
 boolean equals(java.lang.Object obj)
          Indicates whether some object is "equal to" this one.
static java.lang.String getJDBCTypeName(int type)
          Returns the string name of the Java constant that equals the given JDBC type number type.
 int hashCode()
          Returns a hash code value for this object.
 boolean isCompatibleWith(ColumnInfo ci)
          Indicates whether the type of a given database column is "compatible" with this type.
 boolean isToValidate(ColumnInfo ci)
          Indicates whether validate columns with certain types
 java.lang.String toString()
          Returns the string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

typeName

public java.lang.String typeName
The DBMS-specific name for this data type.


dataType

public short dataType
The JDBC (SQL) data type number of this data type.


precision

public int precision
The maximum precision/length allowed for this data type.


literalPrefix

public java.lang.String literalPrefix
The prefix used to quote a literal of this data type; may be null.


literalSuffix

public java.lang.String literalSuffix
The suffix used to quote a literal of this data type; may be null.


createParams

public java.lang.String createParams
Indicates the parameters used in defining columns of this type.


nullable

public int nullable
Indicates whether null values are allowed for this data type.

See Also:
DatabaseMetaData.typeNoNulls, DatabaseMetaData.typeNullable, DatabaseMetaData.typeNullableUnknown

caseSensitive

public boolean caseSensitive
true indicates this data type is case-sensitive in comparisons, false otherwise.


searchable

public short searchable
Indicates searchability of this data type in terms of the kinds of SQL WHERE clauses that are allowed.

See Also:
DatabaseMetaData.typePredNone, DatabaseMetaData.typePredChar, DatabaseMetaData.typePredBasic, DatabaseMetaData.typeSearchable

unsignedAttribute

public boolean unsignedAttribute
true indicates the type is unsigned, false otherwise.


fixedPrecScale

public boolean fixedPrecScale
true indicates the type can be assigned a fixed scale value, such as for decimal or currency types, false otherwise.


autoIncrement

public boolean autoIncrement
true indicates the type automatically increments for each new row inserted, false otherwise.


localTypeName

public java.lang.String localTypeName
Localized version of the DBMS-specific type name of this data type.


minimumScale

public short minimumScale
The minimum supported scale value for this data type.


maximumScale

public short maximumScale
The maximum supported scale value for this data type.


numPrecRadix

public int numPrecRadix
Indicates the numeric radix of this data type, which is usually 2 or 10.


allowsPrecisionSpec

public boolean allowsPrecisionSpec
This is not defined in the JDBC type info, and defines if the type allows specification of the precision in parentheses after the type name. Added so that we can define particular types as not allowing this.

Constructor Detail

TypeInfo

public TypeInfo(java.sql.ResultSet rs)
         throws javax.jdo.JDOFatalDataStoreException
Constructs a type information objectd from the current row of the given result set. The ResultSet object passed must have been obtained from a call to java.sql.DatabaseMetaData.getTypeInfo().

This method only retrieves the values from the current row; the caller is required to advance to the next row with ResultSet.next().

Parameters:
rs - The result set returned from java.sql.DatabaseMetaData.getTypeInfo().
Throws:
javax.jdo.JDOFatalDataStoreException - if a column of type information could not be retrieved from the result set.

TypeInfo

public TypeInfo(java.lang.String typeName,
                short dataType,
                int precision,
                java.lang.String literalPrefix,
                java.lang.String literalSuffix,
                java.lang.String createParams,
                int nullable,
                boolean caseSensitive,
                short searchable,
                boolean unsignedAttribute,
                boolean fixedPrecScale,
                boolean autoIncrement,
                java.lang.String localTypeName,
                short minimumScale,
                short maximumScale,
                int numPrecRadix)
/** Constructs a type information object from its individual attributes.

This can be useful to subclasses and/or custom DatabaseAdapters that need to modify and/or correct the metadata returned by the JDBC driver.

Parameters:
typeName -
dataType -
precision -
literalPrefix -
literalSuffix -
createParams -
nullable -
caseSensitive -
searchable -
unsignedAttribute -
fixedPrecScale -
autoIncrement -
localTypeName -
minimumScale -
maximumScale -
numPrecRadix -
Method Detail

isCompatibleWith

public boolean isCompatibleWith(ColumnInfo ci)
Indicates whether the type of a given database column is "compatible" with this type.

Parameters:
ci - The ColumnInfo
Returns:
Whether they are compatible

isToValidate

public boolean isToValidate(ColumnInfo ci)
Indicates whether validate columns with certain types

Parameters:
ci - The ColumnInfo
Returns:
Whether it is to be validated

equals

public boolean equals(java.lang.Object obj)
Indicates whether some object is "equal to" this one. Two TypeInfo objects are considered equal if their typeName and dataType fields are equal.

Parameters:
obj - the reference object with which to compare
Returns:
true if this object is equal to the obj argument; false otherwise.

hashCode

public int hashCode()
Returns a hash code value for this object.

Returns:
a hash code value for this object.

toString

public java.lang.String toString()
Returns the string representation of this object.

Returns:
string representation of this object.

getJDBCTypeName

public static java.lang.String getJDBCTypeName(int type)
Returns the string name of the Java constant that equals the given JDBC type number type. JDBC type numbers are defined in Types.

If type is not equal to one of the known type numbers, the string "Unrecognized type (type)" is returned.

Parameters:
type - the JDBC type number.
Returns:
the string name of the corresponding constant from Types.

areCompatibleTypes

public static boolean areCompatibleTypes(int expected,
                                         int actual)
Method to return if 2 types are compatible.

Parameters:
expected - The expected
actual - The actual
Returns:
Whether they are compatible.


Copyright © -2007 . All Rights Reserved.