Class SQLTypeInfo
java.lang.Object
org.datanucleus.store.rdbms.schema.SQLTypeInfo
- All Implemented Interfaces:
org.datanucleus.store.schema.StoreSchemaData
- Direct Known Subclasses:
CloudSpannerTypeInfo, DB2TypeInfo, DerbyTypeInfo, FirebirdTypeInfo, H2TypeInfo, HSQLTypeInfo, InformixTypeInfo, MySQLTypeInfo, NuoDBTypeInfo, OracleTypeInfo, PostgreSQLTypeInfo, SQLiteTypeInfo, SQLServerTypeInfo, VirtuosoTypeInfo
Representation of SQL type information in the datastore.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether the type allows specification of the precision in parentheses after the type name.protected booleanWhether the type automatically increments for each new row inserted.protected booleanWhether the data type is case-sensitive in comparisons.protected StringIndicates the parameters used in defining columns of this type.protected shortThe JDBC data type number of this data type (see java.sql.Types).protected booleanWhether the type can be assigned a fixed scale value, such as for decimal or currency types.protected booleanWhether this originates from the JDBC Driverprivate intHashcode.protected StringThe prefix used to quote a literal of this data type; may be null.protected StringThe suffix used to quote a literal of this data type; may be null.protected StringLocalized version of the DBMS-specific type name of this data type.protected shortThe maximum supported scale value for this data type.protected shortThe minimum supported scale value for this data type.protected intIndicates whether null values are allowed for this data type.protected intIndicates the numeric radix of this data type, which is usually 2 or 10.protected intThe maximum precision/length allowed for this data type.protected shortThe searchability of this data type in terms of the kinds of SQL WHERE clauses that are allowed.protected StringThe RDBMS-specific name for this data type.protected booleantrue indicates the type is unsigned, false otherwise. -
Constructor Summary
ConstructorsConstructorDescriptionSQLTypeInfo(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
Modifier and TypeMethodDescriptionvoidaddProperty(String name, Object value) Method to add a property for the type.final booleanIndicates whether some object is "equal to" this one.shortshortshortintintintgetProperty(String name) Accessor for a property.shortfinal inthashCode()Returns a hash code value for this object.booleanbooleanbooleanprivate static booleanisCharacterType(int type) Verify if it's LONGVARCHAR or VARCHAR.booleanisCompatibleWith(RDBMSColumnInfo colInfo) Convenience method for returning if this type is compatible with the provided column.private static booleanisDateType(int type) Verify if it's DATE, TIME, TIMESTAMP type.booleanprivate static booleanisFloatingType(int type) Verify if it's FLOAT, REAL or DOUBLE.private static booleanisIntegerType(int type) Verify if it's TINYINT, SMALLINT, INTEGER, or BIGINT type.private static booleanisNumericType(int type) Verify if it's NUMERIC or DECIMAL.booleanvoidsetAllowsPrecisionSpec(boolean allowsPrecisionSpec) voidsetLocalTypeName(String localTypeName) voidsetTypeName(String typeName) toString()Returns the string representation of this object.Returns the string representation of this object.
-
Field Details
-
fromJdbcDriver
protected boolean fromJdbcDriverWhether this originates from the JDBC Driver -
typeName
The RDBMS-specific name for this data type. -
dataType
protected short dataTypeThe JDBC data type number of this data type (see java.sql.Types). -
precision
protected int precisionThe maximum precision/length allowed for this data type. -
literalPrefix
The prefix used to quote a literal of this data type; may be null. -
literalSuffix
The suffix used to quote a literal of this data type; may be null. -
createParams
Indicates the parameters used in defining columns of this type. -
nullable
protected int nullableIndicates whether null values are allowed for this data type. -
caseSensitive
protected boolean caseSensitiveWhether the data type is case-sensitive in comparisons. -
searchable
protected short searchableThe searchability of this data type in terms of the kinds of SQL WHERE clauses that are allowed. -
unsignedAttribute
protected boolean unsignedAttributetrue indicates the type is unsigned, false otherwise. -
fixedPrecScale
protected boolean fixedPrecScaleWhether the type can be assigned a fixed scale value, such as for decimal or currency types. -
autoIncrement
protected boolean autoIncrementWhether the type automatically increments for each new row inserted. -
localTypeName
Localized version of the DBMS-specific type name of this data type. -
minimumScale
protected short minimumScaleThe minimum supported scale value for this data type. -
maximumScale
protected short maximumScaleThe maximum supported scale value for this data type. -
numPrecRadix
protected int numPrecRadixIndicates the numeric radix of this data type, which is usually 2 or 10. -
allowsPrecisionSpec
protected boolean allowsPrecisionSpecWhether the type allows specification of the precision in parentheses after the type name. -
hash
private int hashHashcode. Set on first use.
-
-
Constructor Details
-
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
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 Details
-
addProperty
-
getProperty
-
equals
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
-
toString
-
toString
-
isCompatibleWith
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
-
isIntegerType
private static boolean isIntegerType(int type) Verify if it's TINYINT, SMALLINT, INTEGER, or BIGINT type.- Parameters:
type- The type- Returns:
- Whether the type is of an integer type
-
isDateType
private static boolean isDateType(int type) Verify if it's DATE, TIME, TIMESTAMP type.- Parameters:
type- The type- Returns:
- Whether the type is of a date type
-
isFloatingType
private static boolean isFloatingType(int type) Verify if it's FLOAT, REAL or DOUBLE.- Parameters:
type- The type- Returns:
- Whether the type is of a floating point type
-
isNumericType
private static boolean isNumericType(int type) Verify if it's NUMERIC or DECIMAL.- Parameters:
type- The type- Returns:
- Whether the type is of a numeric type
-
isCharacterType
private static boolean isCharacterType(int type) Verify if it's LONGVARCHAR or VARCHAR.- Parameters:
type- The type- Returns:
- Whether the type is of a character type
-
setTypeName
-
getTypeName
-
getDataType
public short getDataType() -
getPrecision
public int getPrecision() -
getLiteralPrefix
-
getLiteralSuffix
-
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
-
getLocalTypeName
-
getMinimumScale
public short getMinimumScale() -
getMaximumScale
public short getMaximumScale() -
getNumPrecRadix
public int getNumPrecRadix() -
setAllowsPrecisionSpec
public void setAllowsPrecisionSpec(boolean allowsPrecisionSpec) -
isAllowsPrecisionSpec
public boolean isAllowsPrecisionSpec()
-