Package smile.data.type
Interface DataType
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ArrayType
,BooleanType
,ByteType
,CharType
,DateTimeType
,DateType
,DecimalType
,DoubleType
,FloatType
,IntType
,LongType
,ObjectType
,PrimitiveType
,ShortType
,StringType
,StructType
,TimeType
The interface of data types.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic DataType
Returns the common type.id()
Returns the type ID enum.static DataType
Infers the type of string.default boolean
Returns true if the type is boolean or Boolean.default boolean
isByte()
Returns true if the type is byte or Byte.default boolean
isChar()
Returns true if the type is char or Char.default boolean
Returns true if the type is decimal.default boolean
isDouble()
Returns true if the type is double or Double.default boolean
isFloat()
Returns true if the type is float or Float.default boolean
Returns true if the type is float or double.default boolean
isInt()
Returns true if the type is int or Integer.default boolean
Returns true if the type is int, long, short or byte.default boolean
isLong()
Returns true if the type is long or Long.default boolean
Returns true if the data may be null.default boolean
Returns true if the type is numeric (integral or floating).default boolean
isObject()
Returns true if the type is ObjectType.default boolean
Returns true if this is a primitive data type.default boolean
isShort()
Returns true if the type is short or Short.default boolean
isString()
Returns true if the type is String.name()
Returns the type name used in external catalogs.static DataType
Returns the DataType of a class.static DataType
Returns a DataType from its string representation.static DataType
Returns the DataType of a JDBC type.static DataType
Type promotion when apply to expressions.default String
Returns the string representation of a value of the type.Returns the value from its string representation.
-
Method Details
-
id
DataType.ID id()Returns the type ID enum.- Returns:
- the type ID enum.
-
name
String name()Returns the type name used in external catalogs. DataType.of(name()) should return the same type.- Returns:
- the type name used in external catalogs.
-
valueOf
Returns the value from its string representation.- Parameters:
s
- the string representation of a value of this type.- Returns:
- the value.
-
toString
Returns the string representation of a value of the type.- Parameters:
o
- the value.- Returns:
- the string representation
-
isNullable
default boolean isNullable()Returns true if the data may be null.- Returns:
- true if the data may be null.
-
isPrimitive
default boolean isPrimitive()Returns true if this is a primitive data type.- Returns:
- true if this is a primitive data type.
-
isFloating
default boolean isFloating()Returns true if the type is float or double.- Returns:
- true if the type is float or double.
-
isIntegral
default boolean isIntegral()Returns true if the type is int, long, short or byte.- Returns:
- true if the type is int, long, short or byte.
-
isNumeric
default boolean isNumeric()Returns true if the type is numeric (integral or floating).- Returns:
- true if the type is numeric (integral or floating).
-
isBoolean
default boolean isBoolean()Returns true if the type is boolean or Boolean.- Returns:
- true if the type is boolean or Boolean.
-
isChar
default boolean isChar()Returns true if the type is char or Char.- Returns:
- true if the type is char or Char.
-
isByte
default boolean isByte()Returns true if the type is byte or Byte.- Returns:
- true if the type is byte or Byte.
-
isShort
default boolean isShort()Returns true if the type is short or Short.- Returns:
- true if the type is short or Short.
-
isInt
default boolean isInt()Returns true if the type is int or Integer.- Returns:
- true if the type is int or Integer.
-
isLong
default boolean isLong()Returns true if the type is long or Long.- Returns:
- true if the type is long or Long.
-
isDecimal
default boolean isDecimal()Returns true if the type is decimal.- Returns:
- true if the type is decimal.
-
isFloat
default boolean isFloat()Returns true if the type is float or Float.- Returns:
- true if the type is float or Float.
-
isDouble
default boolean isDouble()Returns true if the type is double or Double.- Returns:
- true if the type is double or Double.
-
isString
default boolean isString()Returns true if the type is String.- Returns:
- true if the type is String.
-
isObject
default boolean isObject()Returns true if the type is ObjectType.- Returns:
- true if the type is ObjectType.
-
prompt
Type promotion when apply to expressions. First, all byte, short, and char values are promoted to int. Then, if one operand is a long, the whole expression is promoted to long. If one operand is a float, the entire expression is promoted to float. If any of the operands is double, the result is double.- Parameters:
a
- the data type.b
- the data type.- Returns:
- the promoted type.
-
coerce
Returns the common type. This method is intended to be used for inferring the schema from text files. This is NOT a general implementation of type coercion.- Parameters:
a
- the data type.b
- the data type.- Returns:
- the common type.
-
infer
Infers the type of string.- Parameters:
s
- the string value.- Returns:
- the inferred data type of string value.
-
of
Returns a DataType from its string representation.- Parameters:
s
- the string representation of data type.- Returns:
- the data type.
- Throws:
ClassNotFoundException
- when fails to load a class.
-
of
Returns the DataType of a class.- Parameters:
clazz
- the Class object.- Returns:
- Smile data type.
-
of
Returns the DataType of a JDBC type.- Parameters:
type
- the JDBC data type.nullable
- true if the column value may be null.dbms
- The database product name.- Returns:
- Smile data type.
-