Top Description Fields Constructors Methods
org.h2.value

public final Class ValueNumeric

extends ValueBigDecimalBase
Class Inheritance
Imports
java.math.BigDecimal, .BigInteger, .RoundingMode, org.h2.api.ErrorCode, org.h2.engine.CastDataProvider, org.h2.message.DbException

Implementation of the NUMERIC data type.

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_SCALE

The default scale for a NUMERIC value.

public static final int
MAXIMUM_SCALE

The maximum scale.

public static final ValueNumeric
ONE

The value 'one'.

public static final ValueNumeric
ZERO

The value 'zero'.

Inherited from org.h2.value.ValueBigDecimalBase:
typevalue

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Value
add(Value
the value to add
v
)

Overrides org.h2.value.Value.add.

Add a value and return the result.

public int
compareTypeSafe(Value
the other value
o
,
CompareMode
the compare mode
mode
,
CastDataProvider
the cast information provider
provider
)

Implements abstract org.h2.value.Value.compareTypeSafe.

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

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

Overrides org.h2.value.Value.divide.

Divide by a value and return the result.

public boolean
equals(Object
the other value
other
)

Implements abstract org.h2.value.Value.equals.

Check if the two values have the same hash code.

public static ValueNumeric

Returns:

the value
get
(BigDecimal
the big decimal
dec
)

Get or create a NUMERIC value for the given big decimal.

public static ValueNumeric

Returns:

the value
get
(BigInteger
the big integer
bigInteger
)

Get or create a NUMERIC value for the given big integer.

public static ValueNumeric

Returns:

the value
getAnyScale
(BigDecimal
the big decimal
dec
)

Get or create a NUMERIC value for the given big decimal with possibly negative scale.

public BigDecimal
public double
getDouble()

Overrides org.h2.value.Value.getDouble.

Returns this value as a Java double value.

public float
getFloat()

Overrides org.h2.value.Value.getFloat.

Returns this value as a Java float value.

public int
getMemory()

Overrides org.h2.value.Value.getMemory.

Get the memory used by this object.

public int
public StringBuilder
getSQL(StringBuilder
string builder
builder
,
int
formatting flags
sqlFlags
)

Implements org.h2.util.HasSQL.getSQL.

Appends the SQL statement of this object to the specified builder.

public String
getString()

Implements abstract org.h2.value.Value.getString.

Get the value as a string.

public TypeInfo
getType()

Implements abstract org.h2.value.Value.getType.

Implements org.h2.value.Typed.getType.

Returns the data type.

public int
getValueType()

Implements abstract org.h2.value.Value.getValueType.

Get the value type.

public int
hashCode()

Implements abstract org.h2.value.Value.hashCode.

Returns a hash code value for this object.

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

Overrides org.h2.value.Value.modulus.

Take the modulus with a value and return the result.

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

Overrides org.h2.value.Value.multiply.

Multiply with a value and return the result.

public Value
negate()

Overrides org.h2.value.Value.negate.

Return -value if this value support arithmetic operations.

public static BigDecimal

Returns:

the scaled value
setScale
(BigDecimal
the BigDecimal value
bd
,
int
the new scale
scale
)

Set the scale of a BigDecimal value.

public Value
subtract(Value
the value to subtract
v
)

Overrides org.h2.value.Value.subtract.

Subtract a value and return the result.

Field Detail

DEFAULT_SCALEback to summary
public static final int DEFAULT_SCALE

The default scale for a NUMERIC value.

MAXIMUM_SCALEback to summary
public static final int MAXIMUM_SCALE

The maximum scale.

ONEback to summary
public static final ValueNumeric ONE

The value 'one'.

ZEROback to summary
public static final ValueNumeric ZERO

The value 'zero'.

Constructor Detail

ValueNumericback to summary
private ValueNumeric(BigDecimal value)

Method Detail

addback to summary
public Value add(Value v)

Overrides org.h2.value.Value.add.

Doc from org.h2.value.Value.add.

Add a value and return the result.

Parameters
v:Value

the value to add

Returns:Value

the result

Annotations
@Override
compareTypeSafeback to summary
public int compareTypeSafe(Value o, CompareMode mode, CastDataProvider provider)

Implements abstract org.h2.value.Value.compareTypeSafe.

Doc from org.h2.value.Value.compareTypeSafe.

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

Parameters
o:Value

the other value

mode:CompareMode

the compare mode

provider:CastDataProvider

the cast information provider

Returns:int

0 if both values are equal, -1 if the other value is smaller, and 1 otherwise

Annotations
@Override
divideback to summary
public Value divide(Value v, TypeInfo quotientType)

Overrides org.h2.value.Value.divide.

Doc from org.h2.value.Value.divide.

Divide by a value and return the result.

Parameters
v:Value

the divisor

quotientType:TypeInfo

the type of quotient (used only to read precision and scale when applicable)

Returns:Value

the result

Annotations
@Override
equalsback to summary
public boolean equals(Object other)

Implements abstract org.h2.value.Value.equals.

Doc from org.h2.value.Value.equals.

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:Object

the other value

Returns:boolean

true if they are equal

Annotations
@Override
getback to summary
public static ValueNumeric get(BigDecimal dec)

Get or create a NUMERIC value for the given big decimal.

Parameters
dec:BigDecimal

the big decimal

Returns:ValueNumeric

the value

getback to summary
public static ValueNumeric get(BigInteger bigInteger)

Get or create a NUMERIC value for the given big integer.

Parameters
bigInteger:BigInteger

the big integer

Returns:ValueNumeric

the value

getAnyScaleback to summary
public static ValueNumeric getAnyScale(BigDecimal dec)

Get or create a NUMERIC value for the given big decimal with possibly negative scale. If scale is negative, it is normalized to 0.

Parameters
dec:BigDecimal

the big decimal

Returns:ValueNumeric

the value

getBigDecimalback to summary
public BigDecimal getBigDecimal()

Overrides org.h2.value.Value.getBigDecimal.

Annotations
@Override
getDoubleback to summary
public double getDouble()

Overrides org.h2.value.Value.getDouble.

Doc from org.h2.value.Value.getDouble.

Returns this value as a Java double value.

Returns:double

value

Annotations
@Override
getFloatback to summary
public float getFloat()

Overrides org.h2.value.Value.getFloat.

Doc from org.h2.value.Value.getFloat.

Returns this value as a Java float value.

Returns:float

value

Annotations
@Override
getMemoryback to summary
public int getMemory()

Overrides org.h2.value.Value.getMemory.

Doc from org.h2.value.Value.getMemory.

Get the memory used by this object.

Returns:int

the memory used in bytes

Annotations
@Override
getSignumback to summary
public int getSignum()

Overrides org.h2.value.Value.getSignum.

Annotations
@Override
getSQLback to summary
public StringBuilder getSQL(StringBuilder builder, int sqlFlags)

Implements org.h2.util.HasSQL.getSQL.

Doc from org.h2.util.HasSQL.getSQL.

Appends the SQL statement of this object to the specified builder.

Parameters
builder:StringBuilder

string builder

sqlFlags:int

formatting flags

Returns:StringBuilder

the specified string builder

Annotations
@Override
getStringback to summary
public String getString()

Implements abstract org.h2.value.Value.getString.

Doc from org.h2.value.Value.getString.

Get the value as a string.

Returns:String

the string

Annotations
@Override
getTypeback to summary
public TypeInfo getType()

Implements abstract org.h2.value.Value.getType.

Implements org.h2.value.Typed.getType.

Doc from org.h2.value.Typed.getType.

Returns the data type.

Returns:TypeInfo

the data type

Annotations
@Override
getValueTypeback to summary
public int getValueType()

Implements abstract org.h2.value.Value.getValueType.

Doc from org.h2.value.Value.getValueType.

Get the value type.

Returns:int

the value type

Annotations
@Override
hashCodeback to summary
public int hashCode()

Implements abstract org.h2.value.Value.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
modulusback to summary
public Value modulus(Value v)

Overrides org.h2.value.Value.modulus.

Doc from org.h2.value.Value.modulus.

Take the modulus with a value and return the result.

Parameters
v:Value

the value to take the modulus with

Returns:Value

the result

Annotations
@Override
multiplyback to summary
public Value multiply(Value v)

Overrides org.h2.value.Value.multiply.

Doc from org.h2.value.Value.multiply.

Multiply with a value and return the result.

Parameters
v:Value

the value to multiply with

Returns:Value

the result

Annotations
@Override
negateback to summary
public Value negate()

Overrides org.h2.value.Value.negate.

Doc from org.h2.value.Value.negate.

Return -value if this value support arithmetic operations.

Returns:Value

the negative

Annotations
@Override
setScaleback to summary
public static BigDecimal setScale(BigDecimal bd, int scale)

Set the scale of a BigDecimal value.

Parameters
bd:BigDecimal

the BigDecimal value

scale:int

the new scale

Returns:BigDecimal

the scaled value

subtractback to summary
public Value subtract(Value v)

Overrides org.h2.value.Value.subtract.

Doc from org.h2.value.Value.subtract.

Subtract a value and return the result.

Parameters
v:Value

the value to subtract

Returns:Value

the result

Annotations
@Override