com.simba.dsi.dataengine.utilities
Class TypeUtilities

java.lang.Object
  extended by com.simba.dsi.dataengine.utilities.TypeUtilities

public class TypeUtilities
extends java.lang.Object

TypeUtilities is used as a utility class for types.


Field Summary
static int BIGINT_DISPLAY_SIZE
          Display size for big integer types.
static int BIT_COLUMN_SIZE
          Column size for bit types.
static int BIT_DISPLAY_SIZE
          Display size for bit types.
static int DATE_COLUMN_SIZE
          Column size for date types.
static int DATE_DISPLAY_SIZE
          Display size for signed date types.
static int DOUBLE_FLOAT_COLUMN_SIZE
          Column size for double and float types.
static int DOUBLE_FLOAT_DISPLAY_SIZE
          Display size for double and float types.
static int GUID_COLUMN_SIZE
          Column size for GUID types.
static int GUID_DISPLAY_SIZE
          Display size for GUID types.
static int INTEGER_COLUMN_SIZE
          Column size for integer types.
static int INTERVAL_DAY_COLUMN_SIZE
          Default display size for day interval type (2 characters ).
static int INTERVAL_DAY_TO_HOUR_COLUMN_SIZE
          Default display size for day to hour interval type (4 characters + 1 for '.').
static int INTERVAL_DAY_TO_MINUTE_COLUMN_SIZE
          Default display size for day to minute interval type (6 characters + 1 for '.' + 1 for ':').
static int INTERVAL_DAY_TO_SECOND_COLUMN_SIZE
          Default display size for day to second interval type (14 characters + 1 for each separator).
static int INTERVAL_HOUR_COLUMN_SIZE
          Default display size for hour interval type (2 characters).
static int INTERVAL_HOUR_TO_MINUTE_COLUMN_SIZE
          Default display size for hour to minute interval type (4 characters + 1 for ':').
static int INTERVAL_HOUR_TO_SECOND_COLUMN_SIZE
          Default display size for hour to second interval type (12 characters + 1 for each separator).
static int INTERVAL_MINUTE_COLUMN_SIZE
          Default display size for minute interval type (2 characters).
static int INTERVAL_MINUTE_TO_SECOND_COLUMN_SIZE
          Default display size for minute to second interval type (10 characters + 1 for each separator).
static int INTERVAL_MONTH_COLUMN_SIZE
          Default display size for month interval type (2 characters).
static int INTERVAL_SECOND_COLUMN_SIZE
          Default display size for second interval type (2 characters + 1 for '.' + 6 for default seconds precision).
static int INTERVAL_YEAR_COLUMN_SIZE
          Default display size for year interval type (2 characters).
static int INTERVAL_YEAR_TO_MONTH_COLUMN_SIZE
          Default display size for year to month interval type (4 characters + 1 for '-').
static int REAL_COLUMN_SIZE
          Column size for real types.
static int REAL_DISPLAY_SIZE
          Display size for real types.
static int SBIGINT_COLUMN_SIZE
          Column size for signed bigint types.
static int SINT_DISPLAY_SIZE
          Display size for signed integer types.
static int SMALLINT_COLUMN_SIZE
          Column size for smallint types.
static int SSMALLINT_DISPLAY_SIZE
          Display size for signed small integer types.
static int STINYINT_DISPLAY_SIZE
          Display size for signed tiny integer types.
static int TIME_NO_FRAC_PREC_DISPLAY_SIZE
          Display size for signed time types.
static int TIME_WITH_FRAC_PREC_DISPLAY_SIZE
          Display size for signed time types.
static int TIMESTAMP_NO_FRAC_PREC_DISPLAY_SIZE
          Display size for signed time stamp types.
static int TIMESTAMP_WITH_FRAC_PREC_DISPLAY_SIZE
          Display size for signed time stamp types.
static int TINYINT_COLUMN_SIZE
          Column size for tinyint types.
static int UBIGINT_COLUMN_SIZE
          Column size for unsigned bigint types.
static int UINT_DISPLAY_SIZE
          Display size for unsigned integer types.
static int USMALLINT_DISPLAY_SIZE
          Display size for unsigned small integer types.
static int UTINYINT_DISPLAY_SIZE
          Display size for unsigned tiny integer types.
 
Constructor Summary
TypeUtilities()
           
 
Method Summary
static long getColumnSize(TypeMetadata typeMetadata, long columnLength)
          Gets the Column Size for the given type.
static long getDisplaySize(TypeMetadata typeMetadata, long columnSize)
          Calculates the display size for the given type and the given column size value from the DSI.
static short getIntervalCodeFromConciseType(int conciseType)
          Get the interval code from the specified concise type.
static int getNumPrecRadix(short sqlType)
          Gets the numeric precision radix used in ODBC.
static int getSizeInBytes(int type)
          Gets the size in bytes (For ODBC) of the given fixed-length type.
static java.util.Set<java.lang.Integer> getSupportedSqlTypes()
           
static java.lang.Integer getTypeForSqlTypeString(java.lang.String sqlTypeName)
          Converts the string representation of a SQL type (i.e.
static int getVerboseTypeFromConciseType(int conciseType)
          Get the verbose type corresponding to the specified concise type.
static boolean isApproximateNumericType(int type)
          Indicates whether the specified type is an approximate numeric type.
static boolean isBinaryType(int type)
          Indicates whether the specified type is a binary type.
static boolean isBooleanType(int type)
          Indicates whether the specified type is a Boolean type.
static boolean isCharacterOrBinaryType(int type)
          Indicates whether the specified type is a character or binary type.
static boolean isCharacterType(int type)
          Indicates whether the specified type is a character type.
static boolean isDateTimeType(int type)
          Indicates whether the specified type is a datetime type.
static boolean isExactNumericType(int type)
          Indicates whether the specified type is an exact numeric type.
static boolean isIntegerType(int type)
          Indicates whether the specified type is an integer type.
static boolean isIntervalType(int type)
          Indicates whether the specified type in an interval type.
static boolean isLOBType(int type)
          Indicates whether the specified type is a large object (LOB) type.
static boolean isNumberType(int type)
          Indicates whether the specified type is a number type.
static boolean isTimeType(int type)
          Indicates whether the specified type is a time type.
static int mapDataTypes(int sqlType)
          Maps internal SQL data types to JDBC SQL data types.
static int NormalizeDateTimeTypeForODBC2(int in_sqlType, boolean in_isODBC2)
          Converts SQL_TYPE_(DATE/TIME/TIMESTAMP) <-> SQL_(DATE/TIME/TIMESTAMP) based on whether we're running in the context of an ODBC 2.X driver or not.
static java.lang.String sqlTypeToString(short sqlType)
          Converts a SQL type to its corresponding string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BIT_DISPLAY_SIZE

public static final int BIT_DISPLAY_SIZE
Display size for bit types.

(1 digit)

See Also:
Constant Field Values

DOUBLE_FLOAT_DISPLAY_SIZE

public static final int DOUBLE_FLOAT_DISPLAY_SIZE
Display size for double and float types.

A sign, 15 digits, a decimal point, the letter E, a sign, and 3 digits

See Also:
Constant Field Values

REAL_DISPLAY_SIZE

public static final int REAL_DISPLAY_SIZE
Display size for real types.

A sign, 7 digits, a decimal point, the letter E, a sign, and 2 digits

See Also:
Constant Field Values

BIGINT_DISPLAY_SIZE

public static final int BIGINT_DISPLAY_SIZE
Display size for big integer types.

20 (a sign and 19 digits if signed or 20 digits if unsigned).

See Also:
Constant Field Values

GUID_DISPLAY_SIZE

public static final int GUID_DISPLAY_SIZE
Display size for GUID types.

See Also:
Constant Field Values

UINT_DISPLAY_SIZE

public static final int UINT_DISPLAY_SIZE
Display size for unsigned integer types.

10 digits

See Also:
Constant Field Values

SINT_DISPLAY_SIZE

public static final int SINT_DISPLAY_SIZE
Display size for signed integer types.

A sign and 10 digits

See Also:
Constant Field Values

USMALLINT_DISPLAY_SIZE

public static final int USMALLINT_DISPLAY_SIZE
Display size for unsigned small integer types.

5 digits

See Also:
Constant Field Values

SSMALLINT_DISPLAY_SIZE

public static final int SSMALLINT_DISPLAY_SIZE
Display size for signed small integer types.

A sign and 5 digits

See Also:
Constant Field Values

UTINYINT_DISPLAY_SIZE

public static final int UTINYINT_DISPLAY_SIZE
Display size for unsigned tiny integer types.

3 digits

See Also:
Constant Field Values

STINYINT_DISPLAY_SIZE

public static final int STINYINT_DISPLAY_SIZE
Display size for signed tiny integer types.

A sign and 3 digits

See Also:
Constant Field Values

DATE_DISPLAY_SIZE

public static final int DATE_DISPLAY_SIZE
Display size for signed date types.

A date in the format yyyy-mm-dd

See Also:
Constant Field Values

TIME_NO_FRAC_PREC_DISPLAY_SIZE

public static final int TIME_NO_FRAC_PREC_DISPLAY_SIZE
Display size for signed time types.

A time in the format hh:mm:ss

See Also:
Constant Field Values

TIME_WITH_FRAC_PREC_DISPLAY_SIZE

public static final int TIME_WITH_FRAC_PREC_DISPLAY_SIZE
Display size for signed time types.

A time in the format hh:mm:ss[.fff...]

See Also:
Constant Field Values

TIMESTAMP_NO_FRAC_PREC_DISPLAY_SIZE

public static final int TIMESTAMP_NO_FRAC_PREC_DISPLAY_SIZE
Display size for signed time stamp types.

For a timestamp in the yyyy-mm-dd hh:mm:ss format

See Also:
Constant Field Values

TIMESTAMP_WITH_FRAC_PREC_DISPLAY_SIZE

public static final int TIMESTAMP_WITH_FRAC_PREC_DISPLAY_SIZE
Display size for signed time stamp types.

For a timestamp in the yyyy-mm-dd hh:mm:ss[.fff...] format

See Also:
Constant Field Values

BIT_COLUMN_SIZE

public static final int BIT_COLUMN_SIZE
Column size for bit types.

See Also:
Constant Field Values

DATE_COLUMN_SIZE

public static final int DATE_COLUMN_SIZE
Column size for date types.

See Also:
Constant Field Values

DOUBLE_FLOAT_COLUMN_SIZE

public static final int DOUBLE_FLOAT_COLUMN_SIZE
Column size for double and float types.

See Also:
Constant Field Values

GUID_COLUMN_SIZE

public static final int GUID_COLUMN_SIZE
Column size for GUID types.

See Also:
Constant Field Values

INTEGER_COLUMN_SIZE

public static final int INTEGER_COLUMN_SIZE
Column size for integer types.

See Also:
Constant Field Values

REAL_COLUMN_SIZE

public static final int REAL_COLUMN_SIZE
Column size for real types.

See Also:
Constant Field Values

SMALLINT_COLUMN_SIZE

public static final int SMALLINT_COLUMN_SIZE
Column size for smallint types.

See Also:
Constant Field Values

TINYINT_COLUMN_SIZE

public static final int TINYINT_COLUMN_SIZE
Column size for tinyint types.

See Also:
Constant Field Values

SBIGINT_COLUMN_SIZE

public static final int SBIGINT_COLUMN_SIZE
Column size for signed bigint types.

See Also:
Constant Field Values

UBIGINT_COLUMN_SIZE

public static final int UBIGINT_COLUMN_SIZE
Column size for unsigned bigint types.

See Also:
Constant Field Values

INTERVAL_YEAR_COLUMN_SIZE

public static final int INTERVAL_YEAR_COLUMN_SIZE
Default display size for year interval type (2 characters). Otherwise it would be the leading precision.

See Also:
Constant Field Values

INTERVAL_YEAR_TO_MONTH_COLUMN_SIZE

public static final int INTERVAL_YEAR_TO_MONTH_COLUMN_SIZE
Default display size for year to month interval type (4 characters + 1 for '-'). Otherwise it would be the leading precision + 3.

See Also:
Constant Field Values

INTERVAL_MONTH_COLUMN_SIZE

public static final int INTERVAL_MONTH_COLUMN_SIZE
Default display size for month interval type (2 characters). Otherwise it would be the leading precision.

See Also:
Constant Field Values

INTERVAL_DAY_COLUMN_SIZE

public static final int INTERVAL_DAY_COLUMN_SIZE
Default display size for day interval type (2 characters ). Otherwise it would be the leading precision.

See Also:
Constant Field Values

INTERVAL_DAY_TO_HOUR_COLUMN_SIZE

public static final int INTERVAL_DAY_TO_HOUR_COLUMN_SIZE
Default display size for day to hour interval type (4 characters + 1 for '.'). Otherwise it would be the leading precision + 3.

See Also:
Constant Field Values

INTERVAL_DAY_TO_MINUTE_COLUMN_SIZE

public static final int INTERVAL_DAY_TO_MINUTE_COLUMN_SIZE
Default display size for day to minute interval type (6 characters + 1 for '.' + 1 for ':'). Otherwise it would be the leading precision + 6.

See Also:
Constant Field Values

INTERVAL_DAY_TO_SECOND_COLUMN_SIZE

public static final int INTERVAL_DAY_TO_SECOND_COLUMN_SIZE
Default display size for day to second interval type (14 characters + 1 for each separator). Otherwise it would be the leading precision + 16.

See Also:
Constant Field Values

INTERVAL_HOUR_COLUMN_SIZE

public static final int INTERVAL_HOUR_COLUMN_SIZE
Default display size for hour interval type (2 characters). Otherwise it would be the leading precision.

See Also:
Constant Field Values

INTERVAL_HOUR_TO_MINUTE_COLUMN_SIZE

public static final int INTERVAL_HOUR_TO_MINUTE_COLUMN_SIZE
Default display size for hour to minute interval type (4 characters + 1 for ':'). Otherwise it would be the leading precision + 3.

See Also:
Constant Field Values

INTERVAL_HOUR_TO_SECOND_COLUMN_SIZE

public static final int INTERVAL_HOUR_TO_SECOND_COLUMN_SIZE
Default display size for hour to second interval type (12 characters + 1 for each separator). Otherwise it would be the leading precision + 13.

See Also:
Constant Field Values

INTERVAL_MINUTE_COLUMN_SIZE

public static final int INTERVAL_MINUTE_COLUMN_SIZE
Default display size for minute interval type (2 characters). Otherwise it would be the leading precision.

See Also:
Constant Field Values

INTERVAL_MINUTE_TO_SECOND_COLUMN_SIZE

public static final int INTERVAL_MINUTE_TO_SECOND_COLUMN_SIZE
Default display size for minute to second interval type (10 characters + 1 for each separator). Otherwise it would be the leading precision + 10.

See Also:
Constant Field Values

INTERVAL_SECOND_COLUMN_SIZE

public static final int INTERVAL_SECOND_COLUMN_SIZE
Default display size for second interval type (2 characters + 1 for '.' + 6 for default seconds precision). Otherwise it would be the leading precision + 7.

See Also:
Constant Field Values
Constructor Detail

TypeUtilities

public TypeUtilities()
Method Detail

getColumnSize

public static long getColumnSize(TypeMetadata typeMetadata,
                                 long columnLength)
                          throws com.simba.support.exceptions.ErrorException
Gets the Column Size for the given type. Used for SqlColumns.

Parameters:
typeMetadata - The type's metadata.
columnLength - The column's column length.
Returns:
The Column Size for the given type.
Throws:
com.simba.support.exceptions.ErrorException - If there is an error.

getSizeInBytes

public static int getSizeInBytes(int type)
Gets the size in bytes (For ODBC) of the given fixed-length type.

Parameters:
type - The SQL type. Must be a fixed-length type.
Returns:
The size in bytes of the given SQL type.

getDisplaySize

public static long getDisplaySize(TypeMetadata typeMetadata,
                                  long columnSize)
                           throws com.simba.support.exceptions.ErrorException
Calculates the display size for the given type and the given column size value from the DSI.

See http://msdn2.microsoft.com/en-gb/library/ms713974.aspx for information on these calculations.

Parameters:
typeMetadata - Type metadata.
columnSize - Width of the column in number of elements (only used in some cases).
Returns:
The display size.
Throws:
com.simba.support.exceptions.ErrorException - If the data type is unsupported.

getIntervalCodeFromConciseType

public static short getIntervalCodeFromConciseType(int conciseType)
Get the interval code from the specified concise type.

Parameters:
conciseType - The concise type.
Returns:
The corresponding interval code.

getSupportedSqlTypes

public static java.util.Set<java.lang.Integer> getSupportedSqlTypes()
Returns:
A set of the SQL types supported by the SDK. These come from java.sql.Types and com.simba.dsi.core.utilities.SqlType

getVerboseTypeFromConciseType

public static int getVerboseTypeFromConciseType(int conciseType)
Get the verbose type corresponding to the specified concise type.

Parameters:
conciseType - The concise type.
Returns:
The corresponding verbose type.

isApproximateNumericType

public static boolean isApproximateNumericType(int type)
Indicates whether the specified type is an approximate numeric type.

The following types are considered approximate numeric types:

Parameters:
type - The type to check.
Returns:
true if the type is an approximate numeric type; false otherwise.

isBinaryType

public static boolean isBinaryType(int type)
Indicates whether the specified type is a binary type.

The following types are considered binary types:

Parameters:
type - The type to check.
Returns:
true if the type is a binary type; false otherwise.

isBooleanType

public static boolean isBooleanType(int type)
Indicates whether the specified type is a Boolean type.

The following types are considered boolean types:

Parameters:
type - The type to check.
Returns:
true if the type is a Boolean type; false otherwise.

isCharacterOrBinaryType

public static boolean isCharacterOrBinaryType(int type)
Indicates whether the specified type is a character or binary type.

The following types are considered character or binary types:

Parameters:
type - The type to check.
Returns:
true if the type is a character or binary type; false otherwise.

isCharacterType

public static boolean isCharacterType(int type)
Indicates whether the specified type is a character type.

The following types are considered character types:

Parameters:
type - The type to check.
Returns:
true if the type is a character type; false otherwise.

isDateTimeType

public static boolean isDateTimeType(int type)
Indicates whether the specified type is a datetime type.

The following types are considered datetime types:

Parameters:
type - The type to check.
Returns:
true if the type is a datetime type; false otherwise.

isExactNumericType

public static boolean isExactNumericType(int type)
Indicates whether the specified type is an exact numeric type.

The following types are considered exact numeric types:

Parameters:
type - The type to check.
Returns:
true if the type is an exact numeric type; false otherwise.

isNumberType

public static boolean isNumberType(int type)
Indicates whether the specified type is a number type.

The following types are considered number types:

Parameters:
type - The type to check.
Returns:
true if the type is a number type; false otherwise.

isIntegerType

public static boolean isIntegerType(int type)
Indicates whether the specified type is an integer type.

The following types are considered integer types:

Parameters:
type - The type to check.
Returns:
true if the type is an integer type; false otherwise.

isIntervalType

public static boolean isIntervalType(int type)
Indicates whether the specified type in an interval type.

The following types are considered interval types:

Parameters:
type - The type to check.
Returns:
true if the type in an interval type; false otherwise.

isLOBType

public static boolean isLOBType(int type)
Indicates whether the specified type is a large object (LOB) type.

The following types are considered LOB types:

Parameters:
type - The type to check.
Returns:
true if the type is a LOB type; false otherwise.

isTimeType

public static boolean isTimeType(int type)
Indicates whether the specified type is a time type.

The following types are considered time types:

Parameters:
type - The type to check.
Returns:
true if the type is a time type; false otherwise.

mapDataTypes

public static int mapDataTypes(int sqlType)
Maps internal SQL data types to JDBC SQL data types.

Parameters:
sqlType - The internal SQL data type to map.
Returns:
The JDBC SQL data type that corresponds to the internal SQL data type.

NormalizeDateTimeTypeForODBC2

public static int NormalizeDateTimeTypeForODBC2(int in_sqlType,
                                                boolean in_isODBC2)
Converts SQL_TYPE_(DATE/TIME/TIMESTAMP) <-> SQL_(DATE/TIME/TIMESTAMP) based on whether we're running in the context of an ODBC 2.X driver or not.

Parameters:
in_sqlType - The SQL type identifier to normalize.
in_isODBC2 - Whether we're running in the context of an ODBC 2.x driver.
Returns:
The normalized SQL type identifier (unchanged from in_sqlType if it wasn't a datetime type).

getTypeForSqlTypeString

public static java.lang.Integer getTypeForSqlTypeString(java.lang.String sqlTypeName)
Converts the string representation of a SQL type (i.e. "SQL_INTEGER") into the typecode (i.e. java.sql.Types.INTEGER).

Parameters:
sqlTypeName - The string representation of the SQL type. (Must not be null)
Returns:
The sql type's typecode, or NULL if one couldn't be found.

sqlTypeToString

public static java.lang.String sqlTypeToString(short sqlType)
Converts a SQL type to its corresponding string. Returns null if the type is not found.

Parameters:
sqlType - The type to convert from.
Returns:
the string representation of the given SQL type, or null.

getNumPrecRadix

public static int getNumPrecRadix(short sqlType)
Gets the numeric precision radix used in ODBC.

Parameters:
sqlType - The sql type.
Returns:
The numeric precision radix.


Copyright © 2006-2014 Simba Technologies Incorporated. All Rights Reserved.