java.io.Externalizable
, java.io.Serializable
, java.lang.Comparable
, Formatable
, Storable
, TypedFormat
, DataValueDescriptor
, NumberDataValue
, Orderable
SQLDecimal
, SQLDouble
, SQLInteger
, SQLLongint
, SQLReal
, SQLSmallint
, SQLTinyint
public abstract class NumberDataType extends DataType implements NumberDataValue
DataType
,
Serialized FormModifier and Type | Field | Description |
---|---|---|
(package private) static java.math.BigDecimal |
MAXLONG_PLUS_ONE |
|
(package private) static java.math.BigDecimal |
MINLONG_MINUS_ONE |
UNKNOWN_LOGICAL_LENGTH
MAX_DECIMAL_PRECISION_SCALE, MIN_DECIMAL_DIVIDE_SCALE
ORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN
Constructor | Description |
---|---|
NumberDataType() |
Modifier and Type | Method | Description |
---|---|---|
NumberDataValue |
absolute(NumberDataValue result) |
Numbers check for isNegative first and negate it if negative.
|
boolean |
compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV) |
Compare this Orderable with a given Orderable for the purpose of
qualification and sorting.
|
int |
compare(DataValueDescriptor arg) |
Compare this Orderable with a given Orderable for the purpose of
index positioning.
|
NumberDataValue |
divide(NumberDataValue dividend,
NumberDataValue divisor,
NumberDataValue result) |
This method implements the / operator for TINYINT, SMALLINT and INTEGER.
|
NumberDataValue |
divide(NumberDataValue dividend,
NumberDataValue divisor,
NumberDataValue result,
int scale) |
Suitable for integral types that ignore scale.
|
private static Context |
getContextOrNull(java.lang.String contextID) |
Privileged lookup of a Context.
|
protected abstract boolean |
isNegative() |
The isNegative abstract method.
|
NumberDataValue |
minus(NumberDataValue left,
NumberDataValue right,
NumberDataValue result) |
This method implements the - operator for TINYINT, SMALLINT and INTEGER.
|
NumberDataValue |
mod(NumberDataValue dividend,
NumberDataValue divisor,
NumberDataValue result) |
The SQL mod operator.
|
static double |
normalizeDOUBLE(double v) |
normalizeDOUBLE normalizes the value, so that negative zero (-0.0)
becomes positive.
|
static float |
normalizeREAL(double v) |
normalizeREAL normalizes the value, so that negative zero (-0.0)
becomes positive.
|
static float |
normalizeREAL(float v) |
normalizeREAL normalizes the value, so that negative zero (-0.0) becomes
positive.
|
protected boolean |
objectNull(java.lang.Object o) |
|
NumberDataValue |
plus(NumberDataValue addend1,
NumberDataValue addend2,
NumberDataValue result) |
This method implements the + operator for TINYINT,SMALLINT,INT.
|
void |
setBigDecimal(java.math.BigDecimal bigDecimal) |
setValue for integral exact numerics.
|
(package private) void |
setObject(java.lang.Object theValue) |
Set the value from a correctly typed Integer object.
|
void |
setValue(byte theValue) |
Common code to handle converting a byte to this value
by using the int to this value conversion.
|
void |
setValue(short theValue) |
Common code to handle converting a short to this value
by using the int to this value conversion.
|
void |
setValue(java.lang.Number theValue) |
Common code to handle java.lang.Integer as a Number,
used for TINYINT, SMALLINT, INTEGER
|
NumberDataValue |
sqrt(NumberDataValue result) |
This is the sqrt method.
|
protected abstract int |
typeCompare(DataValueDescriptor arg) |
Compare this (not null) to a non-null value.
|
int |
typeToBigDecimal() |
Implementation for integral types.
|
private static boolean |
useDB2Limits() |
Controls use of old DB2 limits (DERBY-3398).
|
checkHostVariable, cloneHolder, coalesce, compare, compare, compareTo, dataTypeConversion, equals, equals, flip, genericSetObject, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLong, getObject, getShort, getStream, getTime, getTimestamp, getTraceString, getTypeName, greaterOrEquals, greaterThan, hasStream, in, invalidFormat, isNotNull, isNullOp, lessOrEquals, lessThan, normalize, notEquals, outOfRange, readExternalFromArray, recycle, setFrom, setInto, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, throwLangSetMismatch, throwLangSetMismatch, typePrecedence
checkHostVariable, cloneHolder, cloneValue, coalesce, compare, compare, equals, estimateMemoryUsage, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLength, getLong, getNewNull, getObject, getShort, getStream, getString, getTime, getTimestamp, getTraceString, getTypeName, greaterOrEquals, greaterThan, hasStream, in, isNotNull, isNullOp, lessOrEquals, lessThan, normalize, notEquals, readExternalFromArray, recycle, setInto, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueFromResultSet, typePrecedence
minus, times
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isNull, restoreToNull
getTypeFormatId
static final java.math.BigDecimal MAXLONG_PLUS_ONE
static final java.math.BigDecimal MINLONG_MINUS_ONE
public final NumberDataValue absolute(NumberDataValue result) throws StandardException
absolute
in interface NumberDataValue
result
- The result of the previous call to this method, null
if not called yet.StandardException
- thrown on error.public NumberDataValue sqrt(NumberDataValue result) throws StandardException
sqrt
in interface NumberDataValue
result
- The result of the previous call to this method, null
if not call yet.StandardException
- thrown on a negative number.public NumberDataValue plus(NumberDataValue addend1, NumberDataValue addend2, NumberDataValue result) throws StandardException
plus
in interface NumberDataValue
addend1
- One of the addendsaddend2
- The other addendresult
- The result of a previous call to this method, null
if not called yetStandardException
- Thrown on errorpublic NumberDataValue minus(NumberDataValue left, NumberDataValue right, NumberDataValue result) throws StandardException
minus
in interface NumberDataValue
left
- The value to be subtracted fromright
- The value to be subtractedresult
- The result of a previous call to this method, null
if not called yetStandardException
- Thrown on errorpublic NumberDataValue divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) throws StandardException
divide
in interface NumberDataValue
dividend
- The numeratordivisor
- The denominatorresult
- The result of a previous call to this method, null
if not called yetStandardException
- Thrown on errorpublic NumberDataValue divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result, int scale) throws StandardException
divide
in interface NumberDataValue
dividend
- The numeratordivisor
- The denominatorresult
- The result of the previous call to this method, null
if not called yet.scale
- The scale of the result, for decimal type. If pass
in value < 0, can calculate it dynamically.StandardException
- Thrown on error, if result is non-null then its value will be unchanged.public NumberDataValue mod(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) throws StandardException
NumberDataValue
mod
in interface NumberDataValue
dividend
- The numeratordivisor
- The denominatorresult
- The result of the previous call to this method, null
if not called yet.StandardException
- Thrown on error, if result is non-null then its value will be unchanged.public final int compare(DataValueDescriptor arg) throws StandardException
DataValueDescriptor
compare
in interface DataValueDescriptor
arg
- The Orderable to compare this one to.StandardException
- Thrown on errorprotected abstract int typeCompare(DataValueDescriptor arg) throws StandardException
StandardException
- Thrown on errorpublic final boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) throws StandardException
DataValueDescriptor
compare
in interface DataValueDescriptor
compare
in class DataType
op
- Orderable.ORDER_OP_EQUALS means do an = comparison.
Orderable.ORDER_OP_LESSTHAN means compare this < other.
Orderable.ORDER_OP_LESSOREQUALS means compare this <= other.other
- The DataValueDescriptor to compare this one to.orderedNulls
- True means to treat nulls as ordered values,
that is, treat SQL null as equal to null, and less
than all other values.
False means to treat nulls as unknown values,
that is, the result of any comparison with a null
is the UNKNOWN truth value.unknownRV
- The return value to use if the result of the
comparison is the UNKNOWN truth value. In other
words, if orderedNulls is false, and a null is
involved in the comparison, return unknownRV.
This parameter is not used orderedNulls is true.StandardException
- thrown on errorprotected abstract boolean isNegative()
public void setValue(short theValue) throws StandardException
setValue
in interface DataValueDescriptor
setValue
in class DataType
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(byte theValue) throws StandardException
setValue
in interface DataValueDescriptor
setValue
in class DataType
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(java.lang.Number theValue) throws StandardException
setValue
in interface NumberDataValue
theValue
- An Number containing the value to set this
NumberDataValue to. Null means set the value
to SQL null.StandardException
- Thrown on errorNumberDataValue.setValue(java.lang.Number)
void setObject(java.lang.Object theValue) throws StandardException
setObject
in class DataType
StandardException
public void setBigDecimal(java.math.BigDecimal bigDecimal) throws StandardException
setBigDecimal
in interface DataValueDescriptor
setBigDecimal
in class DataType
bigDecimal
- required to be a BigDecimal or null.StandardException
public int typeToBigDecimal()
typeToBigDecimal
in interface DataValueDescriptor
typeToBigDecimal
in class DataType
protected final boolean objectNull(java.lang.Object o)
public static float normalizeREAL(float v) throws StandardException
StandardException
- if the value is not a number (NaN) or is
infinite.public static float normalizeREAL(double v) throws StandardException
The reason for having normalizeREAL with two signatures is to
avoid that normalizeREAL is accidentally called with a casted
(float)<double value>
since this can introduce an undetected
underflow values to 0.0f.
StandardException
- if the value is not a number (NaN) or is
infinite or on underflow
(the value has magnitude too small to be represented as a float).public static double normalizeDOUBLE(double v) throws StandardException
StandardException
- if v is not a number (NaN) or is infinite.private static boolean useDB2Limits() throws StandardException
StandardException
private static Context getContextOrNull(java.lang.String contextID)
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.