Enum Constant and Description |
---|
BOOLEAN
Boolean type.
|
DATE
The parameter is a date value.
|
DOUBLE
Double type.
|
FLOAT
Float type.
|
INT
Integer type.
|
LONG
Long integer type.
|
STRING
String type where maximum length allowed is 255 characters.
|
TEXT
Text blob type.
|
TIMESTAMP
The parameter is a date+time value.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
canEnumerate |
private java.lang.String |
displayValue |
private boolean |
isNumerical |
private boolean |
isTemporal |
private static java.util.Map<java.lang.String,Type> |
stringMapping |
private java.lang.String |
stringValue |
private java.lang.String |
tableName |
private TypeWrapper<?> |
typeWrapper |
private int |
value |
private java.lang.Class<?> |
valueClass |
private static java.util.Map<java.lang.Integer,Type> |
valueMapping |
Modifier and Type | Method and Description |
---|---|
boolean |
canEnumerate()
If it makes sense to use values of this type as an enumeration
to choose from.
|
java.lang.Number |
convertNumber(java.lang.Number num)
Convert a number to the appropriate class.
|
static Type |
fromHibernateType(Type hibernateType)
Try to find a matching Type instance given a Hibernate Type object.
|
static Type |
fromValue(int value)
Get the
Type object when you know the integer code. |
static Type |
fromValue(java.lang.String value)
Get the
Type object when you know the string value. |
int |
getSQLType()
Get the type of this parameter as specified by the
java.sql.Types class. |
java.lang.String |
getStringValue()
Get the string value representation of this type.
|
java.lang.String |
getTableName()
Get the name of the database table, parameter and annotation
values of this value type are stored in.
|
TypeWrapper<?> |
getTypeWrapper()
Get a wrapper for accessing underlying type information from Hibernate.
|
int |
getValue()
Get the integer value that is used when storing a type in the database.
|
java.lang.Class<?> |
getValueClass()
Get the class of objects that can be used as values for this type.
|
boolean |
isCorrectType(java.lang.Object value)
Check if the value is an object of the correct type.
|
boolean |
isNumerical()
If the values of this type are numerical values.
|
boolean |
isTemporal()
If the values of this type are date/time related.
|
(package private) abstract ParameterValueData<?> |
newParameterValueData()
Create a new
ParameterValueData subclass which is used to
store values of this value type in the database. |
abstract java.lang.Object |
parseString(java.lang.String value)
Parse a string and return a value of the correct type.
|
java.lang.Object |
parseString(java.lang.String value,
java.text.NumberFormat numberFormat,
boolean nullIfException)
Parse a string and return a value of the correct type using a specific
number format for numerical values, optionally ignoring unparsable numbers.
|
java.lang.Object[] |
parseStrings(java.lang.String[] values)
Parse an array of strings and try to convert them to values
of the correct object type.
|
abstract java.io.Serializable |
readValue(java.io.ObjectInputStream in)
Read a value of this type to the input stream.
|
abstract int |
sizeOf(java.lang.Object value)
Get the size in bytes an object of this type requires when
stored in the database.
|
java.lang.String |
toString() |
void |
validate(java.util.List<?> values)
Check if a list of values contain only objects of the correct type.
|
void |
validate(java.lang.Object value)
Check if an object is a value of the correct type.
|
static Type |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static Type[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
abstract void |
writeValue(java.io.Serializable value,
java.io.ObjectOutputStream out)
Write a value of this type to the output stream.
|
public static final Type INT
public static final Type LONG
public static final Type FLOAT
public static final Type DOUBLE
public static final Type STRING
TEXT
public static final Type BOOLEAN
public static final Type DATE
public static final Type TIMESTAMP
private static final java.util.Map<java.lang.Integer,Type> valueMapping
private static final java.util.Map<java.lang.String,Type> stringMapping
private final TypeWrapper<?> typeWrapper
private final int value
private final java.lang.Class<?> valueClass
private final java.lang.String tableName
private final java.lang.String stringValue
private final java.lang.String displayValue
private final boolean canEnumerate
private final boolean isNumerical
private final boolean isTemporal
public static Type[] values()
for (Type c : Type.values()) System.out.println(c);
public static Type valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic java.lang.String toString()
toString
in class java.lang.Enum<Type>
public TypeWrapper<?> getTypeWrapper()
public int getValue()
public java.lang.Class<?> getValueClass()
isCorrectType(Object)
public java.lang.String getStringValue()
public int getSQLType()
java.sql.Types
class.public java.lang.String getTableName()
public boolean canEnumerate()
BOOLEAN
and TEXT
type can't be enumerated.public boolean isNumerical()
public boolean isTemporal()
public void validate(java.lang.Object value) throws InvalidDataException
value
- Value object to be checked.InvalidDataException
- If the value isn't of the correct typepublic void validate(java.util.List<?> values) throws InvalidDataException
values
- List of objects to be checked.InvalidDataException
- If the list contains one or more nulls or
values of incorrect object typepublic boolean isCorrectType(java.lang.Object value)
value
- Value object to be checked.abstract ParameterValueData<?> newParameterValueData()
ParameterValueData
subclass which is used to
store values of this value type in the database.public abstract int sizeOf(java.lang.Object value)
value
- The value to get the size ofpublic abstract void writeValue(java.io.Serializable value, java.io.ObjectOutputStream out) throws java.io.IOException
value
- A value which must be of the correct type (not checked)out
- Stream to write tojava.io.IOException
public abstract java.io.Serializable readValue(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
in
- Stream to read fromjava.io.IOException
java.lang.ClassNotFoundException
public java.lang.Number convertNumber(java.lang.Number num)
num
- The number to convert.public abstract java.lang.Object parseString(java.lang.String value) throws InvalidDataException
value
- The string to get the type object from.InvalidDataException
- If the argument is corrupt.public java.lang.Object parseString(java.lang.String value, java.text.NumberFormat numberFormat, boolean nullIfException)
value
- The string value to parsenumberFormat
- The number format, or null to use parseString(String)
nullIfException
- TRUE to return null for unparsable numeric values, or
FALSE to throw an exceptionjava.lang.NumberFormatException
- If the type is numerical and the string can't be
parsed as a number and the nullIfException parameter is falsepublic java.lang.Object[] parseStrings(java.lang.String[] values) throws InvalidDataException
values
- An array of values to parse through.InvalidDataException
- If at least one of the strings could not
be parsed to the correct typepublic static Type fromValue(int value)
Type
object when you know the integer code.value
- The integer code to get the Type object for.public static Type fromValue(java.lang.String value)
Type
object when you know the string value.value
- The string value to get the Type object for.