|
|||||||||
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
org.apache.derby.iapi.types.BinaryDecimal
org.apache.derby.iapi.types.BigIntegerDecimal
public final class BigIntegerDecimal
DECIMAL support using the immutable java.math.BigInteger to perform arithmetic and conversions. Extends BinaryDecimal to use the base support of that class. J2ME/CDC/Foundation includes BigInteger. A BigInteger is used in calculations etc. to represent the integral unscaled value. It is simply created from new BigInteger(data2c). No additional instance fields are used by this class, a possible enhancement would be to keep the BigInteger around but would require calls from the parent class to reset state etc.
Field Summary | |
---|---|
private static java.math.BigInteger |
MAXLONG_PLUS_ONE
|
private static java.math.BigInteger |
MINLONG_MINUS_ONE
|
private static java.math.BigInteger |
TEN
|
Fields inherited from class org.apache.derby.iapi.types.BinaryDecimal |
---|
data2c, sqlScale |
Fields inherited from class org.apache.derby.iapi.types.NumberDataType |
---|
ZERO_DECIMAL |
Fields inherited from interface org.apache.derby.iapi.types.VariableSizeDataValue |
---|
IGNORE_PRECISION |
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 | |
---|---|
BigIntegerDecimal()
|
Method Summary | |
---|---|
NumberDataValue |
divideNN(NumberDataValue left,
NumberDataValue right,
NumberDataValue result,
int scale)
Divide two non-null NumberDataValues using DECIMAL arithmetic. |
private BigIntegerDecimal |
getBID(DataValueDescriptor value)
Obtain a BinaryDecimal that represents the passed in value. |
boolean |
getBoolean()
Gets the value in the data value descriptor as a boolean. |
int |
getDecimalValuePrecision()
Return the SQL precision of this value. |
double |
getDouble()
Gets the value in the data value descriptor as a double. |
float |
getFloat()
Gets the value in the data value descriptor as a float. |
long |
getLong()
Gets the value in the data value descriptor as a long. |
DataValueDescriptor |
getNewNull()
Get a new null value of the same type as this data value. |
java.lang.String |
getString()
Gets the value in the data value descriptor as a String. |
NumberDataValue |
minus(NumberDataValue result)
Negate the number. |
void |
normalize(DataTypeDescriptor desiredType,
DataValueDescriptor source)
Default normalization method. |
NumberDataValue |
plusNN(NumberDataValue left,
NumberDataValue right,
NumberDataValue result)
Add two non-null NumberDataValues using DECIMAL arithmetic. |
private static java.math.BigInteger |
rescale(java.math.BigInteger bi,
int deltaScale)
Rescale a BigInteger, a positive delta means the scale is increased, zero no change and negative decrease of scale. |
void |
setValue(java.lang.String theValue)
Set the value from a String, the format is nnnn Scale always set to zero. |
void |
setWidth(int desiredPrecision,
int desiredScale,
boolean errorOnTrunc)
|
NumberDataValue |
timesNN(NumberDataValue left,
NumberDataValue right,
NumberDataValue result)
Multiple two non-null NumberDataValues using DECIMAL arithmetic. |
java.lang.String |
toString()
|
protected int |
typeCompare(DataValueDescriptor arg)
Compare two non-null NumberDataValues using DECIMAL arithmetic. |
Methods inherited from class org.apache.derby.iapi.types.BinaryDecimal |
---|
cloneValue, divide, divide, estimateMemoryUsage, getByte, getDecimalValueScale, getInt, getLength, getShort, getTypeFormatId, getTypeName, hashCode, isNegative, isNull, minus, minusNN, plus, readExternal, readExternalFromArray, restoreToNull, setFrom, setValue, setValue, setValue, setValue, setValue, setValue, setValueFromResultSet, times, typePrecedence, typeToBigDecimal, writeExternal |
Methods inherited from class org.apache.derby.iapi.types.NumberDataType |
---|
absolute, compare, compare, mod, normalizeDOUBLE, normalizeREAL, normalizeREAL, objectNull, setBigDecimal, setObject, setValue, setValue, sqrt |
Methods inherited from class org.apache.derby.iapi.types.DataType |
---|
checkHostVariable, cloneHolder, coalesce, compare, compare, compareTo, dataTypeConversion, equals, equals, flip, genericSetObject, getBytes, getDate, getNationalString, getObject, getStream, getTime, getTimestamp, getTraceString, getTypeName, greaterOrEquals, greaterThan, hasStream, in, invalidFormat, isNotNull, isNullOp, lessOrEquals, lessThan, notEquals, outOfRange, recycle, setInto, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, throwLangSetMismatch, throwLangSetMismatch |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.derby.iapi.types.DataValueDescriptor |
---|
checkHostVariable, cloneHolder, coalesce, compare, compare, equals, getBytes, getDate, getObject, getStream, getTime, getTimestamp, getTraceString, greaterOrEquals, greaterThan, hasStream, in, isNotNull, isNullOp, lessOrEquals, lessThan, notEquals, recycle, setInto, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue |
Field Detail |
---|
private static final java.math.BigInteger TEN
private static final java.math.BigInteger MAXLONG_PLUS_ONE
private static final java.math.BigInteger MINLONG_MINUS_ONE
Constructor Detail |
---|
public BigIntegerDecimal()
Method Detail |
---|
public DataValueDescriptor getNewNull()
DataValueDescriptor
public long getLong() throws StandardException
DataType
getLong
in interface DataValueDescriptor
getLong
in class DataType
StandardException
- Thrown on errorpublic float getFloat() throws StandardException
DataType
getFloat
in interface DataValueDescriptor
getFloat
in class DataType
StandardException
- Thrown on errorpublic double getDouble() throws StandardException
DataType
getDouble
in interface DataValueDescriptor
getDouble
in class DataType
StandardException
- Thrown on errorpublic boolean getBoolean()
DataType
getBoolean
in interface DataValueDescriptor
getBoolean
in class DataType
public void setValue(java.lang.String theValue) throws StandardException
setValue
in interface DataValueDescriptor
setValue
in class DataType
theValue
- The BigDecimal value to set this DataValueDescriptor to
StandardException
public java.lang.String getString()
DataValueDescriptor
public int getDecimalValuePrecision()
getDecimalValuePrecision
in interface NumberDataValue
getDecimalValuePrecision
in class NumberDataType
protected int typeCompare(DataValueDescriptor arg) throws StandardException
typeCompare
in class NumberDataType
StandardException
- Thrown on errorpublic NumberDataValue plusNN(NumberDataValue left, NumberDataValue right, NumberDataValue result) throws StandardException
plusNN
in class BinaryDecimal
StandardException
public NumberDataValue minus(NumberDataValue result) throws StandardException
result
- 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.NumberDataValue.minus(org.apache.derby.iapi.types.NumberDataValue)
public NumberDataValue timesNN(NumberDataValue left, NumberDataValue right, NumberDataValue result) throws StandardException
left * right
= (left_unscaled * 10^-left_scale) * (right_unscaled * 10^-right_scale)
= (left_unscaled * 10^-left_scale) * (right_unscaled * 10^-right_scale)
= (left_unscaled * right_unscaled) * 10^-(left_scale + right_scale)
timesNN
in class BinaryDecimal
StandardException
public NumberDataValue divideNN(NumberDataValue left, NumberDataValue right, NumberDataValue result, int scale) throws StandardException
left / right
= (left_unscaled * 10^-left_scale) / (right_unscaled * 10^-right_scale)
= (left_unscaled / right_unscaled) * (10^-left_scale / 10^-right_scale)
= (left_unscaled / right_unscaled) * (10^-(left_scale-right_scale))
divideNN
in class BinaryDecimal
StandardException
public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException
DataType
normalize
in interface DataValueDescriptor
normalize
in class DataType
desiredType
- The type to normalize the source column tosource
- The value to normalize
StandardException
- Thrown normalization error.public void setWidth(int desiredPrecision, int desiredScale, boolean errorOnTrunc) throws StandardException
StandardException
private BigIntegerDecimal getBID(DataValueDescriptor value) throws StandardException
StandardException
private static java.math.BigInteger rescale(java.math.BigInteger bi, int deltaScale)
bi
- value to be rescaleddeltaScale
- change of scale
public java.lang.String toString()
toString
in class java.lang.Object
|
Built on Thu 2011-03-10 11:54:14+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |