org.datanucleus.store.rdbms.schema
Class SQLTypeInfo

java.lang.Object
  extended by org.datanucleus.store.rdbms.schema.SQLTypeInfo
All Implemented Interfaces:
org.datanucleus.store.schema.StoreSchemaData
Direct Known Subclasses:
DB2TypeInfo, DerbyTypeInfo, FirebirdTypeInfo, H2TypeInfo, HSQLTypeInfo, InformixTypeInfo, McKoiTypeInfo, MSSQLTypeInfo, MySQLTypeInfo, OracleTypeInfo, PostgresqlTypeInfo

public class SQLTypeInfo
extends java.lang.Object
implements org.datanucleus.store.schema.StoreSchemaData

Representation of SQL type information in the datastore.


Field Summary
protected  boolean allowsPrecisionSpec
          Whether the type allows specification of the precision in parentheses after the type name.
protected  boolean autoIncrement
          Whether the type automatically increments for each new row inserted.
protected  boolean caseSensitive
          Whether the data type is case-sensitive in comparisons.
protected  java.lang.String createParams
          Indicates the parameters used in defining columns of this type.
protected  short dataType
          The JDBC data type number of this data type (see java.sql.Types).
protected  boolean fixedPrecScale
          Whether the type can be assigned a fixed scale value, such as for decimal or currency types.
protected  java.lang.String literalPrefix
          The prefix used to quote a literal of this data type; may be null.
protected  java.lang.String literalSuffix
          The suffix used to quote a literal of this data type; may be null.
protected  java.lang.String localTypeName
          Localized version of the DBMS-specific type name of this data type.
protected  short maximumScale
          The maximum supported scale value for this data type.
protected  short minimumScale
          The minimum supported scale value for this data type.
protected  int nullable
          Indicates whether null values are allowed for this data type.
protected  int numPrecRadix
          Indicates the numeric radix of this data type, which is usually 2 or 10.
protected  int precision
          The maximum precision/length allowed for this data type.
protected  short searchable
          The searchability of this data type in terms of the kinds of SQL WHERE clauses that are allowed.
protected  java.lang.String typeName
          The RDBMS-specific name for this data type.
protected  boolean unsignedAttribute
          true indicates the type is unsigned, false otherwise.
 
Constructor Summary
SQLTypeInfo(java.sql.ResultSet rs)
          Constructor to create a type info definition for the current row of the passed ResultSet.
SQLTypeInfo(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)
          Constructor to create a type info definition from the passed values.
 
Method Summary
 void addProperty(java.lang.String name, java.lang.Object value)
          Method to add a property for the type.
 boolean equals(java.lang.Object obj)
          Indicates whether some object is "equal to" this one.
 java.lang.String getCreateParams()
           
 short getDataType()
           
 java.lang.String getLiteralPrefix()
           
 java.lang.String getLiteralSuffix()
           
 java.lang.String getLocalTypeName()
           
 short getMaximumScale()
           
 short getMinimumScale()
           
 int getNullable()
           
 int getNumPrecRadix()
           
 int getPrecision()
           
 java.lang.Object getProperty(java.lang.String name)
          Accessor for a property.
 short getSearchable()
           
 java.lang.String getTypeName()
           
 int hashCode()
          Returns a hash code value for this object.
 boolean isAllowsPrecisionSpec()
           
 boolean isAutoIncrement()
           
 boolean isCaseSensitive()
           
 boolean isCompatibleWith(RDBMSColumnInfo colInfo)
          Convenience method for returning if this type is compatible with the provided column.
 boolean isFixedPrecScale()
           
 boolean isUnsignedAttribute()
           
 void setAllowsPrecisionSpec(boolean allowsPrecisionSpec)
           
 void setLocalTypeName(java.lang.String localTypeName)
           
 void setTypeName(java.lang.String typeName)
           
 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

protected java.lang.String typeName
The RDBMS-specific name for this data type.


dataType

protected short dataType
The JDBC data type number of this data type (see java.sql.Types).


precision

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


literalPrefix

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


literalSuffix

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


createParams

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


nullable

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


caseSensitive

protected boolean caseSensitive
Whether the data type is case-sensitive in comparisons.


searchable

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


unsignedAttribute

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


fixedPrecScale

protected boolean fixedPrecScale
Whether the type can be assigned a fixed scale value, such as for decimal or currency types.


autoIncrement

protected boolean autoIncrement
Whether the type automatically increments for each new row inserted.


localTypeName

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


minimumScale

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


maximumScale

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


numPrecRadix

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


allowsPrecisionSpec

protected boolean allowsPrecisionSpec
Whether the type allows specification of the precision in parentheses after the type name.

Constructor Detail

SQLTypeInfo

public SQLTypeInfo(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)
Constructor to create a type info definition from the passed values.


SQLTypeInfo

public SQLTypeInfo(java.sql.ResultSet rs)
Constructor to create a type info definition for the current row of the passed ResultSet.

Parameters:
rs - ResultSet (from DatabaseMetaData.getTypeInfo() for example).
Throws:
org.datanucleus.exceptions.NucleusDataStoreException - Thrown if an error occurs getting the information
Method Detail

addProperty

public void addProperty(java.lang.String name,
                        java.lang.Object value)
Method to add a property for the type.

Specified by:
addProperty in interface org.datanucleus.store.schema.StoreSchemaData
Parameters:
name - Name of property
value - Its value

getProperty

public java.lang.Object getProperty(java.lang.String name)
Accessor for a property.

Specified by:
getProperty in interface org.datanucleus.store.schema.StoreSchemaData
Parameters:
name - Name of the property
Returns:
Its value, or null if not defined

equals

public final boolean equals(java.lang.Object obj)
Indicates whether some object is "equal to" this one. Two SQLTypeInfo are considered equal if their type name and data type properties are equal.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the reference object with which to compare
Returns:
true if this object is equal to the obj argument; false otherwise.

hashCode

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

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.

toString

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

Overrides:
toString in class java.lang.Object
Returns:
string representation of this object.

isCompatibleWith

public boolean isCompatibleWith(RDBMSColumnInfo colInfo)
Convenience method for returning if this type is compatible with the provided column. Compares the data type of each record, and returns true if the types are equivalent. For example one could be VARCHAR, and the other LONGVARCHAR so they both store string data, and hence they are compatible.

Parameters:
colInfo - The column
Returns:
Whether they are considered compatible

setTypeName

public void setTypeName(java.lang.String typeName)

getTypeName

public java.lang.String getTypeName()

getDataType

public short getDataType()

getPrecision

public int getPrecision()

getLiteralPrefix

public java.lang.String getLiteralPrefix()

getLiteralSuffix

public java.lang.String getLiteralSuffix()

getCreateParams

public java.lang.String getCreateParams()

getNullable

public int getNullable()

isCaseSensitive

public boolean isCaseSensitive()

getSearchable

public short getSearchable()

isUnsignedAttribute

public boolean isUnsignedAttribute()

isFixedPrecScale

public boolean isFixedPrecScale()

isAutoIncrement

public boolean isAutoIncrement()

setLocalTypeName

public void setLocalTypeName(java.lang.String localTypeName)

getLocalTypeName

public java.lang.String getLocalTypeName()

getMinimumScale

public short getMinimumScale()

getMaximumScale

public short getMaximumScale()

getNumPrecRadix

public int getNumPrecRadix()

setAllowsPrecisionSpec

public void setAllowsPrecisionSpec(boolean allowsPrecisionSpec)

isAllowsPrecisionSpec

public boolean isAllowsPrecisionSpec()


Copyright © 2009. All Rights Reserved.