Package mgui.datasources
Class DataTypes
java.lang.Object
mgui.datasources.DataTypes
public class DataTypes
extends java.lang.Object
Class to provide functions for testing and comparing data types.
- Author:
- Andrew Reid
-
Field Summary
Fields Modifier and Type Field Description static intBINARYstatic intBLOBstatic intBOOLEANstatic intBYTEstatic intCHARstatic intCLOBstatic java.util.ArrayList<DataType>dataTypesstatic intDATEstatic intDECIMALstatic intDOUBLEstatic intFLOATstatic intINTEGERstatic intJAVA_OBJECTstatic intLONGstatic intLONGSTRINGstatic intRGBstatic intRGBAstatic intSHORTstatic intSINGLEstatic intSTRINGstatic intTIMESTAMPstatic intUSHORT -
Constructor Summary
Constructors Constructor Description DataTypes() -
Method Summary
Modifier and Type Method Description static intgetDataBufferType(java.lang.String type)static intgetDataBufferType(DataType type)static java.lang.StringgetDataBufferTypeStr(int type)static java.util.ArrayList<DataType>getDataTypeList()Returns a sorted list of strings representing data types as specified in the setDataTypes methodstatic DataTypegetFromDataBufferType(int db_type)static java.lang.ObjectgetInstanceForValue(java.lang.Object value, int data_type)Converts a value from aStringto an instance of the specified type.static intgetMappedSQLTypeDBMStoJDBC(int dataType, java.lang.String driverStr)Return data type mapped to particular driver (for non-standard types) from DBMS type to JDBC typestatic intgetMappedSQLTypeJDBCtoDBMS(int dataType, java.lang.String driverStr)static intgetSize(DataType type)Returns the number of bytes required to store a value of DataTypetype.static intgetSizeForSQLType(int type)Returns the number of bytes required to store a value of the SQL typetype.static intgetSizeForType(int type)Returns the number of bytes required to store a value of DataType valuetype.static intgetSQLStrValue(java.lang.String typeStr)Returns the equivalent integer value (fromTypesfor the given type string.static java.lang.ClassgetSQLTypeClass(int dataType)Return the class of given data typestatic java.lang.StringgetSQLTypeLabel(int SQLType)static java.lang.ObjectgetSQLTypeObject(int dataType)static java.lang.StringgetSQLTypeStr(int SQLType)static java.lang.StringgetSQLTypeStr(int SQLType, int length)static DataTypegetType(int val)static DataTypegetType(java.lang.String type)static DataTypegetTypeForSize(int size)static DataTypegetTypeForSQL(int SQLType)Returns aDataTypefor the given SQL type (fromTypes).static DataTypegetTypeForSQLStr(java.lang.String sqlType)static intguessDataType(java.lang.String token)Returns a best guess for the data type of the given string.static booleanisComparable(int dataType)static booleanisNumeric(int sqlType)Determines whether a given SQL type is numericstatic booleanisText(int sqlType)Determines whether a given SQL type is textstatic booleanisText(DataType dataType)Determines whether a given data type is textstatic booleanisType(java.lang.Object obj, int type)static voidsetSQLTypes(java.util.HashMap<java.lang.Integer,java.lang.String> map)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
INTEGER
public static final int INTEGER- See Also:
- Constant Field Values
-
DOUBLE
public static final int DOUBLE- See Also:
- Constant Field Values
-
SINGLE
public static final int SINGLE- See Also:
- Constant Field Values
-
CHAR
public static final int CHAR- See Also:
- Constant Field Values
-
STRING
public static final int STRING- See Also:
- Constant Field Values
-
LONGSTRING
public static final int LONGSTRING- See Also:
- Constant Field Values
-
BINARY
public static final int BINARY- See Also:
- Constant Field Values
-
BOOLEAN
public static final int BOOLEAN- See Also:
- Constant Field Values
-
SHORT
public static final int SHORT- See Also:
- Constant Field Values
-
FLOAT
public static final int FLOAT- See Also:
- Constant Field Values
-
LONG
public static final int LONG- See Also:
- Constant Field Values
-
RGB
public static final int RGB- See Also:
- Constant Field Values
-
RGBA
public static final int RGBA- See Also:
- Constant Field Values
-
BYTE
public static final int BYTE- See Also:
- Constant Field Values
-
USHORT
public static final int USHORT- See Also:
- Constant Field Values
-
CLOB
public static final int CLOB- See Also:
- Constant Field Values
-
BLOB
public static final int BLOB- See Also:
- Constant Field Values
-
JAVA_OBJECT
public static final int JAVA_OBJECT- See Also:
- Constant Field Values
-
TIMESTAMP
public static final int TIMESTAMP- See Also:
- Constant Field Values
-
DATE
public static final int DATE- See Also:
- Constant Field Values
-
DECIMAL
public static final int DECIMAL- See Also:
- Constant Field Values
-
dataTypes
-
-
Constructor Details
-
DataTypes
public DataTypes()
-
-
Method Details
-
setSQLTypes
public static void setSQLTypes(java.util.HashMap<java.lang.Integer,java.lang.String> map) -
getType
-
getType
-
getTypeForSQLStr
-
getTypeForSQL
Returns aDataTypefor the given SQL type (fromTypes).- Parameters:
SQLType-- Returns:
-
getSize
Returns the number of bytes required to store a value of DataTypetype.- Parameters:
type-- Returns:
-
getSizeForType
public static int getSizeForType(int type)Returns the number of bytes required to store a value of DataType valuetype.- Parameters:
type-- Returns:
-
getSizeForSQLType
public static int getSizeForSQLType(int type)Returns the number of bytes required to store a value of the SQL typetype.- Parameters:
type-- Returns:
-
getTypeForSize
-
getSQLTypeObject
public static java.lang.Object getSQLTypeObject(int dataType) -
getMappedSQLTypeDBMStoJDBC
public static int getMappedSQLTypeDBMStoJDBC(int dataType, java.lang.String driverStr)Return data type mapped to particular driver (for non-standard types) from DBMS type to JDBC type- Parameters:
dataType- DBMS typedriverStr- The driver URL as aString- Returns:
dataTypemapped to the JDBC type
-
getMappedSQLTypeJDBCtoDBMS
public static int getMappedSQLTypeJDBCtoDBMS(int dataType, java.lang.String driverStr) -
getSQLTypeLabel
public static java.lang.String getSQLTypeLabel(int SQLType) -
getSQLTypeStr
public static java.lang.String getSQLTypeStr(int SQLType) -
getSQLTypeStr
public static java.lang.String getSQLTypeStr(int SQLType, int length) -
getSQLStrValue
public static int getSQLStrValue(java.lang.String typeStr)Returns the equivalent integer value (fromTypesfor the given type string.- Parameters:
typeStr-- Returns:
-
isComparable
public static boolean isComparable(int dataType) -
isType
public static boolean isType(java.lang.Object obj, int type) -
getInstanceForValue
public static java.lang.Object getInstanceForValue(java.lang.Object value, int data_type) throws DataSourceExceptionConverts a value from aStringto an instance of the specified type.- Parameters:
value-data_type-- Returns:
- Throws:
DataSourceException- - Ifvaluecannot be converted to the specified type
-
guessDataType
public static int guessDataType(java.lang.String token)Returns a best guess for the data type of the given string.- Parameters:
token-- Returns:
-
getSQLTypeClass
public static java.lang.Class getSQLTypeClass(int dataType)Return the class of given data type- Parameters:
dataType-- Returns:
-
getDataBufferType
-
getFromDataBufferType
-
getDataBufferType
public static int getDataBufferType(java.lang.String type) -
getDataBufferTypeStr
public static java.lang.String getDataBufferTypeStr(int type) -
isNumeric
public static boolean isNumeric(int sqlType)Determines whether a given SQL type is numeric- Parameters:
sqlType-- Returns:
-
isText
public static boolean isText(int sqlType)Determines whether a given SQL type is text- Parameters:
sqlType-- Returns:
-
isText
Determines whether a given data type is text- Parameters:
sqlType-- Returns:
-
getDataTypeList
Returns a sorted list of strings representing data types as specified in the setDataTypes method- Returns:
- sorted ArrayList of strings
-