|
|||||||||
| 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 |
|---|
ONE, ZERO, 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.Object |
getObject()
Gets the value in the data value descriptor as a int. |
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 |
setBigDecimal(java.lang.Number theValue)
setValue for integral exact numerics. |
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, 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, 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, getStream, getTime, getTimestamp, getTraceString, getTypeName, greaterOrEquals, greaterThan, hasStream, in, invalidFormat, isNotNull, isNullOp, lessOrEquals, lessThan, notEquals, outOfRange, readExternalFromArray, recycle, setInto, setInto, setObjectForCast, setToNull, setValue, setValue, 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, getStream, getTime, getTimestamp, getTraceString, greaterOrEquals, greaterThan, hasStream, in, isNotNull, isNullOp, lessOrEquals, lessThan, notEquals, readExternalFromArray, recycle, setInto, setInto, setObjectForCast, setToNull, setValue, setValue, 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 DataValueDescriptorgetLong in class DataTypeStandardException - Thrown on error
public float getFloat()
throws StandardException
DataType
getFloat in interface DataValueDescriptorgetFloat in class DataTypeStandardException - Thrown on error
public double getDouble()
throws StandardException
DataType
getDouble in interface DataValueDescriptorgetDouble in class DataTypeStandardException - Thrown on errorpublic boolean getBoolean()
DataType
getBoolean in interface DataValueDescriptorgetBoolean in class DataType
public void setValue(java.lang.String theValue)
throws StandardException
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The BigDecimal value to set this DataValueDescriptor to
StandardException
public java.lang.Object getObject()
throws StandardException
DataType
getObject in interface DataValueDescriptorgetObject in class DataTypeStandardException - Thrown on errorpublic java.lang.String getString()
DataValueDescriptor
public int getDecimalValuePrecision()
getDecimalValuePrecision in interface NumberDataValuegetDecimalValuePrecision in class NumberDataType
protected int typeCompare(DataValueDescriptor arg)
throws StandardException
typeCompare in class NumberDataTypeStandardException - Thrown on error
public NumberDataValue plusNN(NumberDataValue left,
NumberDataValue right,
NumberDataValue result)
throws StandardException
plusNN in class BinaryDecimalStandardException
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 BinaryDecimalStandardException
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 BinaryDecimalStandardException
public void normalize(DataTypeDescriptor desiredType,
DataValueDescriptor source)
throws StandardException
DataType
normalize in interface DataValueDescriptornormalize in class DataTypedesiredType - 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 void setBigDecimal(java.lang.Number theValue)
throws StandardException
NumberDataType
setBigDecimal in interface DataValueDescriptorsetBigDecimal in class NumberDataTypetheValue - required to be a BigDecimal or null.
StandardExceptionpublic java.lang.String toString()
toString in class java.lang.Object
|
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 | ||||||||