Package smile.data.type
Interface DataType
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ArrayType,BooleanType,ByteType,CharType,DateTimeType,DateType,DecimalType,DoubleType,FloatType,IntegerType,LongType,ObjectType,ShortType,StringType,StructType,TimeType
The interface of data types.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault DataTypeboxed()Returns the boxed data type if this is a primitive type.static DataTypeReturns the common type.id()Returns the type ID enum.static DataTypeInfers the type of string.default booleanReturns true if the type is boolean or Boolean.default booleanisByte()Returns true if the type is byte or Byte.default booleanisChar()Returns true if the type is char or Char.default booleanisDouble()Returns true if the type is double or Double.static booleanReturns true if the given type is of double, either primitive or boxed.default booleanisFloat()Returns true if the type is float or Float.static booleanReturns true if the given type is of float, either primitive or boxed.default booleanReturns true if the type is float or double.default booleanisInt()Returns true if the type is int or Integer.static booleanReturns true if the given type is of int, short, byte, char, either primitive or boxed.default booleanReturns true if the type is int, long, short or byte.default booleanisLong()Returns true if the type is long or Long.static booleanReturns true if the given type is of long, either primitive or boxed.default booleanReturns true if the type is numeric (integral or floating).default booleanisObject()Returns true if the type is ObjectType.default booleanReturns true if this is a primitive data type.default booleanisShort()Returns true if the type is short or Short.default booleanisString()Returns true if the type is String.name()Returns the type name used in external catalogs.static DataTypeReturns the DataType of a class.static DataTypeReturns a DataType from its string representation.static DataTypeReturns the DataType of a JDBC type.static DataTypeType promotion when apply to expressions.default StringReturns the string representation of a value of the type.default DataTypeunboxed()Returns the unboxed data type if this is a boxed primitive type.Returns the value from its string representation.
-
Method Details
-
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.
-
id
DataType.ID id()Returns the type ID enum.- Returns:
- the type ID enum.
-
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
-
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.
-
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.
-
boxed
Returns the boxed data type if this is a primitive type. Otherwise, return this type.- Returns:
- the boxed data type.
-
unboxed
Returns the unboxed data type if this is a boxed primitive type. Otherwise, return this type.- Returns:
- the unboxed data 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.
-
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.
-
isInt
Returns true if the given type is of int, short, byte, char, either primitive or boxed.- Parameters:
t- the data type.- Returns:
- true if the given type is of int.
-
isLong
Returns true if the given type is of long, either primitive or boxed.- Parameters:
t- the data type.- Returns:
- true if the given type is of long.
-
isFloat
Returns true if the given type is of float, either primitive or boxed.- Parameters:
t- the data type.- Returns:
- true if the given type is of float.
-
isDouble
Returns true if the given type is of double, either primitive or boxed.- Parameters:
t- the data type.- Returns:
- true if the given type is of double.
-