|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.derby.iapi.types.DataType
org.apache.derby.iapi.types.NumberDataType
public abstract class NumberDataType
NumberDataType is the superclass for all exact and approximate numeric data types. It exists for the purpose of allowing classification of types for supported implicit conversions among them.
DataType,
Serialized Form| Field Summary | |
|---|---|
(package private) static java.math.BigDecimal |
MAXLONG_PLUS_ONE
|
(package private) static java.math.BigDecimal |
MINLONG_MINUS_ONE
|
(package private) static java.math.BigDecimal |
ONE
|
(package private) static java.math.BigDecimal |
ZERO
|
(package private) static DataValueDescriptor |
ZERO_DECIMAL
Set by the booting DataValueFactory implementation. |
| Fields inherited from interface org.apache.derby.iapi.types.NumberDataValue |
|---|
MAX_DECIMAL_PRECISION_SCALE, MIN_DECIMAL_DIVIDE_SCALE |
| Fields inherited from interface org.apache.derby.iapi.types.DataValueDescriptor |
|---|
UNKNOWN_LOGICAL_LENGTH |
| Fields inherited from interface org.apache.derby.iapi.types.Orderable |
|---|
ORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN |
| Constructor Summary | |
|---|---|
NumberDataType()
|
|
| Method Summary | |
|---|---|
NumberDataValue |
absolute(NumberDataValue result)
Numbers check for isNegative first and negate it if negative. |
int |
compare(DataValueDescriptor arg)
Compare this Orderable with a given Orderable for the purpose of index positioning. |
boolean |
compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV)
Compare this Orderable with a given Orderable for the purpose of qualification and sorting. |
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. |
int |
getDecimalValuePrecision()
Return the precision of this specific DECIMAL value. |
int |
getDecimalValueScale()
Return the scale of this specific DECIMAL value. |
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.lang.Number 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(java.lang.Number theValue)
Common code to handle java.lang.Integer as a Number, used for TINYINT, SMALLINT, INTEGER |
void |
setValue(short theValue)
Common code to handle converting a short to this value by using the int to this value conversion. |
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). |
| Methods inherited from class org.apache.derby.iapi.types.DataType |
|---|
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 |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.derby.iapi.types.NumberDataValue |
|---|
minus, times |
| Methods inherited from interface org.apache.derby.iapi.types.DataValueDescriptor |
|---|
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 |
| Methods inherited from interface org.apache.derby.iapi.services.io.Storable |
|---|
isNull, restoreToNull |
| Methods inherited from interface java.io.Externalizable |
|---|
readExternal, writeExternal |
| Methods inherited from interface org.apache.derby.iapi.services.io.TypedFormat |
|---|
getTypeFormatId |
| Field Detail |
|---|
static DataValueDescriptor ZERO_DECIMAL
static final java.math.BigDecimal ZERO
static final java.math.BigDecimal ONE
static final java.math.BigDecimal MAXLONG_PLUS_ONE
static final java.math.BigDecimal MINLONG_MINUS_ONE
| Constructor Detail |
|---|
public NumberDataType()
| Method Detail |
|---|
public final NumberDataValue absolute(NumberDataValue result)
throws StandardException
absolute in interface NumberDataValueresult - 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 NumberDataValueresult - 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 NumberDataValueaddend1 - One of the addendsaddend2 - The other addendresult - The result of a previous call to this method, null
if not called yet
StandardException - Thrown on error
public NumberDataValue minus(NumberDataValue left,
NumberDataValue right,
NumberDataValue result)
throws StandardException
minus in interface NumberDataValueleft - The value to be subtracted fromright - The value to be subtractedresult - The result of a previous call to this method, null
if not called yet
StandardException - Thrown on error
public NumberDataValue divide(NumberDataValue dividend,
NumberDataValue divisor,
NumberDataValue result)
throws StandardException
divide in interface NumberDataValuedividend - The numeratordivisor - The denominatorresult - The result of a previous call to this method, null
if not called yet
StandardException - Thrown on error
public NumberDataValue divide(NumberDataValue dividend,
NumberDataValue divisor,
NumberDataValue result,
int scale)
throws StandardException
divide in interface NumberDataValuedividend - 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 NumberDataValuedividend - 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 DataValueDescriptorarg - The Orderable to compare this one to.
StandardException - Thrown on error
protected abstract int typeCompare(DataValueDescriptor arg)
throws StandardException
StandardException - Thrown on error
public final boolean compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV)
throws StandardException
DataValueDescriptor
compare in interface DataValueDescriptorcompare in class DataTypeop - 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 DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor to
StandardException - Thrown on error
public void setValue(byte theValue)
throws StandardException
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor to
StandardException - Thrown on error
public void setValue(java.lang.Number theValue)
throws StandardException
setValue in interface NumberDataValuetheValue - 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 DataTypeStandardException
public void setBigDecimal(java.lang.Number bigDecimal)
throws StandardException
setBigDecimal in interface DataValueDescriptorsetBigDecimal in class DataTypebigDecimal - required to be a BigDecimal or null.
StandardExceptionpublic int typeToBigDecimal()
typeToBigDecimal in interface DataValueDescriptortypeToBigDecimal in class DataTypepublic int getDecimalValuePrecision()
getDecimalValuePrecision in interface NumberDataValuepublic int getDecimalValueScale()
getDecimalValueScale in interface NumberDataValueprotected 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
|
Built on Wed 2013-06-12 15:21:56+0000, from revision ??? | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||