Package org.h2.value
Class Value
- java.lang.Object
-
- org.h2.value.VersionedValue<Value>
-
- org.h2.value.Value
-
- Direct Known Subclasses:
SearchRow
,SpatialKey
,ValueBigDecimalBase
,ValueBigint
,ValueBoolean
,ValueBytesBase
,ValueCollectionBase
,ValueDate
,ValueDouble
,ValueEnumBase
,ValueInteger
,ValueInterval
,ValueLob
,ValueNull
,ValueReal
,ValueSmallint
,ValueStringBase
,ValueTime
,ValueTimestamp
,ValueTimestampTimeZone
,ValueTimeTimeZone
,ValueTinyint
,ValueUuid
public abstract class Value extends VersionedValue<Value> implements HasSQL, Typed
This is the base class for all value classes. It provides conversion and comparison methods.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ARRAY
The value type for ARRAY values.(package private) static int
ASSIGN_TO
Cast a value to the specified type for assignment.static int
BIGINT
The value type for BIGINT values.static int
BINARY
The value type for BINARY values.static int
BLOB
The value type for BINARY LARGE OBJECT values.static int
BOOLEAN
The value type for BOOLEAN values.(package private) static int
CAST_TO
Cast a value to the specified type.static int
CHAR
The value type for CHARACTER values.static int
CLOB
The value type for CHARACTER LARGE OBJECT values.(package private) static int
CONVERT_TO
Convert a value to the specified type without taking scale and precision into account.static int
DATE
The value type for DATE values.static int
DECFLOAT
The value type for DECFLOAT values.static int
DOUBLE
The value type for DOUBLE PRECISION values.static Value[]
EMPTY_VALUES
Empty array of values.static int
ENUM
The value type for ENUM values.static int
GEOMETRY
The value type for string values with a fixed size.(package private) static int
GROUP_BINARY_STRING
Group for binary string data types.(package private) static int
GROUP_BOOLEAN
Group for BINARY data type.(package private) static int
GROUP_CHARACTER_STRING
Group for character string data types.(package private) static int
GROUP_COLLECTION
Group for collection data types (ARRAY, ROW).(package private) static int
GROUP_DATETIME
Group for datetime data types.(package private) static int
GROUP_INTERVAL_DT
Group for day-time interval data types.(package private) static int
GROUP_INTERVAL_YM
Group for year-month interval data types.(package private) static int
GROUP_NULL
Group for untyped NULL data type.(package private) static int
GROUP_NUMERIC
Group for numeric data types.(package private) static int
GROUP_OTHER
Group for other data types (JAVA_OBJECT, UUID, GEOMETRY, ENUM, JSON).(package private) static byte[]
GROUPS
static int
INTEGER
The value type for INTEGER values.static int
INTERVAL_DAY
The value type forINTERVAL DAY
values.static int
INTERVAL_DAY_TO_HOUR
The value type forINTERVAL DAY TO HOUR
values.static int
INTERVAL_DAY_TO_MINUTE
The value type forINTERVAL DAY TO MINUTE
values.static int
INTERVAL_DAY_TO_SECOND
The value type forINTERVAL DAY TO SECOND
values.static int
INTERVAL_HOUR
The value type forINTERVAL HOUR
values.static int
INTERVAL_HOUR_TO_MINUTE
The value type forINTERVAL HOUR TO MINUTE
values.static int
INTERVAL_HOUR_TO_SECOND
The value type forINTERVAL HOUR TO SECOND
values.static int
INTERVAL_MINUTE
The value type forINTERVAL MINUTE
values.static int
INTERVAL_MINUTE_TO_SECOND
The value type forINTERVAL MINUTE TO SECOND
values.static int
INTERVAL_MONTH
The value type forINTERVAL MONTH
values.static int
INTERVAL_SECOND
The value type forINTERVAL SECOND
values.static int
INTERVAL_YEAR
The value type forINTERVAL YEAR
values.static int
INTERVAL_YEAR_TO_MONTH
The value type forINTERVAL YEAR TO MONTH
values.static int
JAVA_OBJECT
The value type for JAVA_OBJECT values.static int
JSON
The value type for JSON values.(package private) static java.math.BigDecimal
MAX_LONG_DECIMAL
static java.math.BigDecimal
MIN_LONG_DECIMAL
The smallest Long value, as a BigDecimal.private static java.lang.String[]
NAMES
static int
NULL
The value type for NULL.static int
NUMERIC
The value type for NUMERIC values.static int
REAL
The value type for REAL values.static int
ROW
The value type for ROW values.static int
SMALLINT
The value type for SMALLINT values.private static java.lang.ref.SoftReference<Value[]>
softCache
static int
TIME
The value type for TIME values.static int
TIME_TZ
The value type for TIME WITH TIME ZONE values.static int
TIMESTAMP
The value type for TIMESTAMP values.static int
TIMESTAMP_TZ
The value type for TIMESTAMP WITH TIME ZONE values.static int
TINYINT
The value type for TINYINT values.static int
TYPE_COUNT
The number of value types.static int
UNKNOWN
The data type is unknown at this time.static int
UUID
The value type for UUID values.static int
VARBINARY
The value type for BINARY VARYING values.static int
VARCHAR
The value type for CHARACTER VARYING values.static int
VARCHAR_IGNORECASE
The value type for VARCHAR_IGNORECASE values.-
Fields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS
-
-
Constructor Summary
Constructors Constructor Description Value()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Value
add(Value v)
Add a value and return the result.(package private) static Value
cache(Value v)
Check if a value is in the cache that is equal to this value.Value
castTo(TypeInfo targetType, CastDataProvider provider)
Cast a value to the specified type.long
charLength()
Returns length of this value in characters.static void
clearCache()
Clear the value cache.int
compareTo(Value v, CastDataProvider provider, CompareMode compareMode)
Compare this value against another value using the specified compare mode.private int
compareToNotNullable(Value v, CastDataProvider provider, CompareMode compareMode)
abstract int
compareTypeSafe(Value v, CompareMode mode, CastDataProvider provider)
Compare this value against another value given that the values are of the same data type.int
compareWithNull(Value v, boolean forEquality, CastDataProvider provider, CompareMode compareMode)
Compare this value against another value using the specified compare mode.boolean
containsNull()
Returns true if this value is NULL or contains NULL value.Value
convertForAssignTo(TypeInfo targetType, CastDataProvider provider, java.lang.Object column)
Cast a value to the specified type for assignment.Value
convertTo(int targetType)
Convert a value to the specified type without taking scale and precision into account.Value
convertTo(int targetType, CastDataProvider provider)
Convert a value to the specified type without taking scale and precision into account.Value
convertTo(TypeInfo targetType)
Convert a value to the specified type without taking scale and precision into account.Value
convertTo(TypeInfo targetType, CastDataProvider provider)
Convert a value to the specified type without taking scale and precision into account.private Value
convertTo(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
Convert a value to the specified type.Value
convertTo(TypeInfo targetType, CastDataProvider provider, java.lang.Object column)
Convert a value to the specified type without taking scale and precision into account.ValueArray
convertToAnyArray(CastDataProvider provider)
Convert this value to any ARRAY data type.ValueRow
convertToAnyRow()
Convert this value to any ROW data type.private ValueArray
convertToArray(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
ValueBigint
convertToBigint(java.lang.Object column)
Converts this value to a BIGINT value.private ValueBinary
convertToBinary(TypeInfo targetType, int conversionMode, java.lang.Object column)
private ValueBlob
convertToBlob(TypeInfo targetType, int conversionMode, java.lang.Object column)
ValueBoolean
convertToBoolean()
Converts this value to a BOOLEAN value.private static byte
convertToByte(long x, java.lang.Object column)
ValueChar
convertToChar()
Converts this value to a CHAR value.private ValueChar
convertToChar(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
private ValueClob
convertToClob(TypeInfo targetType, int conversionMode, java.lang.Object column)
ValueDate
convertToDate(CastDataProvider provider)
Converts this value to a DATE value.private ValueDecfloat
convertToDecfloat(TypeInfo targetType, int conversionMode)
ValueDouble
convertToDouble()
Converts this value to a DOUBLE value.ValueEnum
convertToEnum(ExtTypeInfoEnum extTypeInfo, CastDataProvider provider)
Converts this value to an ENUM value.ValueGeometry
convertToGeometry(ExtTypeInfoGeometry extTypeInfo)
Converts this value to a GEOMETRY value.static int
convertToInt(long x, java.lang.Object column)
Convert to integer, throwing exception if out of range.ValueInteger
convertToInt(java.lang.Object column)
Converts this value to a INT value.private ValueInterval
convertToIntervalDayTime(int targetType, java.lang.Object column)
private ValueInterval
convertToIntervalDayTime(java.math.BigDecimal bigDecimal, int targetType)
private ValueInterval
convertToIntervalDayTime(TypeInfo targetType, int conversionMode, java.lang.Object column)
private ValueInterval
convertToIntervalYearMonth(int targetType, java.lang.Object column)
private ValueInterval
convertToIntervalYearMonth(TypeInfo targetType, int conversionMode, java.lang.Object column)
ValueJavaObject
convertToJavaObject(TypeInfo targetType, int conversionMode, java.lang.Object column)
Converts this value to a JAVA_OBJECT value.private ValueJson
convertToJson(TypeInfo targetType, int conversionMode, java.lang.Object column)
private static long
convertToLong(double x, java.lang.Object column)
private static long
convertToLong(java.math.BigDecimal x, java.lang.Object column)
private ValueNumeric
convertToNumeric(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
ValueReal
convertToReal()
Converts this value to a REAL value.private Value
convertToRow(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
private static short
convertToShort(long x, java.lang.Object column)
ValueSmallint
convertToSmallint(java.lang.Object 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)
ValueTinyint
convertToTinyint(java.lang.Object column)
Converts this value to a TINYINT value.ValueUuid
convertToUuid()
Converts this value to a UUID value.private ValueVarbinary
convertToVarbinary(TypeInfo targetType, int conversionMode, java.lang.Object column)
private Value
convertToVarchar(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
private Value
convertToVarcharIgnoreCase(TypeInfo targetType, int conversionMode, java.lang.Object column)
Value
divide(Value v, TypeInfo quotientType)
Divide by a value and return the result.abstract boolean
equals(java.lang.Object other)
Check if the two values have the same hash code.java.math.BigDecimal
getBigDecimal()
boolean
getBoolean()
Returns this value as a Javaboolean
value.byte
getByte()
Returns this value as a Javabyte
value.byte[]
getBytes()
byte[]
getBytesNoCopy()
private static java.lang.String
getColumnName(java.lang.Object column)
(package private) DbException
getDataConversionError(int targetType)
Creates new instance of the DbException for data conversion error.(package private) DbException
getDataConversionError(TypeInfo targetType)
Creates new instance of the DbException for data conversion error.private static DbException
getDataTypeCombinationException(int t1, int t2)
double
getDouble()
Returns this value as a Javadouble
value.float
getFloat()
Returns this value as a Javafloat
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)
static int
getHigherOrder(int t1, int t2)
Get the higher value order type of two value types.(package private) static int
getHigherOrderKnown(int t1, int t2)
private static int
getHigherOther(int t1, int t2, int g2)
java.io.InputStream
getInputStream()
java.io.InputStream
getInputStream(long oneBasedOffset, long length)
Get the input streamint
getInt()
Returns this value as a Javaint
value.private long
getLocalTimeNanos(CastDataProvider provider)
long
getLong()
Returns this value as a Javalong
value.int
getMemory()
Get the memory used by this object.java.io.Reader
getReader()
java.io.Reader
getReader(long oneBasedOffset, long length)
Get the readershort
getShort()
Returns this value as a Javashort
value.int
getSignum()
abstract java.lang.String
getString()
Get the value as a string.abstract TypeInfo
getType()
Returns the data type.static java.lang.String
getTypeName(int valueType)
Returns name of the specified data type.protected DbException
getUnsupportedExceptionForOperation(java.lang.String op)
Create an exception meaning the specified operation is not supported for this data type.(package private) DbException
getValueTooLongException(TypeInfo targetType, java.lang.Object column)
abstract int
getValueType()
Get the value type.abstract int
hashCode()
boolean
isFalse()
Returns whether this valueIS FALSE
.boolean
isTrue()
Returns whether this valueIS TRUE
.Value
modulus(Value v)
Take the modulus with a value and return the result.Value
multiply(Value v)
Multiply with a value and return the result.Value
negate()
Return -value if this value support arithmetic operations.long
octetLength()
Returns length of this value in bytes.(package private) static void
rangeCheck(long zeroBasedOffset, long length, long dataSize)
Check the range of the parameters.Value
subtract(Value v)
Subtract a value and return the result.java.lang.String
toString()
-
Methods inherited from class org.h2.value.VersionedValue
getCommittedValue, getCurrentValue, getOperationId, isCommitted
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.h2.util.HasSQL
getSQL, getSQL, getTraceSQL
-
-
-
-
Field Detail
-
UNKNOWN
public static final int UNKNOWN
The data type is unknown at this time.- See Also:
- Constant Field Values
-
NULL
public static final int NULL
The value type for NULL.- See Also:
- Constant Field Values
-
CHAR
public static final int CHAR
The value type for CHARACTER values.- See Also:
- Constant Field Values
-
VARCHAR
public static final int VARCHAR
The value type for CHARACTER VARYING values.- See Also:
- Constant Field Values
-
CLOB
public static final int CLOB
The value type for CHARACTER LARGE OBJECT values.- See Also:
- Constant Field Values
-
VARCHAR_IGNORECASE
public static final int VARCHAR_IGNORECASE
The value type for VARCHAR_IGNORECASE values.- See Also:
- Constant Field Values
-
BINARY
public static final int BINARY
The value type for BINARY values.- See Also:
- Constant Field Values
-
VARBINARY
public static final int VARBINARY
The value type for BINARY VARYING values.- See Also:
- Constant Field Values
-
BLOB
public static final int BLOB
The value type for BINARY LARGE OBJECT values.- See Also:
- Constant Field Values
-
BOOLEAN
public static final int BOOLEAN
The value type for BOOLEAN values.- See Also:
- Constant Field Values
-
TINYINT
public static final int TINYINT
The value type for TINYINT values.- See Also:
- Constant Field Values
-
SMALLINT
public static final int SMALLINT
The value type for SMALLINT values.- See Also:
- Constant Field Values
-
INTEGER
public static final int INTEGER
The value type for INTEGER values.- See Also:
- Constant Field Values
-
BIGINT
public static final int BIGINT
The value type for BIGINT values.- See Also:
- Constant Field Values
-
NUMERIC
public static final int NUMERIC
The value type for NUMERIC values.- See Also:
- Constant Field Values
-
REAL
public static final int REAL
The value type for REAL values.- See Also:
- Constant Field Values
-
DOUBLE
public static final int DOUBLE
The value type for DOUBLE PRECISION values.- See Also:
- Constant Field Values
-
DECFLOAT
public static final int DECFLOAT
The value type for DECFLOAT values.- See Also:
- Constant Field Values
-
DATE
public static final int DATE
The value type for DATE values.- See Also:
- Constant Field Values
-
TIME
public static final int TIME
The value type for TIME values.- See Also:
- Constant Field Values
-
TIME_TZ
public static final int TIME_TZ
The value type for TIME WITH TIME ZONE values.- See Also:
- Constant Field Values
-
TIMESTAMP
public static final int TIMESTAMP
The value type for TIMESTAMP values.- See Also:
- Constant Field Values
-
TIMESTAMP_TZ
public static final int TIMESTAMP_TZ
The value type for TIMESTAMP WITH TIME ZONE values.- See Also:
- Constant Field Values
-
INTERVAL_YEAR
public static final int INTERVAL_YEAR
The value type forINTERVAL YEAR
values.- See Also:
- Constant Field Values
-
INTERVAL_MONTH
public static final int INTERVAL_MONTH
The value type forINTERVAL MONTH
values.- See Also:
- Constant Field Values
-
INTERVAL_DAY
public static final int INTERVAL_DAY
The value type forINTERVAL DAY
values.- See Also:
- Constant Field Values
-
INTERVAL_HOUR
public static final int INTERVAL_HOUR
The value type forINTERVAL HOUR
values.- See Also:
- Constant Field Values
-
INTERVAL_MINUTE
public static final int INTERVAL_MINUTE
The value type forINTERVAL MINUTE
values.- See Also:
- Constant Field Values
-
INTERVAL_SECOND
public static final int INTERVAL_SECOND
The value type forINTERVAL SECOND
values.- See Also:
- Constant Field Values
-
INTERVAL_YEAR_TO_MONTH
public static final int INTERVAL_YEAR_TO_MONTH
The value type forINTERVAL YEAR TO MONTH
values.- See Also:
- Constant Field Values
-
INTERVAL_DAY_TO_HOUR
public static final int INTERVAL_DAY_TO_HOUR
The value type forINTERVAL DAY TO HOUR
values.- See Also:
- Constant Field Values
-
INTERVAL_DAY_TO_MINUTE
public static final int INTERVAL_DAY_TO_MINUTE
The value type forINTERVAL DAY TO MINUTE
values.- See Also:
- Constant Field Values
-
INTERVAL_DAY_TO_SECOND
public static final int INTERVAL_DAY_TO_SECOND
The value type forINTERVAL DAY TO SECOND
values.- See Also:
- Constant Field Values
-
INTERVAL_HOUR_TO_MINUTE
public static final int INTERVAL_HOUR_TO_MINUTE
The value type forINTERVAL HOUR TO MINUTE
values.- See Also:
- Constant Field Values
-
INTERVAL_HOUR_TO_SECOND
public static final int INTERVAL_HOUR_TO_SECOND
The value type forINTERVAL HOUR TO SECOND
values.- See Also:
- Constant Field Values
-
INTERVAL_MINUTE_TO_SECOND
public static final int INTERVAL_MINUTE_TO_SECOND
The value type forINTERVAL MINUTE TO SECOND
values.- See Also:
- Constant Field Values
-
JAVA_OBJECT
public static final int JAVA_OBJECT
The value type for JAVA_OBJECT values.- See Also:
- Constant Field Values
-
ENUM
public static final int ENUM
The value type for ENUM values.- See Also:
- Constant Field Values
-
GEOMETRY
public static final int GEOMETRY
The value type for string values with a fixed size.- See Also:
- Constant Field Values
-
JSON
public static final int JSON
The value type for JSON values.- See Also:
- Constant Field Values
-
UUID
public static final int UUID
The value type for UUID values.- See Also:
- Constant Field Values
-
ARRAY
public static final int ARRAY
The value type for ARRAY values.- See Also:
- Constant Field Values
-
ROW
public static final int ROW
The value type for ROW values.- See Also:
- Constant Field Values
-
TYPE_COUNT
public static final int TYPE_COUNT
The number of value types.- See Also:
- Constant Field Values
-
GROUP_NULL
static final int GROUP_NULL
Group for untyped NULL data type.- See Also:
- Constant Field Values
-
GROUP_CHARACTER_STRING
static final int GROUP_CHARACTER_STRING
Group for character string data types.- See Also:
- Constant Field Values
-
GROUP_BINARY_STRING
static final int GROUP_BINARY_STRING
Group for binary string data types.- See Also:
- Constant Field Values
-
GROUP_BOOLEAN
static final int GROUP_BOOLEAN
Group for BINARY data type.- See Also:
- Constant Field Values
-
GROUP_NUMERIC
static final int GROUP_NUMERIC
Group for numeric data types.- See Also:
- Constant Field Values
-
GROUP_DATETIME
static final int GROUP_DATETIME
Group for datetime data types.- See Also:
- Constant Field Values
-
GROUP_INTERVAL_YM
static final int GROUP_INTERVAL_YM
Group for year-month interval data types.- See Also:
- Constant Field Values
-
GROUP_INTERVAL_DT
static final int GROUP_INTERVAL_DT
Group for day-time interval data types.- See Also:
- Constant Field Values
-
GROUP_OTHER
static final int GROUP_OTHER
Group for other data types (JAVA_OBJECT, UUID, GEOMETRY, ENUM, JSON).- See Also:
- Constant Field Values
-
GROUP_COLLECTION
static final int GROUP_COLLECTION
Group for collection data types (ARRAY, ROW).- See Also:
- Constant Field Values
-
GROUPS
static final byte[] GROUPS
-
NAMES
private static final java.lang.String[] NAMES
-
EMPTY_VALUES
public static final Value[] EMPTY_VALUES
Empty array of values.
-
softCache
private static java.lang.ref.SoftReference<Value[]> softCache
-
MAX_LONG_DECIMAL
static final java.math.BigDecimal MAX_LONG_DECIMAL
-
MIN_LONG_DECIMAL
public static final java.math.BigDecimal MIN_LONG_DECIMAL
The smallest Long value, as a BigDecimal.
-
CONVERT_TO
static final int CONVERT_TO
Convert a value to the specified type without taking scale and precision into account.- See Also:
- Constant Field Values
-
CAST_TO
static final int CAST_TO
Cast a value to the specified type. The scale is set if applicable. The value is truncated to a required precision.- See Also:
- Constant Field Values
-
ASSIGN_TO
static final int ASSIGN_TO
Cast a value to the specified type for assignment. The scale is set if applicable. If precision is too large an exception is thrown.- See Also:
- Constant Field Values
-
-
Method Detail
-
getTypeName
public static java.lang.String getTypeName(int valueType)
Returns name of the specified data type.- Parameters:
valueType
- the value type- Returns:
- the name
-
rangeCheck
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 targetdataSize
- the length of the source
-
getType
public abstract TypeInfo getType()
Description copied from interface:Typed
Returns the data type.
-
getValueType
public abstract int getValueType()
Get the value type.- Returns:
- the value type
-
getMemory
public int getMemory()
Get the memory used by this object.- Returns:
- the memory used in bytes
-
hashCode
public abstract int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public abstract boolean equals(java.lang.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.- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- the other value- Returns:
- true if they are equal
-
getHigherOrder
public 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 typet2
- the second value type- Returns:
- the higher value type of the two
-
getHigherOrderKnown
static int getHigherOrderKnown(int t1, int t2)
-
getHigherNumeric
private static int getHigherNumeric(int t1, int t2, int g2)
-
getHigherDateTime
private static int getHigherDateTime(int t1, int t2, int g2)
-
getHigherIntervalYearMonth
private static int getHigherIntervalYearMonth(int t1, int t2, int g2)
-
getHigherIntervalDayTime
private static int getHigherIntervalDayTime(int t1, int t2, int g2)
-
getHigherOther
private static int getHigherOther(int t1, int t2, int g2)
-
getDataTypeCombinationException
private static DbException getDataTypeCombinationException(int t1, int t2)
-
cache
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
-
clearCache
public static void clearCache()
Clear the value cache. Used for testing.
-
getString
public abstract java.lang.String getString()
Get the value as a string.- Returns:
- the string
-
getReader
public java.io.Reader getReader()
-
getReader
public java.io.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
-
getBytes
public byte[] getBytes()
-
getBytesNoCopy
public byte[] getBytesNoCopy()
-
getInputStream
public java.io.InputStream getInputStream()
-
getInputStream
public java.io.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
-
getBoolean
public boolean getBoolean()
Returns this value as a Javaboolean
value.- Returns:
- value
- Throws:
DbException
- if this value isNULL
or cannot be casted toBOOLEAN
- See Also:
isTrue()
,isFalse()
-
getByte
public byte getByte()
Returns this value as a Javabyte
value.- Returns:
- value
- Throws:
DbException
- if this value isNULL
or cannot be casted toTINYINT
-
getShort
public short getShort()
Returns this value as a Javashort
value.- Returns:
- value
- Throws:
DbException
- if this value isNULL
or cannot be casted toSMALLINT
-
getInt
public int getInt()
Returns this value as a Javaint
value.- Returns:
- value
- Throws:
DbException
- if this value isNULL
or cannot be casted toINTEGER
-
getLong
public long getLong()
Returns this value as a Javalong
value.- Returns:
- value
- Throws:
DbException
- if this value isNULL
or cannot be casted toBIGINT
-
getBigDecimal
public java.math.BigDecimal getBigDecimal()
-
getFloat
public float getFloat()
Returns this value as a Javafloat
value.- Returns:
- value
- Throws:
DbException
- if this value isNULL
or cannot be casted toREAL
-
getDouble
public double getDouble()
Returns this value as a Javadouble
value.- Returns:
- value
- Throws:
DbException
- if this value isNULL
or cannot be casted toDOUBLE PRECISION
-
add
public Value add(Value v)
Add a value and return the result.- Parameters:
v
- the value to add- Returns:
- the result
-
getSignum
public int getSignum()
-
negate
public Value negate()
Return -value if this value support arithmetic operations.- Returns:
- the negative
-
subtract
public Value subtract(Value v)
Subtract a value and return the result.- Parameters:
v
- the value to subtract- Returns:
- the result
-
divide
public Value divide(Value v, TypeInfo quotientType)
Divide by a value and return the result.- Parameters:
v
- the divisorquotientType
- the type of quotient (used only to read precision and scale when applicable)- Returns:
- the result
-
multiply
public Value multiply(Value v)
Multiply with a value and return the result.- Parameters:
v
- the value to multiply with- Returns:
- the result
-
modulus
public 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
-
convertTo
public final Value convertTo(int targetType)
Convert a value to the specified type without taking scale and precision into account.- Parameters:
targetType
- the type of the returned value- Returns:
- the converted value
-
convertTo
public final Value convertTo(TypeInfo targetType)
Convert a value to the specified type without taking scale and precision into account.- Parameters:
targetType
- the type of the returned value- Returns:
- the converted value
-
convertTo
public final Value convertTo(int targetType, CastDataProvider provider)
Convert a value to the specified type without taking scale and precision into account.- Parameters:
targetType
- the type of the returned valueprovider
- the cast information provider- Returns:
- the converted value
-
convertTo
public final Value convertTo(TypeInfo targetType, CastDataProvider provider)
Convert a value to the specified type without taking scale and precision into account.- Parameters:
targetType
- the type of the returned valueprovider
- the cast information provider- Returns:
- the converted value
-
convertTo
public final Value convertTo(TypeInfo targetType, CastDataProvider provider, java.lang.Object column)
Convert a value to the specified type without taking scale and precision into account.- Parameters:
targetType
- the type of the returned valueprovider
- the cast information providercolumn
- the column, used to improve the error message if conversion fails- Returns:
- the converted value
-
convertToAnyArray
public final ValueArray convertToAnyArray(CastDataProvider provider)
Convert this value to any ARRAY data type.- Parameters:
provider
- the cast information provider- Returns:
- a row value
-
convertToAnyRow
public final ValueRow convertToAnyRow()
Convert this value to any ROW data type.- Returns:
- a row value
-
castTo
public final Value castTo(TypeInfo targetType, CastDataProvider provider)
Cast a value to the specified type. The scale is set if applicable. The value is truncated to the required precision.- Parameters:
targetType
- the type of the returned valueprovider
- the cast information provider- Returns:
- the converted value
-
convertForAssignTo
public final Value convertForAssignTo(TypeInfo targetType, CastDataProvider provider, java.lang.Object column)
Cast a value to the specified type for assignment. The scale is set if applicable. If precision is too large an exception is thrown.- Parameters:
targetType
- the type of the returned valueprovider
- the cast information providercolumn
- the column, used to improve the error message if conversion fails- Returns:
- the converted value
-
convertTo
private Value convertTo(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
Convert a value to the specified type.- Parameters:
targetType
- the type of the returned valueprovider
- the cast information providerconversionMode
- conversion modecolumn
- the column (if any), used to improve the error message if conversion fails- Returns:
- the converted value
-
convertToChar
public ValueChar convertToChar()
Converts this value to a CHAR value. May not be called on a NULL value.- Returns:
- a CHAR value.
-
convertToChar
private ValueChar convertToChar(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
-
convertToVarchar
private Value convertToVarchar(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
-
convertToClob
private ValueClob convertToClob(TypeInfo targetType, int conversionMode, java.lang.Object column)
-
convertToVarcharIgnoreCase
private Value convertToVarcharIgnoreCase(TypeInfo targetType, int conversionMode, java.lang.Object column)
-
convertToBinary
private ValueBinary convertToBinary(TypeInfo targetType, int conversionMode, java.lang.Object column)
-
convertToVarbinary
private ValueVarbinary convertToVarbinary(TypeInfo targetType, int conversionMode, java.lang.Object column)
-
convertToBlob
private ValueBlob convertToBlob(TypeInfo targetType, int conversionMode, java.lang.Object column)
-
convertToBoolean
public final ValueBoolean convertToBoolean()
Converts this value to a BOOLEAN value. May not be called on a NULL value.- Returns:
- the BOOLEAN value
-
convertToTinyint
public final ValueTinyint convertToTinyint(java.lang.Object column)
Converts this value to a TINYINT value. May not be called on a NULL value.- Parameters:
column
- the column, used for to improve the error message if conversion fails- Returns:
- the TINYINT value
-
convertToSmallint
public final ValueSmallint convertToSmallint(java.lang.Object column)
Converts this value to a SMALLINT value. May not be called on a NULL value.- Parameters:
column
- the column, used for to improve the error message if conversion fails- Returns:
- the SMALLINT value
-
convertToInt
public final ValueInteger convertToInt(java.lang.Object column)
Converts this value to a INT value. May not be called on a NULL value.- Parameters:
column
- the column, used for to improve the error message if conversion fails- Returns:
- the INT value
-
convertToBigint
public final ValueBigint convertToBigint(java.lang.Object column)
Converts this value to a BIGINT value. May not be called on a NULL value.- Parameters:
column
- the column, used for to improve the error message if conversion fails- Returns:
- the BIGINT value
-
convertToNumeric
private ValueNumeric convertToNumeric(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
-
convertToReal
public final ValueReal convertToReal()
Converts this value to a REAL value. May not be called on a NULL value.- Returns:
- the REAL value
-
convertToDouble
public final ValueDouble convertToDouble()
Converts this value to a DOUBLE value. May not be called on a NULL value.- Returns:
- the DOUBLE value
-
convertToDecfloat
private ValueDecfloat convertToDecfloat(TypeInfo targetType, int conversionMode)
-
convertToDate
public final ValueDate convertToDate(CastDataProvider provider)
Converts this value to a DATE value. May not be called on a NULL value.- Parameters:
provider
- the cast information provider- Returns:
- the DATE value
-
convertToTime
private ValueTime convertToTime(TypeInfo targetType, CastDataProvider provider, int conversionMode)
-
convertToTimeTimeZone
private ValueTimeTimeZone convertToTimeTimeZone(TypeInfo targetType, CastDataProvider provider, int conversionMode)
-
convertToTimestamp
private ValueTimestamp convertToTimestamp(TypeInfo targetType, CastDataProvider provider, int conversionMode)
-
getLocalTimeNanos
private long getLocalTimeNanos(CastDataProvider provider)
-
convertToTimestampTimeZone
private ValueTimestampTimeZone convertToTimestampTimeZone(TypeInfo targetType, CastDataProvider provider, int conversionMode)
-
convertToIntervalYearMonth
private ValueInterval convertToIntervalYearMonth(TypeInfo targetType, int conversionMode, java.lang.Object column)
-
convertToIntervalYearMonth
private ValueInterval convertToIntervalYearMonth(int targetType, java.lang.Object column)
-
convertToIntervalDayTime
private ValueInterval convertToIntervalDayTime(TypeInfo targetType, int conversionMode, java.lang.Object column)
-
convertToIntervalDayTime
private ValueInterval convertToIntervalDayTime(int targetType, java.lang.Object column)
-
convertToIntervalDayTime
private ValueInterval convertToIntervalDayTime(java.math.BigDecimal bigDecimal, int targetType)
-
convertToJavaObject
public final ValueJavaObject convertToJavaObject(TypeInfo targetType, int conversionMode, java.lang.Object column)
Converts this value to a JAVA_OBJECT value. May not be called on a NULL value.- Parameters:
targetType
- the type of the returned valueconversionMode
- conversion modecolumn
- the column (if any), used to improve the error message if conversion fails- Returns:
- the JAVA_OBJECT value
-
convertToEnum
public final ValueEnum convertToEnum(ExtTypeInfoEnum extTypeInfo, CastDataProvider provider)
Converts this value to an ENUM value. May not be called on a NULL value.- Parameters:
extTypeInfo
- the extended data type informationprovider
- the cast information provider- Returns:
- the ENUM value
-
convertToGeometry
public final ValueGeometry convertToGeometry(ExtTypeInfoGeometry extTypeInfo)
Converts this value to a GEOMETRY value. May not be called on a NULL value.- Parameters:
extTypeInfo
- the extended data type information, or null- Returns:
- the GEOMETRY value
-
convertToJson
private ValueJson convertToJson(TypeInfo targetType, int conversionMode, java.lang.Object column)
-
convertToUuid
public final ValueUuid convertToUuid()
Converts this value to a UUID value. May not be called on a NULL value.- Returns:
- the UUID value
-
convertToArray
private ValueArray convertToArray(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
-
convertToRow
private Value convertToRow(TypeInfo targetType, CastDataProvider provider, int conversionMode, java.lang.Object column)
-
getDataConversionError
final DbException getDataConversionError(int targetType)
Creates new instance of the DbException for data conversion error.- Parameters:
targetType
- Target data type.- Returns:
- instance of the DbException.
-
getDataConversionError
final DbException getDataConversionError(TypeInfo targetType)
Creates new instance of the DbException for data conversion error.- Parameters:
targetType
- target data type.- Returns:
- instance of the DbException.
-
getValueTooLongException
final DbException getValueTooLongException(TypeInfo targetType, java.lang.Object column)
-
compareTypeSafe
public abstract int compareTypeSafe(Value v, CompareMode mode, CastDataProvider provider)
Compare this value against another value given that the values are of the same data type.- Parameters:
v
- the other valuemode
- the compare modeprovider
- the cast information provider- Returns:
- 0 if both values are equal, -1 if the other value is smaller, and 1 otherwise
-
compareTo
public final int compareTo(Value v, CastDataProvider provider, CompareMode compareMode)
Compare this value against another value using the specified compare mode.- Parameters:
v
- the other valueprovider
- the cast information providercompareMode
- the compare mode- Returns:
- 0 if both values are equal, -1 if this value is smaller, and 1 otherwise
-
compareToNotNullable
private int compareToNotNullable(Value v, CastDataProvider provider, CompareMode compareMode)
-
compareWithNull
public int compareWithNull(Value v, boolean forEquality, CastDataProvider provider, CompareMode compareMode)
Compare this value against another value using the specified compare mode.- Parameters:
v
- the other valueforEquality
- perform only check for equalityprovider
- the cast information providercompareMode
- the compare mode- 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
-
containsNull
public boolean containsNull()
Returns true if this value is NULL or contains NULL value.- Returns:
- true if this value is NULL or contains NULL value
-
convertToByte
private static byte convertToByte(long x, java.lang.Object column)
-
convertToShort
private static short convertToShort(long x, java.lang.Object column)
-
convertToInt
public static int convertToInt(long x, java.lang.Object column)
Convert to integer, throwing exception if out of range.- Parameters:
x
- integer value.column
- Column info.- Returns:
- x
-
convertToLong
private static long convertToLong(double x, java.lang.Object column)
-
convertToLong
private static long convertToLong(java.math.BigDecimal x, java.lang.Object column)
-
getColumnName
private static java.lang.String getColumnName(java.lang.Object column)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getUnsupportedExceptionForOperation
protected final DbException getUnsupportedExceptionForOperation(java.lang.String op)
Create an exception meaning the specified operation is not supported for this data type.- Parameters:
op
- the operation- Returns:
- the exception
-
charLength
public long charLength()
Returns length of this value in characters.- Returns:
- length of this value in characters
- Throws:
java.lang.NullPointerException
- if this value isNULL
-
octetLength
public long octetLength()
Returns length of this value in bytes.- Returns:
- length of this value in bytes
- Throws:
java.lang.NullPointerException
- if this value isNULL
-
isTrue
public final boolean isTrue()
Returns whether this valueIS TRUE
.- Returns:
true
if it is. ForBOOLEAN
values returnstrue
forTRUE
andfalse
forFALSE
andUNKNOWN
(NULL
).- See Also:
getBoolean()
,isFalse()
-
isFalse
public final boolean isFalse()
Returns whether this valueIS FALSE
.- Returns:
true
if it is. ForBOOLEAN
values returnstrue
forFALSE
andfalse
forTRUE
andUNKNOWN
(NULL
).- See Also:
getBoolean()
,isTrue()
-
-