Class SQLTypeInfo
- java.lang.Object
-
- org.datanucleus.store.rdbms.schema.SQLTypeInfo
-
- All Implemented Interfaces:
org.datanucleus.store.schema.StoreSchemaData
- Direct Known Subclasses:
DB2TypeInfo,DerbyTypeInfo,FirebirdTypeInfo,H2TypeInfo,HSQLTypeInfo,InformixTypeInfo,MySQLTypeInfo,NuoDBTypeInfo,OracleTypeInfo,PostgreSQLTypeInfo,SQLiteTypeInfo,SQLServerTypeInfo,VirtuosoTypeInfo
public class SQLTypeInfo extends Object implements org.datanucleus.store.schema.StoreSchemaData
Representation of SQL type information in the datastore.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanallowsPrecisionSpecWhether the type allows specification of the precision in parentheses after the type name.protected booleanautoIncrementWhether the type automatically increments for each new row inserted.protected booleancaseSensitiveWhether the data type is case-sensitive in comparisons.protected StringcreateParamsIndicates the parameters used in defining columns of this type.protected shortdataTypeThe JDBC data type number of this data type (see java.sql.Types).protected booleanfixedPrecScaleWhether the type can be assigned a fixed scale value, such as for decimal or currency types.protected booleanfromJdbcDriverWhether this originates from the JDBC Driverprotected StringliteralPrefixThe prefix used to quote a literal of this data type; may be null.protected StringliteralSuffixThe suffix used to quote a literal of this data type; may be null.protected StringlocalTypeNameLocalized version of the DBMS-specific type name of this data type.protected shortmaximumScaleThe maximum supported scale value for this data type.protected shortminimumScaleThe minimum supported scale value for this data type.protected intnullableIndicates whether null values are allowed for this data type.protected intnumPrecRadixIndicates the numeric radix of this data type, which is usually 2 or 10.protected intprecisionThe maximum precision/length allowed for this data type.protected shortsearchableThe searchability of this data type in terms of the kinds of SQL WHERE clauses that are allowed.protected StringtypeNameThe RDBMS-specific name for this data type.protected booleanunsignedAttributetrue indicates the type is unsigned, false otherwise.
-
Constructor Summary
Constructors Constructor Description SQLTypeInfo(String typeName, short dataType, int precision, String literalPrefix, String literalSuffix, String createParams, int nullable, boolean caseSensitive, short searchable, boolean unsignedAttribute, boolean fixedPrecScale, boolean autoIncrement, String localTypeName, short minimumScale, short maximumScale, int numPrecRadix)SQLTypeInfo(ResultSet rs)Constructor to create a type info definition for the current row of the passed ResultSet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProperty(String name, Object value)Method to add a property for the type.booleanequals(Object obj)Indicates whether some object is "equal to" this one.StringgetCreateParams()shortgetDataType()StringgetLiteralPrefix()StringgetLiteralSuffix()StringgetLocalTypeName()shortgetMaximumScale()shortgetMinimumScale()intgetNullable()intgetNumPrecRadix()intgetPrecision()ObjectgetProperty(String name)Accessor for a property.shortgetSearchable()StringgetTypeName()inthashCode()Returns a hash code value for this object.booleanisAllowsPrecisionSpec()booleanisAutoIncrement()booleanisCaseSensitive()booleanisCompatibleWith(RDBMSColumnInfo colInfo)Convenience method for returning if this type is compatible with the provided column.booleanisFixedPrecScale()booleanisUnsignedAttribute()voidsetAllowsPrecisionSpec(boolean allowsPrecisionSpec)voidsetLocalTypeName(String localTypeName)voidsetTypeName(String typeName)StringtoString()Returns the string representation of this object.StringtoString(String indent)Returns the string representation of this object.
-
-
-
Field Detail
-
fromJdbcDriver
protected boolean fromJdbcDriver
Whether this originates from the JDBC Driver
-
typeName
protected 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 String literalPrefix
The prefix used to quote a literal of this data type; may be null.
-
literalSuffix
protected String literalSuffix
The suffix used to quote a literal of this data type; may be null.
-
createParams
protected 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 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(String typeName, short dataType, int precision, String literalPrefix, String literalSuffix, String createParams, int nullable, boolean caseSensitive, short searchable, boolean unsignedAttribute, boolean fixedPrecScale, boolean autoIncrement, String localTypeName, short minimumScale, short maximumScale, int numPrecRadix)
-
SQLTypeInfo
public SQLTypeInfo(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(String name, Object value)
Method to add a property for the type.- Specified by:
addPropertyin interfaceorg.datanucleus.store.schema.StoreSchemaData- Parameters:
name- Name of propertyvalue- Its value
-
getProperty
public Object getProperty(String name)
Accessor for a property.- Specified by:
getPropertyin interfaceorg.datanucleus.store.schema.StoreSchemaData- Parameters:
name- Name of the property- Returns:
- Its value, or null if not defined
-
equals
public final boolean equals(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.
-
hashCode
public final int hashCode()
Returns a hash code value for this object.
-
toString
public String toString()
Returns the string representation of this object.
-
toString
public String toString(String indent)
Returns the string representation of this object.- Parameters:
indent- The indent for each line of the output- 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(String typeName)
-
getTypeName
public String getTypeName()
-
getDataType
public short getDataType()
-
getPrecision
public int getPrecision()
-
getLiteralPrefix
public String getLiteralPrefix()
-
getLiteralSuffix
public String getLiteralSuffix()
-
getCreateParams
public 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(String localTypeName)
-
getLocalTypeName
public String getLocalTypeName()
-
getMinimumScale
public short getMinimumScale()
-
getMaximumScale
public short getMaximumScale()
-
getNumPrecRadix
public int getNumPrecRadix()
-
setAllowsPrecisionSpec
public void setAllowsPrecisionSpec(boolean allowsPrecisionSpec)
-
isAllowsPrecisionSpec
public boolean isAllowsPrecisionSpec()
-
-