Value

This is the base class for all value classes. It provides conversion and comparison methods.

Methods
static Value cache(Value v)
Check if a value is in the cache that is equal to this value.
static Value cache(Value v)
Check if a value is in the cache that is equal to this value. If yes, this value should be used to save memory. If the value is not in the cache yet, it is added.
Parameters:
v - the value to look for
Returns:
the value in the cache or the value passed
static void clearCache()
Clear the value cache.
static void clearCache()
Clear the value cache. Used for testing.
static int getHigherOrder(int t1, int t2)
Get the higher value order type of two value types.
static int getHigherOrder(int t1, int t2)
Get the higher value order type of two value types. If values need to be converted to match the other operands value type, the value with the lower order is converted to the value with the higher order.
Parameters:
t1 - the first value type
t2 - the second value type
Returns:
the higher value type of the two
static int getOrder(int type)
Get the order of this value type.
static int getOrder(int type)
Get the order of this value type.
Parameters:
type - the value type
Returns:
the order number
static void rangeCheck(long zeroBasedOffset, long length, long dataSize)
Check the range of the parameters.
static void rangeCheck(long zeroBasedOffset, long length, long dataSize)
Check the range of the parameters.
Parameters:
zeroBasedOffset - the offset (0 meaning no offset)
length - the length of the target
dataSize - the length of the source
Value add(Value v)
Add a value and return the result.
Value add(Value v)
Add a value and return the result.
Parameters:
v - the value to add
Returns:
the result
boolean checkPrecision(long precision)
Check if the precision is smaller or equal than the given precision.
boolean checkPrecision(long precision)
Check if the precision is smaller or equal than the given precision.
Parameters:
precision - the maximum precision
Returns:
true if the precision of this value is smaller or equal to the given precision
int compareSecure(Value v, CompareMode mode)
Compare the value with another value of the same type.
int compareSecure(Value v, CompareMode mode)
Compare the value with another value of the same type.
Parameters:
v - the other value
mode - the compare mode
Returns:
0 if both values are equal, -1 if the other value is smaller, and 1 otherwise
int compareTo(Value v, CompareMode mode)
Compare this value against another value using the specified compare mode.
int compareTo(Value v, CompareMode mode)
Compare this value against another value using the specified compare mode.
Parameters:
v - the other value
mode - the compare mode
Returns:
0 if both values are equal, -1 if the other value is smaller, and 1 otherwise
int compareTypeSafe(Value v, CompareMode mode)
Compare this value against another value given that the values are of the same data type.
int compareTypeSafe(Value v, CompareMode mode)
Compare this value against another value given that the values are of the same data type.
Parameters:
v - the other value
mode - the compare mode
Returns:
0 if both values are equal, -1 if the other value is smaller, and 1 otherwise
Value convertPrecision(long precision, boolean force)
Convert the precision to the requested value.
Value convertPrecision(long precision, boolean force)
Convert the precision to the requested value. The precision of the returned value may be somewhat larger than requested, because values with a fixed precision are not truncated.
Parameters:
precision - the new precision
force - true if losing numeric precision is allowed
Returns:
the new value
Value convertScale(boolean onlyToSmallerScale, int targetScale)
Convert the scale.
Value convertScale(boolean onlyToSmallerScale, int targetScale)
Convert the scale.
Parameters:
onlyToSmallerScale - if the scale should not reduced
targetScale - the requested scale
Returns:
the value
Value convertTo(int targetType)
Compare a value to the specified type.
Value convertTo(int targetType)
Compare a value to the specified type.
Parameters:
targetType - the type of the returned value
Returns:
the converted value
Value convertTo(int targetType, int precision, Mode mode)
Compare a value to the specified type.
Value convertTo(int targetType, int precision, Mode mode)
Compare a value to the specified type.
Parameters:
targetType - the type of the returned value
precision - the precision of the column to convert this value to. The special constant -1 is used to indicate that the precision plays no role when converting the value
mode - the mode
Returns:
the converted value
Value convertTo(int targetType, int precision, Mode mode, Object column, String[] enumerators)
Compare a value to the specified type.
Value convertTo(int targetType, int precision, Mode mode, Object column, String[] enumerators)
Compare a value to the specified type.
Parameters:
targetType - the type of the returned value
precision - the precision of the column to convert this value to. The special constant -1 is used to indicate that the precision plays no role when converting the value
mode - the conversion mode
column - the column (if any), used for to improve the error message if conversion fails
enumerators - the ENUM datatype enumerators (if any), for dealing with ENUM conversions
Returns:
the converted value
Value convertToEnum(String[] enumerators)
Convert value to ENUM value
Value convertToEnum(String[] enumerators)
Convert value to ENUM value
Parameters:
enumerators - allowed values for the ENUM to which the value is converted
Returns:
value represented as ENUM
Value copy(DataHandler handler, int tableId)
Copy a large value, to be used in the given table.
Value copy(DataHandler handler, int tableId)
Copy a large value, to be used in the given table. For values that are kept fully in memory this method has no effect.
Parameters:
handler - the data handler
tableId - the table where this object is used
Returns:
the new value or itself
Value copyToResult()
Create an independent copy of this value if needed, that will be bound to a result.
Value copyToResult()
Create an independent copy of this value if needed, that will be bound to a result. If the original row is removed, this copy is still readable.
Returns:
the value (this for small objects)
Value copyToTemp()
Copy this value to a temporary file if necessary.
Value copyToTemp()
Copy this value to a temporary file if necessary.
Returns:
the new value
Value divide(Value v)
Divide by a value and return the result.
Value divide(Value v)
Divide by a value and return the result.
Parameters:
v - the value to divide by
Returns:
the result
boolean equals(Object other)
Check if the two values have the same hash code.
boolean equals(Object other)
Check if the two values have the same hash code. No data conversion is made; this method returns false if the other object is not of the same class. For some values, compareTo may return 0 even if equals return false. Example: ValueDecimal 0.0 and 0.00.
Parameters:
other - the other value
Returns:
true if they are equal
BigDecimal getBigDecimal()
BigDecimal getBigDecimal()
boolean getBoolean()
boolean getBoolean()
byte getByte()
byte getByte()
byte[] getBytes()
byte[] getBytes()
byte[] getBytesNoCopy()
byte[] getBytesNoCopy()
DataHandler getDataHandler()
Return the data handler for the values that support it (actually only Java objects).
DataHandler getDataHandler()
Return the data handler for the values that support it (actually only Java objects).
Returns:
the data handler
Date getDate()
Date getDate()
int getDisplaySize()
Get the display size in characters.
int getDisplaySize()
Get the display size in characters.
Returns:
the display size
double getDouble()
double getDouble()
float getFloat()
float getFloat()
InputStream getInputStream()
InputStream getInputStream()
InputStream getInputStream(long oneBasedOffset, long length)
Get the input stream
InputStream getInputStream(long oneBasedOffset, long length)
Get the input stream
Parameters:
oneBasedOffset - the offset (1 means no offset)
length - the requested length
Returns:
the new input stream
int getInt()
int getInt()
long getLong()
long getLong()
int getMemory()
Get the memory used by this object.
int getMemory()
Get the memory used by this object.
Returns:
the memory used in bytes
Object getObject()
Get the value as an object.
Object getObject()
Get the value as an object.
Returns:
the object
long getPrecision()
Get the precision.
long getPrecision()
Get the precision.
Returns:
the precision
Reader getReader()
Reader getReader()
Reader getReader(long oneBasedOffset, long length)
Get the reader
Reader getReader(long oneBasedOffset, long length)
Get the reader
Parameters:
oneBasedOffset - the offset (1 means no offset)
length - the requested length
Returns:
the new reader
ResultSet getResultSet()
ResultSet getResultSet()
String getSQL()
Get the SQL expression for this value.
String getSQL()
Get the SQL expression for this value.
Returns:
the SQL expression
int getScale()
int getScale()
short getShort()
short getShort()
int getSignum()
int getSignum()
byte[] getSmall()
Get the byte array.
byte[] getSmall()
Get the byte array.
Returns:
the byte array
String getString()
Get the value as a string.
String getString()
Get the value as a string.
Returns:
the string
int getTableId()
Get the table (only for LOB object).
int getTableId()
Get the table (only for LOB object).
Returns:
the table id
Time getTime()
Time getTime()
Timestamp getTimestamp()
Timestamp getTimestamp()
String getTraceSQL()
Get a medium size SQL expression for debugging or tracing.
String getTraceSQL()
Get a medium size SQL expression for debugging or tracing. If the precision is too large, only a subset of the value is returned.
Returns:
the SQL expression
int getType()
Get the value type.
int getType()
Get the value type.
Returns:
the type
int hashCode()
int hashCode()
boolean isLinkedToTable()
Check if this value is linked to a specific table.
boolean isLinkedToTable()
Check if this value is linked to a specific table. For values that are kept fully in memory, this method returns false.
Returns:
true if it is
Value modulus(Value v)
Take the modulus with a value and return the result.
Value modulus(Value v)
Take the modulus with a value and return the result.
Parameters:
v - the value to take the modulus with
Returns:
the result
Value multiply(Value v)
Multiply with a value and return the result.
Value multiply(Value v)
Multiply with a value and return the result.
Parameters:
v - the value to multiply with
Returns:
the result
Value negate()
Return -value if this value support arithmetic operations.
Value negate()
Return -value if this value support arithmetic operations.
Returns:
the negative
void remove()
Remove the underlying resource, if any.
void remove()
Remove the underlying resource, if any. For values that are kept fully in memory this method has no effect.
void set(PreparedStatement prep, int parameterIndex)
Set the value as a parameter in a prepared statement.
void set(PreparedStatement prep, int parameterIndex) throws SQLException
Set the value as a parameter in a prepared statement.
Parameters:
prep - the prepared statement
parameterIndex - the parameter index
Value subtract(Value v)
Subtract a value and return the result.
Value subtract(Value v)
Subtract a value and return the result.
Parameters:
v - the value to subtract
Returns:
the result
DbException throwUnsupportedExceptionForType(String op)
Throw the exception that the feature is not support for the given data type.
DbException throwUnsupportedExceptionForType(String op)
Throw the exception that the feature is not support for the given data type.
Parameters:
op - the operation
Returns:
never returns normally
Throws:
DbException - the exception
String toString()
String toString()

Fields
static int ARRAY = 17
static int BLOB = 15
static int BOOLEAN = 1
static int BYTE = 2
static int BYTES = 12
static int CLOB = 16
static int DATE = 10
static int DECIMAL = 6
static int DOUBLE = 7
static int ENUM = 25
static int FLOAT = 8
static int GEOMETRY = 22
static int INT = 4
static int JAVA_OBJECT = 19
static int LONG = 5
static int NULL = 0
static int RESULT_SET = 18
static int SHORT = 3
static int STRING = 13
static int STRING_FIXED = 21
static int STRING_IGNORECASE = 14
static int TIME = 9
static int TIMESTAMP = 11
static int TIMESTAMP_TZ = 24
static int TYPE_COUNT = 25
static int UNKNOWN = -1
static int UUID = 20

UNKNOWN = -1

The data type is unknown at this time.

NULL = 0

The value type for NULL.

BOOLEAN = 1

The value type for BOOLEAN values.

DATE = 10

The value type for DATE values.

TIMESTAMP = 11

The value type for TIMESTAMP values.

BYTES = 12

The value type for BYTES values.

STRING = 13

The value type for STRING values.

STRING_IGNORECASE = 14

The value type for case insensitive STRING values.

BLOB = 15

The value type for BLOB values.

CLOB = 16

The value type for CLOB values.

ARRAY = 17

The value type for ARRAY values.

RESULT_SET = 18

The value type for RESULT_SET values.

JAVA_OBJECT = 19

The value type for JAVA_OBJECT values.

BYTE = 2

The value type for BYTE values.

UUID = 20

The value type for UUID values.

STRING_FIXED = 21

The value type for string values with a fixed size.

GEOMETRY = 22

The value type for string values with a fixed size.

TIMESTAMP_TZ = 24

The value type for TIMESTAMP WITH TIME ZONE values.

ENUM = 25

The value type for ENUM values.

TYPE_COUNT = 25

The number of value types.

SHORT = 3

The value type for SHORT values.

INT = 4

The value type for INT values.

LONG = 5

The value type for LONG values.

DECIMAL = 6

The value type for DECIMAL values.

DOUBLE = 7

The value type for DOUBLE values.

FLOAT = 8

The value type for FLOAT values.

TIME = 9

The value type for TIME values.