|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> [ types overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.iapi.types
Class NumberDataType

java.lang.Objectorg.apache.derby.iapi.types.DataType
org.apache.derby.iapi.types.NumberDataType
- All Implemented Interfaces:
- CloneableObject, DataValueDescriptor, java.io.Externalizable, org.apache.derby.iapi.services.io.Formatable, NumberDataValue, Orderable, java.io.Serializable, org.apache.derby.iapi.services.io.Storable, org.apache.derby.iapi.services.io.TypedFormat
- Direct Known Subclasses:
- BinaryDecimal, SQLDecimal, SQLDouble, SQLInteger, SQLLongint, SQLReal, SQLSmallint, SQLTinyint
- public abstract class NumberDataType
- extends DataType
- implements NumberDataValue
- extends DataType
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.
| Field Summary | |
(package private) static java.lang.Comparable |
MAXLONG_PLUS_ONE
Set by the booting DataValueFactory implementation. |
(package private) static java.lang.Comparable |
MINLONG_MINUS_ONE
Set by the booting DataValueFactory implementation. |
(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.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 checks the validity of the given java double that it fits within the range of DB2 DOUBLEs. |
static float |
normalizeREAL(double v)
normalizeREAL checks the validity of the given java double that it fits within the range of DB2 REALs. |
static float |
normalizeREAL(float v)
normalizeREAL checks the validity of the given java float that it fits within the range of DB2 REALs. |
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. |
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. |
| Methods inherited from class org.apache.derby.iapi.types.DataType |
checkHostVariable, cloneObject, coalesce, dataTypeConversion, equals, equals, flip, genericSetObject, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLong, getNationalString, getObject, getShort, getStream, getTime, getTimestamp, greaterOrEquals, greaterThan, in, invalidFormat, isNotNull, isNullOp, lessOrEquals, lessThan, normalize, notEquals, outOfRange, setFrom, setInto, setInto, setObjectForCast, setToNull, 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, coalesce, equals, estimateMemoryUsage, getBoolean, getByte, getBytes, getClone, getDate, getDouble, getFloat, getInt, getLength, getLong, getNewNull, getObject, getShort, getStream, getString, getTime, getTimestamp, getTypeName, greaterOrEquals, greaterThan, in, isNotNull, isNullOp, lessOrEquals, lessThan, normalize, notEquals, readExternalFromArray, setInto, setInto, setObjectForCast, setToNull, 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 |
ZERO_DECIMAL
static DataValueDescriptor ZERO_DECIMAL
- Set by the booting DataValueFactory implementation.
MINLONG_MINUS_ONE
static java.lang.Comparable MINLONG_MINUS_ONE
- Set by the booting DataValueFactory implementation.
MAXLONG_PLUS_ONE
static java.lang.Comparable MAXLONG_PLUS_ONE
- Set by the booting DataValueFactory implementation.
| Constructor Detail |
NumberDataType
public NumberDataType()
| Method Detail |
absolute
public final NumberDataValue absolute(NumberDataValue result) throws org.apache.derby.iapi.error.StandardException
- Numbers check for isNegative first and negate it if negative.
- Specified by:
absolutein interfaceNumberDataValue
sqrt
public NumberDataValue sqrt(NumberDataValue result) throws org.apache.derby.iapi.error.StandardException
- This is the sqrt method.
- Specified by:
sqrtin interfaceNumberDataValue
plus
public NumberDataValue plus(NumberDataValue addend1, NumberDataValue addend2, NumberDataValue result) throws org.apache.derby.iapi.error.StandardException
- This method implements the + operator for TINYINT,SMALLINT,INT.
- Specified by:
plusin interfaceNumberDataValue
minus
public NumberDataValue minus(NumberDataValue left, NumberDataValue right, NumberDataValue result) throws org.apache.derby.iapi.error.StandardException
- This method implements the - operator for TINYINT, SMALLINT and INTEGER.
- Specified by:
minusin interfaceNumberDataValue
divide
public NumberDataValue divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) throws org.apache.derby.iapi.error.StandardException
- This method implements the / operator for TINYINT, SMALLINT and INTEGER.
Specialized methods are not required for TINYINT and SMALLINT as the Java
virtual machine always executes byte and int division as integer.
- Specified by:
dividein interfaceNumberDataValue
divide
public NumberDataValue divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result, int scale) throws org.apache.derby.iapi.error.StandardException
- Suitable for integral types that ignore scale.
- Specified by:
dividein interfaceNumberDataValue
mod
public NumberDataValue mod(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
NumberDataValue - The SQL mod operator.
- Specified by:
modin interfaceNumberDataValue
compare
public final int compare(DataValueDescriptor arg) throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Compare this Orderable with a given Orderable for the purpose of
index positioning. This method treats nulls as ordered values -
that is, it treats SQL null as equal to null and less than all
other values.
- Specified by:
comparein interfaceDataValueDescriptor
typeCompare
protected abstract int typeCompare(DataValueDescriptor arg) throws org.apache.derby.iapi.error.StandardException
- Compare this (not null) to a non-null value.
compare
public final boolean compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV)
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Compare this Orderable with a given Orderable for the purpose of
qualification and sorting. The caller gets to determine how nulls
should be treated - they can either be ordered values or unknown
values.
- Specified by:
comparein interfaceDataValueDescriptor- Overrides:
comparein classDataType
isNegative
protected abstract boolean isNegative()
- The isNegative abstract method. Checks to see if this.value is negative.
To be implemented by each NumberDataType.
setValue
public void setValue(short theValue)
throws org.apache.derby.iapi.error.StandardException
- Common code to handle converting a short to this value
by using the int to this value conversion.
Simply calls setValue(int).
- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classDataType
setValue
public void setValue(byte theValue)
throws org.apache.derby.iapi.error.StandardException
- Common code to handle converting a byte to this value
by using the int to this value conversion.
Simply calls setValue(int).
- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classDataType
setValue
public void setValue(java.lang.Number theValue) throws org.apache.derby.iapi.error.StandardException
- Common code to handle java.lang.Integer as a Number,
used for TINYINT, SMALLINT, INTEGER
- Specified by:
setValuein interfaceNumberDataValue
setBigDecimal
public void setBigDecimal(java.lang.Number bigDecimal) throws org.apache.derby.iapi.error.StandardException
- setValue for integral exact numerics. Converts the BigDecimal
to a long to preserve precision
- Specified by:
setBigDecimalin interfaceDataValueDescriptor- Overrides:
setBigDecimalin classDataType
typeToBigDecimal
public int typeToBigDecimal()
- Implementation for integral types. Convert to a BigDecimal using long
- Specified by:
typeToBigDecimalin interfaceDataValueDescriptor- Overrides:
typeToBigDecimalin classDataType
getDecimalValuePrecision
public int getDecimalValuePrecision()
- Return the precision of this specific DECIMAL value.
If the value does not represent a SQL DECIMAL then
the return is undefined.
- Specified by:
getDecimalValuePrecisionin interfaceNumberDataValue
getDecimalValueScale
public int getDecimalValueScale()
- Return the scale of this specific DECIMAL value.
If the value does not represent a SQL DECIMAL then
the return is undefined.
- Specified by:
getDecimalValueScalein interfaceNumberDataValue
objectNull
protected final boolean objectNull(java.lang.Object o)
normalizeREAL
public static float normalizeREAL(float v)
throws org.apache.derby.iapi.error.StandardException
- normalizeREAL checks the validity of the given java float that
it fits within the range of DB2 REALs. In addition it
normalizes the value, so that negative zero (-0.0) becomes positive.
normalizeREAL
public static float normalizeREAL(double v)
throws org.apache.derby.iapi.error.StandardException
- normalizeREAL checks the validity of the given java double that
it fits within the range of DB2 REALs. In addition it
normalizes the value, so that negative zero (-0.0) becomes positive.
The reason for having normalizeREAL with two signatures is to
avoid that normalizeREAL is called with a casted (float)doublevalue,
since this invokes an unwanted rounding (of underflow values to 0.0),
in contradiction to DB2s casting semantics.
normalizeDOUBLE
public static double normalizeDOUBLE(double v)
throws org.apache.derby.iapi.error.StandardException
- normalizeDOUBLE checks the validity of the given java double that
it fits within the range of DB2 DOUBLEs. In addition it
normalizes the value, so that negative zero (-0.0) becomes positive.
|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> [ types overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC