Enum SQLDataType
- java.lang.Object
-
- java.lang.Enum<SQLDataType>
-
- edu.caltech.nanodb.relations.SQLDataType
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<SQLDataType>
public enum SQLDataType extends java.lang.Enum<SQLDataType>
An enumeration of the SQL data-types that are supported by NanoDB. NanoDB does not support a dynamic or user-extensible type system, although the process for programmatically adding new data-types should be relatively straightforward.Each data-type also has an integer type-ID associated with it, accessible via the
getTypeID()
method. The values start at 1 and go up. Note that type-IDs are currentlybyte
values. This is to facilitate compact storage in the data dictionary. If more than 127 data-types are needed (which is unlikely), keep in mind that this will affect the storage format in the data-dictionary.The type-ID values currently fall in ranges so that similar types can be grouped together. Besides aesthetics, this also allows us to easily tell if a type is a number, or a string, etc. Here is the current breakdown:
- Number types: 1..20
- Character types: 21..30
- Date/time types: 31..40
- Miscellaneous types: 41..*
-
-
Enum Constant Summary
Enum Constants Enum Constant Description BIGINT
An 8-byte signed integer, designated in SQL as BIGINT.BLOB
A large byte-sequence, with a very large maximum length.CHAR
A fixed-length character-sequence, with a specified length.DATE
A date value containing year, month, and day.DATETIME
DOUBLE
An 8-byte signed floating-point number with 53 bits of precision, designated in SQL as DOUBLE.FILE_POINTER
A file-pointer value.FLOAT
A 4-byte signed floating-point number with 24 bits of precision, designated in SQL as FLOAT.INTEGER
A 4-byte signed integer, designated in SQL as INTEGER.INTERVAL
A temporal interval value.NULL
A placeholder type for NULL literalsNUMERIC
A decimal value with a specified precision and scale.SMALLINT
A 2-byte signed integer, designated in SQL as SMALLINT.TEXT
A large character-sequence, with a very large maximum length.TIME
A time value containing hours, minutes, and seconds.TIMESTAMP
A date/time value with higher precision than theDATETIME
value.TINYINT
A 1-byte signed integer, designated in SQL as TINYINT.VARCHAR
A variable-length character-sequence, with a specified maximum length.
-
Field Summary
Fields Modifier and Type Field Description private byte
typeID
The ID of the datatype.
-
Constructor Summary
Constructors Modifier Constructor Description private
SQLDataType(byte typeID)
Construct a new SQLDataType instance with the specified type ID.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SQLDataType
findType(byte typeID)
Given the specified ID, this method returns the corresponding SQL data type enum value, or it returnsnull
if the type value doesn't signify any SQL data type in this enumeration.byte
getTypeID()
Returns this SQL data-type's unique ID.static boolean
isNumber(SQLDataType type)
static boolean
isString(SQLDataType type)
static SQLDataType
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static SQLDataType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NULL
public static final SQLDataType NULL
A placeholder type for NULL literals
-
INTEGER
public static final SQLDataType INTEGER
A 4-byte signed integer, designated in SQL as INTEGER. It corresponds to the Javaint
data-type.
-
SMALLINT
public static final SQLDataType SMALLINT
A 2-byte signed integer, designated in SQL as SMALLINT. It corresponds to the Javashort
data-type.
-
BIGINT
public static final SQLDataType BIGINT
An 8-byte signed integer, designated in SQL as BIGINT. It corresponds to the Javalong
data-type. This is not a standard SQL data-type.
-
TINYINT
public static final SQLDataType TINYINT
A 1-byte signed integer, designated in SQL as TINYINT. It corresponds to the Javabyte
data-type. This is not a standard SQL data-type.
-
FLOAT
public static final SQLDataType FLOAT
A 4-byte signed floating-point number with 24 bits of precision, designated in SQL as FLOAT. It corresponds to the Javafloat
data-type.The SQL standard contains this data-type, but specifies additional options provided here.
-
DOUBLE
public static final SQLDataType DOUBLE
An 8-byte signed floating-point number with 53 bits of precision, designated in SQL as DOUBLE. It corresponds to the Javadouble
data-type.The SQL standard contains this data-type, but specifies additional options provided here.
-
NUMERIC
public static final SQLDataType NUMERIC
A decimal value with a specified precision and scale.
-
CHAR
public static final SQLDataType CHAR
A fixed-length character-sequence, with a specified length.
-
VARCHAR
public static final SQLDataType VARCHAR
A variable-length character-sequence, with a specified maximum length.
-
TEXT
public static final SQLDataType TEXT
A large character-sequence, with a very large maximum length.
-
BLOB
public static final SQLDataType BLOB
A large byte-sequence, with a very large maximum length.
-
DATE
public static final SQLDataType DATE
A date value containing year, month, and day.
-
TIME
public static final SQLDataType TIME
A time value containing hours, minutes, and seconds.
-
DATETIME
public static final SQLDataType DATETIME
-
TIMESTAMP
public static final SQLDataType TIMESTAMP
A date/time value with higher precision than theDATETIME
value.
-
INTERVAL
public static final SQLDataType INTERVAL
A temporal interval value.
-
FILE_POINTER
public static final SQLDataType FILE_POINTER
A file-pointer value. This is not exposed in SQL, but is used internally.
-
-
Constructor Detail
-
SQLDataType
private SQLDataType(byte typeID)
Construct a new SQLDataType instance with the specified type ID. Each data-type should have a unique ID. Note that this constructor is private, since this is the only place where SQL data-types should be declared.- Parameters:
typeID
- the unique numeric ID for this SQL data type
-
-
Method Detail
-
values
public static SQLDataType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (SQLDataType c : SQLDataType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static SQLDataType valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getTypeID
public byte getTypeID()
Returns this SQL data-type's unique ID.- Returns:
- this SQL data type's unique ID.
-
findType
public static SQLDataType findType(byte typeID)
Given the specified ID, this method returns the corresponding SQL data type enum value, or it returnsnull
if the type value doesn't signify any SQL data type in this enumeration.- Parameters:
typeID
- the ID of the type to search for- Returns:
- the SQLDataType value corresponding to the specified type ID, or null if no corresponding value could be found.
-
isNumber
public static boolean isNumber(SQLDataType type)
-
isString
public static boolean isString(SQLDataType type)
-
-