- java.lang.Object
-
- java.lang.Enum<DataType>
-
- org.tentackle.model.DataType
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDataType.SqlTypeWithPostfixPair of SqlType and its name postfix.
-
Enum Constant Summary
Enum Constants Enum Constant Description APPLICATIONApplication specific type.
Such types are immutable because they just convert data between internal and external representation.BIGDECIMALABigDecimal.BINARYABinary.BMONEYABMoney(tentackle type).BOOLEANABoolean.BOOLEAN_PRIMITIVEA boolean (primitive).BYTEAByte.BYTE_PRIMITIVEA byte (primitive).CHARACTERACharacter.CHARACTER_PRIMITIVEA char (primitive).DATEADate.DMONEYADMoney(tentackle type).DOUBLEADouble.DOUBLE_PRIMITIVEA double (primitive).FLOATAFloat.FLOAT_PRIMITIVEA float (primitive).INTEGERAInteger.INTEGER_PRIMITIVEAn int (primitive).LARGESTRINGA very largeString.LOCALDATEALocalDate.LOCALDATETIMEALocalDateTime.LOCALTIMEALocalTime.LONGALong.LONG_PRIMITIVEA long (primitive).SHORTAShort.SHORT_PRIMITIVEA short (primitive).STRINGAString.TIMEATime.TIMESTAMPATimestamp.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DataTypecreateFromJavaType(java.lang.String javaType)Creates a datatype from a java type string.org.tentackle.sql.SqlType[]getSqlTypes()Gets the sql type.
Notice that a tentackle type may be mapped to more than one column for multi-column types such as BMoney.DataType.SqlTypeWithPostfix[]getSqlTypesWithPostfix()Gets the SqlTypes along with their column name postfixes.booleanisBool()Returns whether this is a boolean or Boolean type.booleanisDateOrTime()Returns whether this is a date and/or time type.booleanisMultiColumn()True if this is a multicolumn type.booleanisMutable()Returns whether type is a mutable java object.
Mutable objects may change their state and must implementFreezable.booleanisNumeric()Returns whether this is a numeric type.booleanisPrimitive()Returns whether type is a primitive.booleanisScaleInSecondColumn()Returns whether this is a numeric type with the scale stored in a second column.java.lang.Objectparse(java.lang.String str)Parses a string and converts to the value of this type.java.lang.Stringprint(java.lang.Object object)Takes an object and converts it to a string that can in turn be parsed withparse(java.lang.String).DataTypetoNonPrimitive()Converts a primitive to a Java class.DataTypetoPrimitive()Converts to a Java primitive.java.lang.StringtoString()static DataTypevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static DataType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
STRING
public static final DataType STRING
AString.
-
LARGESTRING
public static final DataType LARGESTRING
A very largeString.
-
DATE
public static final DataType DATE
ADate.
-
TIME
public static final DataType TIME
ATime.
-
TIMESTAMP
public static final DataType TIMESTAMP
ATimestamp.
-
LOCALDATE
public static final DataType LOCALDATE
ALocalDate.
-
LOCALTIME
public static final DataType LOCALTIME
ALocalTime.
-
LOCALDATETIME
public static final DataType LOCALDATETIME
ALocalDateTime.
-
BINARY
public static final DataType BINARY
ABinary.
-
BIGDECIMAL
public static final DataType BIGDECIMAL
ABigDecimal.
-
BMONEY
public static final DataType BMONEY
ABMoney(tentackle type).
-
DMONEY
public static final DataType DMONEY
ADMoney(tentackle type).
-
CHARACTER
public static final DataType CHARACTER
ACharacter.
-
CHARACTER_PRIMITIVE
public static final DataType CHARACTER_PRIMITIVE
A char (primitive).
-
BOOLEAN
public static final DataType BOOLEAN
ABoolean.
-
BOOLEAN_PRIMITIVE
public static final DataType BOOLEAN_PRIMITIVE
A boolean (primitive).
-
BYTE
public static final DataType BYTE
AByte.
-
BYTE_PRIMITIVE
public static final DataType BYTE_PRIMITIVE
A byte (primitive).
-
SHORT
public static final DataType SHORT
AShort.
-
SHORT_PRIMITIVE
public static final DataType SHORT_PRIMITIVE
A short (primitive).
-
INTEGER
public static final DataType INTEGER
AInteger.
-
INTEGER_PRIMITIVE
public static final DataType INTEGER_PRIMITIVE
An int (primitive).
-
LONG
public static final DataType LONG
ALong.
-
LONG_PRIMITIVE
public static final DataType LONG_PRIMITIVE
A long (primitive).
-
FLOAT
public static final DataType FLOAT
AFloat.
-
FLOAT_PRIMITIVE
public static final DataType FLOAT_PRIMITIVE
A float (primitive).
-
DOUBLE
public static final DataType DOUBLE
ADouble.
-
DOUBLE_PRIMITIVE
public static final DataType DOUBLE_PRIMITIVE
A double (primitive).
-
APPLICATION
public static final DataType APPLICATION
Application specific type.
Such types are immutable because they just convert data between internal and external representation. In most cases this is an enum.
-
-
Method Detail
-
values
public static DataType[] 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 (DataType c : DataType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static DataType 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
-
createFromJavaType
public static DataType createFromJavaType(java.lang.String javaType)
Creates a datatype from a java type string.- Parameters:
javaType- the java type- Returns:
- the datatype, null if no such type
-
isPrimitive
public boolean isPrimitive()
Returns whether type is a primitive.- Returns:
- true if primitive
-
isMutable
public boolean isMutable()
Returns whether type is a mutable java object.
Mutable objects may change their state and must implementFreezable.- Returns:
- true if mutable and freezable
-
isNumeric
public boolean isNumeric()
Returns whether this is a numeric type.- Returns:
- true if numeric
-
isDateOrTime
public boolean isDateOrTime()
Returns whether this is a date and/or time type.- Returns:
- true if date or time type
-
isBool
public boolean isBool()
Returns whether this is a boolean or Boolean type.- Returns:
- true if bool
-
getSqlTypes
public org.tentackle.sql.SqlType[] getSqlTypes()
Gets the sql type.
Notice that a tentackle type may be mapped to more than one column for multi-column types such as BMoney.- Returns:
- the sql type(s)
-
getSqlTypesWithPostfix
public DataType.SqlTypeWithPostfix[] getSqlTypesWithPostfix()
Gets the SqlTypes along with their column name postfixes.The first postfix is always the empty string. The second one is "_2", third "_3" and so on. This is a tentackle convention for multi-column types such as BMoney.
- Returns:
- the sq; types and their postfixes
-
isMultiColumn
public boolean isMultiColumn()
True if this is a multicolumn type.- Returns:
- true if multicolumn
-
isScaleInSecondColumn
public boolean isScaleInSecondColumn()
Returns whether this is a numeric type with the scale stored in a second column.BMoney and Dmoney for example.
- Returns:
- true if scale in second column
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Enum<DataType>
-
toPrimitive
public DataType toPrimitive()
Converts to a Java primitive.- Returns:
- the primitive type, never null
-
toNonPrimitive
public DataType toNonPrimitive()
Converts a primitive to a Java class.- Returns:
- the non-primitive type, never null
-
parse
public java.lang.Object parse(java.lang.String str)
Parses a string and converts to the value of this type.Notice: the method doesn't use any locale, so the results are always the same regardless of the JVM's locale.
- Parameters:
str- the source string- Returns:
- the value
-
print
public java.lang.String print(java.lang.Object object)
Takes an object and converts it to a string that can in turn be parsed withparse(java.lang.String).- Parameters:
object- the object of this DataType- Returns:
- the printable string
-
-