Top Description Fields Constructors Methods
org.h2.value

public abstract Class Value

extends VersionedValue<Value>
implements HasSQL, Typed
Class Inheritance
All Implemented Interfaces
org.h2.value.Typed, org.h2.util.HasSQL
Known Direct Subclasses
org.h2.value.ValueBigDecimalBase, org.h2.value.ValueBigint, org.h2.value.ValueBoolean, org.h2.value.ValueBytesBase, org.h2.value.ValueCollectionBase, org.h2.value.ValueDate, org.h2.value.ValueDouble, org.h2.value.ValueEnumBase, org.h2.value.ValueInteger, org.h2.value.ValueLob, org.h2.value.ValueNull, org.h2.value.ValueReal, org.h2.value.ValueSmallint, org.h2.value.ValueStringBase, org.h2.value.ValueTime, org.h2.value.ValueTimestamp, org.h2.value.ValueTimestampTimeZone, org.h2.value.ValueTimeTimeZone, org.h2.value.ValueTinyint, org.h2.value.ValueUuid, org.h2.mvstore.db.SpatialKey, org.h2.result.SearchRow, org.h2.value.ValueInterval
Static Imports
org.h2.util.Bits.INT_VH_BE, .Bits.LONG_VH_BE

This is the base class for all value classes. It provides conversion and comparison methods.
Authors
Thomas Mueller, Noel Grandin, Nicolas Fortin, Atelier SIG, IRSTV FR CNRS 24888

Field Summary

Modifier and TypeField and Description
public static final int
ARRAY

The value type for ARRAY values.

public static final int
ASSIGN_TO

Cast a value to the specified type for assignment.

public static final int
BIGINT

The value type for BIGINT values.

public static final int
BINARY

The value type for BINARY values.

public static final int
BLOB

The value type for BINARY LARGE OBJECT values.

public static final int
BOOLEAN

The value type for BOOLEAN values.

public static final int
CAST_TO

Cast a value to the specified type.

public static final int
CHAR

The value type for CHARACTER values.

public static final int
CLOB

The value type for CHARACTER LARGE OBJECT values.

public static final int
CONVERT_TO

Convert a value to the specified type without taking scale and precision into account.

public static final int
DATE

The value type for DATE values.

public static final int
DECFLOAT

The value type for DECFLOAT values.

public static final int
DOUBLE

The value type for DOUBLE PRECISION values.

public static final Value[]
EMPTY_VALUES

Empty array of values.

public static final int
ENUM

The value type for ENUM values.

public static final int
GEOMETRY

The value type for string values with a fixed size.

pack-priv static final int
GROUP_BINARY_STRING

Group for binary string data types.

pack-priv static final int
GROUP_BOOLEAN

Group for BINARY data type.

pack-priv static final int
GROUP_CHARACTER_STRING

Group for character string data types.

pack-priv static final int
GROUP_COLLECTION

Group for collection data types (ARRAY, ROW).

pack-priv static final int
GROUP_DATETIME

Group for datetime data types.

pack-priv static final int
GROUP_INTERVAL_DT

Group for day-time interval data types.

pack-priv static final int
GROUP_INTERVAL_YM

Group for year-month interval data types.

pack-priv static final int
GROUP_NULL

Group for untyped NULL data type.

pack-priv static final int
GROUP_NUMERIC

Group for numeric data types.

pack-priv static final int
GROUP_OTHER

Group for other data types (JAVA_OBJECT, UUID, GEOMETRY, ENUM, JSON).

pack-priv static final byte[]
public static final int
INTEGER

The value type for INTEGER values.

public static final int
INTERVAL_DAY

The value type for INTERVAL DAY values.

public static final int
INTERVAL_DAY_TO_HOUR

The value type for INTERVAL DAY TO HOUR values.

public static final int
INTERVAL_DAY_TO_MINUTE

The value type for INTERVAL DAY TO MINUTE values.

public static final int
INTERVAL_DAY_TO_SECOND

The value type for INTERVAL DAY TO SECOND values.

public static final int
INTERVAL_HOUR

The value type for INTERVAL HOUR values.

public static final int
INTERVAL_HOUR_TO_MINUTE

The value type for INTERVAL HOUR TO MINUTE values.

public static final int
INTERVAL_HOUR_TO_SECOND

The value type for INTERVAL HOUR TO SECOND values.

public static final int
INTERVAL_MINUTE

The value type for INTERVAL MINUTE values.

public static final int
INTERVAL_MINUTE_TO_SECOND

The value type for INTERVAL MINUTE TO SECOND values.

public static final int
INTERVAL_MONTH

The value type for INTERVAL MONTH values.

public static final int
INTERVAL_SECOND

The value type for INTERVAL SECOND values.

public static final int
INTERVAL_YEAR

The value type for INTERVAL YEAR values.

public static final int
INTERVAL_YEAR_TO_MONTH

The value type for INTERVAL YEAR TO MONTH values.

public static final int
JAVA_OBJECT

The value type for JAVA_OBJECT values.

public static final int
JSON

The value type for JSON values.

public static final BigDecimal
MAX_LONG_DECIMAL

The largest BIGINT value, as a BigDecimal.

public static final BigDecimal
MIN_LONG_DECIMAL

The smallest BIGINT value, as a BigDecimal.

private static final String[]
public static final int
NULL

The value type for NULL.

public static final int
NUMERIC

The value type for NUMERIC values.

public static final int
REAL

The value type for REAL values.

public static final int
ROW

The value type for ROW values.

public static final int
SMALLINT

The value type for SMALLINT values.

private static SoftReference<Value[]>
public static final int
TIME

The value type for TIME values.

public static final int
TIME_TZ

The value type for TIME WITH TIME ZONE values.

public static final int
TIMESTAMP

The value type for TIMESTAMP values.

public static final int
TIMESTAMP_TZ

The value type for TIMESTAMP WITH TIME ZONE values.

public static final int
TINYINT

The value type for TINYINT values.

public static final int
TYPE_COUNT

The number of value types.

public static final int
UNKNOWN

The data type is unknown at this time.

public static final int
UUID

The value type for UUID values.

public static final int
VARBINARY

The value type for BINARY VARYING values.

public static final int
VARCHAR

The value type for CHARACTER VARYING values.

public static final int
VARCHAR_IGNORECASE

The value type for VARCHAR_IGNORECASE values.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Value

Returns:

the result
add
(Value
the value to add
v
)

Add a value and return the result.

pack-priv static Value

Returns:

the value in the cache or the value passed
cache
(Value
the value to look for
v
)

Check if a value is in the cache that is equal to this value.

public final Value

Returns:

the converted value
castTo
(TypeInfo
the type of the returned value
targetType
,
CastDataProvider
the cast information provider
provider
)

Cast a value to the specified type.

public long

Returns:

length of this value in characters
charLength
()

Returns length of this value in characters.

public static void
clearCache()

Clear the value cache.

private static int
compareNumeric(Value l, Value r, int leftType, int rightType, int dataType)

public final int

Returns:

0 if both values are equal, -1 if this value is smaller, and 1 otherwise
compareTo
(Value
the other value
v
,
CastDataProvider
the cast information provider
provider
,
CompareMode
the compare mode
compareMode
)

Compare this value against another value using the specified compare mode.

private static int
public abstract int

Returns:

0 if both values are equal, -1 if the other value is smaller, and 1 otherwise
compareTypeSafe
(Value
the other value
v
,
CompareMode
the compare mode
mode
,
CastDataProvider
the cast information provider
provider
)

Compare this value against another value given that the values are of the same data type.

public int

Returns:

0 if both values are equal, -1 if this value is smaller, 1 if other value is larger, Integer#MIN_VALUE if order is not defined due to NULL comparison
compareWithNull
(Value
the other value
v
,
boolean
perform only check for equality
forEquality
,
CastDataProvider
the cast information provider
provider
,
CompareMode
the compare mode
compareMode
)

Compare this value against another value using the specified compare mode.

public boolean

Returns:

true if this value is NULL or contains NULL value
containsNull
()

Returns true if this value is NULL or contains NULL value.

public final Value

Returns:

the converted value
convertForAssignTo
(TypeInfo
the type of the returned value
targetType
,
CastDataProvider
the cast information provider
provider
,
Object
the column, used to improve the error message if conversion fails
column
)

Cast a value to the specified type for assignment.

public final Value

Returns:

the converted value
convertTo
(int
the type of the returned value
targetType
)

Convert a value to the specified type without taking scale and precision into account.

public final Value

Returns:

the converted value
convertTo
(TypeInfo
the type of the returned value
targetType
)

Convert a value to the specified type without taking scale and precision into account.

public final Value

Returns:

the converted value
convertTo
(int
the type of the returned value
targetType
,
CastDataProvider
the cast information provider
provider
)

Convert a value to the specified type without taking scale and precision into account.

public final Value

Returns:

the converted value
convertTo
(TypeInfo
the type of the returned value
targetType
,
CastDataProvider
the cast information provider
provider
)

Convert a value to the specified type without taking scale and precision into account.

public final Value

Returns:

the converted value
convertTo
(TypeInfo
the type of the returned value
targetType
,
CastDataProvider
the cast information provider
provider
,
Object
the column, used to improve the error message if conversion fails
column
)

Convert a value to the specified type without taking scale and precision into account.

private Value

Returns:

the converted value
convertTo
(TypeInfo
the type of the returned value
targetType
,
CastDataProvider
the cast information provider
provider
,
int
conversion mode
conversionMode
,
Object
the column (if any), used to improve the error message if conversion fails
column
)

Convert a value to the specified type.

public final ValueArray

Returns:

a row value
convertToAnyArray
(CastDataProvider
the cast information provider
provider
)

Convert this value to any ARRAY data type.

public final ValueJson

Returns:

a JSON value
convertToAnyJson
()

Convert this value to JSON data type.

public final ValueRow

Returns:

a row value
convertToAnyRow
()

Convert this value to any ROW data type.

private ValueArray
convertToArray(TypeInfo targetType, CastDataProvider provider, int conversionMode, Object column)

public final ValueBigint

Returns:

the BIGINT value
convertToBigint
(Object
the column, used for to improve the error message if conversion fails
column
)

Converts this value to a BIGINT value.

private ValueBinary
convertToBinary(TypeInfo targetType, int conversionMode, Object column)

private ValueBlob
convertToBlob(TypeInfo targetType, int conversionMode, Object column)

public final ValueBoolean

Returns:

the BOOLEAN value
convertToBoolean
()

Converts this value to a BOOLEAN value.

private static byte
convertToByte(long x, Object column)

public ValueChar

Returns:

a CHAR value.
convertToChar
()

Converts this value to a CHAR value.

private ValueChar
convertToChar(TypeInfo targetType, CastDataProvider provider, int conversionMode, Object column)

private ValueClob
convertToClob(TypeInfo targetType, int conversionMode, Object column)

public final ValueDate

Returns:

the DATE value
convertToDate
(CastDataProvider
the cast information provider
provider
)

Converts this value to a DATE value.

private ValueDecfloat
convertToDecfloat(TypeInfo targetType, int conversionMode)

public final ValueDouble

Returns:

the DOUBLE value
convertToDouble
()

Converts this value to a DOUBLE value.

public final ValueEnum

Returns:

the ENUM value
convertToEnum
(ExtTypeInfoEnum
the extended data type information
extTypeInfo
,
CastDataProvider
the cast information provider
provider
)

Converts this value to an ENUM value.

public final ValueGeometry

Returns:

the GEOMETRY value
convertToGeometry
(ExtTypeInfoGeometry
the extended data type information, or null
extTypeInfo
)

Converts this value to a GEOMETRY value.

public final ValueInteger

Returns:

the INT value
convertToInt
(Object
the column, used for to improve the error message if conversion fails
column
)

Converts this value to a INT value.

public static int

Returns:

x
convertToInt
(long
integer value.
x
,
Object
Column info.
column
)

Convert to integer, throwing exception if out of range.

private ValueInterval
convertToIntervalDayTime(TypeInfo targetType, int conversionMode, Object column)

private ValueInterval
convertToIntervalDayTime(int targetType, Object column)

private ValueInterval
convertToIntervalDayTime(BigDecimal bigDecimal, int targetType)

private ValueInterval
convertToIntervalYearMonth(TypeInfo targetType, int conversionMode, Object column)

private ValueInterval
convertToIntervalYearMonth(int targetType, Object column)

public final ValueJavaObject

Returns:

the JAVA_OBJECT value
convertToJavaObject
(TypeInfo
the type of the returned value
targetType
,
int
conversion mode
conversionMode
,
Object
the column (if any), used to improve the error message if conversion fails
column
)

Converts this value to a JAVA_OBJECT value.

public ValueJson

Returns:

the JSON value
convertToJson
(TypeInfo
the type of the returned value
targetType
,
int
conversion mode
conversionMode
,
Object
the column (if any), used to improve the error message if conversion fails
column
)

Converts this value to a JSON value.

private static long
convertToLong(double x, Object column)

public static long

Returns:

x
convertToLong
(BigDecimal
long value.
x
,
Object
Column info.
column
)

Convert to long, throwing exception if out of range.

private ValueNumeric
convertToNumeric(TypeInfo targetType, CastDataProvider provider, int conversionMode, Object column)

public final ValueReal

Returns:

the REAL value
convertToReal
()

Converts this value to a REAL value.

private Value
convertToRow(TypeInfo targetType, CastDataProvider provider, int conversionMode, Object column)

private static short
convertToShort(long x, Object column)

public final ValueSmallint

Returns:

the SMALLINT value
convertToSmallint
(Object
the column, used for to improve the error message if conversion fails
column
)

Converts this value to a SMALLINT value.

private ValueTime
convertToTime(TypeInfo targetType, CastDataProvider provider, int conversionMode)

private ValueTimestamp
convertToTimestamp(TypeInfo targetType, CastDataProvider provider, int conversionMode)

private ValueTimestampTimeZone
convertToTimestampTimeZone(TypeInfo targetType, CastDataProvider provider, int conversionMode)

private ValueTimeTimeZone
convertToTimeTimeZone(TypeInfo targetType, CastDataProvider provider, int conversionMode)

public final ValueTinyint

Returns:

the TINYINT value
convertToTinyint
(Object
the column, used for to improve the error message if conversion fails
column
)

Converts this value to a TINYINT value.

public final ValueUuid

Returns:

the UUID value
convertToUuid
()

Converts this value to a UUID value.

private ValueVarbinary
convertToVarbinary(TypeInfo targetType, int conversionMode, Object column)

private Value
convertToVarchar(TypeInfo targetType, CastDataProvider provider, int conversionMode, Object column)

private Value
convertToVarcharIgnoreCase(TypeInfo targetType, int conversionMode, Object column)

public Value

Returns:

the result
divide
(Value
the divisor
v
,
TypeInfo
the type of quotient (used only to read precision and scale when applicable)
quotientType
)

Divide by a value and return the result.

public abstract boolean

Returns:

true if they are equal
equals
(Object
the other value
other
)

Overrides java.lang.Object.equals.

Check if the two values have the same hash code.

public BigDecimal
public boolean

Returns:

value
getBoolean
()

Returns this value as a Java boolean value.

public byte

Returns:

value
getByte
()

Returns this value as a Java byte value.

public byte[]
public byte[]
pack-priv final DbException

Returns:

instance of the DbException.
getDataConversionError
(int
Target data type.
targetType
)

Creates new instance of the DbException for data conversion error.

pack-priv final DbException

Returns:

instance of the DbException.
getDataConversionError
(TypeInfo
target data type.
targetType
)

Creates new instance of the DbException for data conversion error.

private static DbException
public double

Returns:

value
getDouble
()

Returns this value as a Java double value.

public float

Returns:

value
getFloat
()

Returns this value as a Java float value.

private static int
getHigherDateTime(int t1, int t2, int g2)

private static int
getHigherIntervalDayTime(int t1, int t2, int g2)

private static int
getHigherIntervalYearMonth(int t1, int t2, int g2)

private static int
getHigherNumeric(int t1, int t2, int g2)

public static int

Returns:

the higher value type of the two
getHigherOrder
(int
the first value type
t1
,
int
the second value type
t2
)

Get the higher value order type of two value types.

pack-priv static int
getHigherOrderKnown(int t1, int t2)

private static int
getHigherOrderNonNull(int t1, int t2)

private static int
getHigherOther(int t1, int t2, int g2)

public InputStream
public InputStream

Returns:

the new input stream
getInputStream
(long
the offset (1 means no offset)
oneBasedOffset
,
long
the requested length
length
)

Get the input stream

public int

Returns:

value
getInt
()

Returns this value as a Java int value.

private long
public long

Returns:

value
getLong
()

Returns this value as a Java long value.

public int

Returns:

the memory used in bytes
getMemory
()

Get the memory used by this object.

private static DbException
public Reader
public Reader

Returns:

the new reader
getReader
(long
the offset (1 means no offset)
oneBasedOffset
,
long
the requested length
length
)

Get the reader

public short

Returns:

value
getShort
()

Returns this value as a Java short value.

public int
public abstract String

Returns:

the string
getString
()

Get the value as a string.

public abstract TypeInfo
getType()

Redeclares org.h2.value.Typed.getType.

Returns the data type.

public static String

Returns:

the name
getTypeName
(int
the value type
valueType
)

Returns name of the specified data type.

protected final DbException

Returns:

the exception
getUnsupportedExceptionForOperation
(String
the operation
op
)

Create an exception meaning the specified operation is not supported for this data type.

pack-priv final DbException
public abstract int

Returns:

the value type
getValueType
()

Get the value type.

public Value

Returns:

this value, the specified value, or null
getValueWithFirstNull
(Value
a value of the same data type as this value, must be neither equal to nor smaller than nor greater than this value
v
)

Scans this and specified values until a first NULL occurrence and returns a value where NULL appears earlier, or null if these two values have first NULL on the same position.

pack-priv Value
public abstract int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public final boolean

Returns:

true if it is. For BOOLEAN values returns true for FALSE and false for TRUE and UNKNOWN (NULL).
isFalse
()

Returns whether this value IS FALSE.

public final boolean

Returns:

true if it is. For BOOLEAN values returns true for TRUE and false for FALSE and UNKNOWN (NULL).
isTrue
()

Returns whether this value IS TRUE.

public Value

Returns:

the result
modulus
(Value
the value to take the modulus with
v
)

Take the modulus with a value and return the result.

public Value

Returns:

the result
multiply
(Value
the value to multiply with
v
)

Multiply with a value and return the result.

public Value

Returns:

the negative
negate
()

Return -value if this value support arithmetic operations.

public long

Returns:

length of this value in bytes
octetLength
()

Returns length of this value in bytes.

pack-priv static void
rangeCheck(long
the offset (0 meaning no offset)
zeroBasedOffset
,
long
the length of the target
length
,
long
the length of the source
dataSize
)

Check the range of the parameters.

public Value

Returns:

the result
subtract
(Value
the value to subtract
v
)

Subtract a value and return the result.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.h2.value.VersionedValue:
getCommittedValuegetCurrentValuegetOperationIdisCommitted