| java.lang.Object org.apache.derby.iapi.types.DataType org.apache.derby.iapi.types.NumberDataType org.apache.derby.iapi.types.BinaryDecimal
All known Subclasses: org.apache.derby.iapi.types.BigIntegerDecimal,
BinaryDecimal | abstract class BinaryDecimal extends NumberDataType implements VariableSizeDataValue(Code) | | SQL DECIMAL using raw data. Provides the basis for the
CDCDecimal implementation.
The on-disk format must match the SQLDecimal format so that
databases are portable across J2ME and J2SE environments.
The format of the byte array is defined by the return of the
java.math.BigInteger.toByteArray:, extracted here.
Returns a byte array containing the two's-complement representation of this BigInteger.
The byte array will be in big-endian byte-order: the most significant byte is in the zeroth element.
This is the format for DECIMAL even if BigINteger is not available, e.g. OSGi ee.minimum.
|
Field Summary | |
protected byte[] | data2c The unscaled value as a binary two's complement array. | protected int | sqlScale |
Method Summary | |
public NumberDataValue | divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) | final public NumberDataValue | divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result, int scale) | abstract public NumberDataValue | divideNN(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result, int scale) Divide two non-nullable values using DECIMAL arithmetic. | public int | estimateMemoryUsage() | final public byte | getByte() Return a byte from this value. | public DataValueDescriptor | getClone() | public int | getDecimalValueScale() Return the SQL scale of this value, number of digits after the
decimal point, or zero for a whole number. | final public int | getInt() Return a int from this value. | final public int | getLength() | final public short | getShort() Return a short from this value. | final public int | getTypeFormatId() Return my format identifier. | final public String | getTypeName() | public int | hashCode() | protected boolean | isNegative() | public boolean | isNull() see if the decimal value is null. | final public NumberDataValue | minus(NumberDataValue left, NumberDataValue right, NumberDataValue result) | public NumberDataValue | minusNN(NumberDataValue left, NumberDataValue right, NumberDataValue result) Implement subtraction using addition and negation of the right value. | final public NumberDataValue | plus(NumberDataValue addend1, NumberDataValue addend2, NumberDataValue result) This method implements the + operator for DECIMAL. | abstract public NumberDataValue | plusNN(NumberDataValue addend1, NumberDataValue addend2, NumberDataValue result) Add two non-nullable values using DECIMAL arithmetic. | public void | readExternal(ObjectInput in) Note the use of data2c: we reuse the array if the
incoming array is the same length or smaller than
the array length. | public void | readExternalFromArray(ArrayInputStream in) | public void | restoreToNull() | protected void | setFrom(DataValueDescriptor dvd) | public void | setValue(long theValue) Set the value from a long. | final public void | setValue(int theValue) Set the value from an int, just copy 'byte-by-byte'
from the int to a four byte array. | public void | setValue(boolean theValue) | final public void | setValue(double theValue) Convert from a double, normalize and then convert as a String. | final public void | setValue(float theValue) Convert from a float, normalize and then convert as a String. | public void | setValue(Number theValue) Called when setting a DECIMAL value internally or from
through a procedure or function. | public void | setValueFromResultSet(ResultSet resultSet, int colNumber, boolean isNullable) | final public NumberDataValue | times(NumberDataValue left, NumberDataValue right, NumberDataValue result) | abstract public NumberDataValue | timesNN(NumberDataValue left, NumberDataValue right, NumberDataValue result) Multiple two non-nullable values using DECIMAL arithmetic. | final public int | typePrecedence() | final public int | typeToBigDecimal() DECIMAL implementation. | public void | writeExternal(ObjectOutput out) |
data2c | protected byte[] data2c(Code) | | The unscaled value as a binary two's complement array.
|
sqlScale | protected int sqlScale(Code) | | The SQL scale, zero or positive, of the value
|
BinaryDecimal | BinaryDecimal()(Code) | | |
divide | final public NumberDataValue divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result, int scale) throws StandardException(Code) | | This method implements the / operator for BigDecimal/BigDecimal
Parameters: dividend - The numerator Parameters: divisor - The denominator Parameters: result - The result of a previous call to this method, nullif not called yet Parameters: scale - The result scale, if < 0, calculate the scale accordingto the actual values' sizes A SQLDecimal containing the result of the division exception: StandardException - Thrown on error |
estimateMemoryUsage | public int estimateMemoryUsage()(Code) | | |
getDecimalValueScale | public int getDecimalValueScale()(Code) | | Return the SQL scale of this value, number of digits after the
decimal point, or zero for a whole number.
|
getLength | final public int getLength()(Code) | | |
hashCode | public int hashCode()(Code) | | |
isNegative | protected boolean isNegative()(Code) | | |
isNull | public boolean isNull()(Code) | | see if the decimal value is null.
|
restoreToNull | public void restoreToNull()(Code) | | |
setValue | public void setValue(long theValue)(Code) | | Set the value from a long.
|
setValue | final public void setValue(int theValue)(Code) | | Set the value from an int, just copy 'byte-by-byte'
from the int to a four byte array. Then reduce.
See Also: NumberDataValue.setValue |
setValue | public void setValue(boolean theValue)(Code) | | Set the value from a boolean
|
setValue | final public void setValue(float theValue) throws StandardException(Code) | | Convert from a float, normalize and then convert as a String.
|
setValue | public void setValue(Number theValue) throws StandardException(Code) | | Called when setting a DECIMAL value internally or from
through a procedure or function.
Handles long in addition to BigDecimal to handle
identity being stored as a long but returned as a DECIMAL.
|
typeToBigDecimal | final public int typeToBigDecimal()(Code) | | DECIMAL implementation.
Use DECIMAL to indicate to self that another
passed in value is an instance of this type.
|
writeExternal | public void writeExternal(ObjectOutput out) throws IOException(Code) | | Distill the Decimal to a byte array and
Write out:
- scale (unsigned byte)
- length of byte array
- the byte array
|
Methods inherited from org.apache.derby.iapi.types.NumberDataType | final public NumberDataValue absolute(NumberDataValue result) throws StandardException(Code)(Java Doc) final public int compare(DataValueDescriptor arg) throws StandardException(Code)(Java Doc) final public boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) throws StandardException(Code)(Java Doc) public NumberDataValue divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) throws StandardException(Code)(Java Doc) public NumberDataValue divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result, int scale) throws StandardException(Code)(Java Doc) public int getDecimalValuePrecision()(Code)(Java Doc) public int getDecimalValueScale()(Code)(Java Doc) abstract protected boolean isNegative()(Code)(Java Doc) public NumberDataValue minus(NumberDataValue left, NumberDataValue right, NumberDataValue result) throws StandardException(Code)(Java Doc) public NumberDataValue mod(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) throws StandardException(Code)(Java Doc) public static double normalizeDOUBLE(double v) throws StandardException(Code)(Java Doc) public static float normalizeREAL(float v) throws StandardException(Code)(Java Doc) public static float normalizeREAL(double v) throws StandardException(Code)(Java Doc) final protected boolean objectNull(Object o)(Code)(Java Doc) public NumberDataValue plus(NumberDataValue addend1, NumberDataValue addend2, NumberDataValue result) throws StandardException(Code)(Java Doc) public void setBigDecimal(Number bigDecimal) throws StandardException(Code)(Java Doc) void setObject(Object theValue) throws StandardException(Code)(Java Doc) public void setValue(short theValue) throws StandardException(Code)(Java Doc) public void setValue(byte theValue) throws StandardException(Code)(Java Doc) public void setValue(Number theValue) throws StandardException(Code)(Java Doc) public NumberDataValue sqrt(NumberDataValue result) throws StandardException(Code)(Java Doc) abstract protected int typeCompare(DataValueDescriptor arg) throws StandardException(Code)(Java Doc) public int typeToBigDecimal()(Code)(Java Doc)
|
Methods inherited from org.apache.derby.iapi.types.DataType | public void checkHostVariable(int declaredLength) throws StandardException(Code)(Java Doc) public Object cloneObject()(Code)(Java Doc) public DataValueDescriptor coalesce(DataValueDescriptor[] argumentsList, DataValueDescriptor returnValue) throws StandardException(Code)(Java Doc) public boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) throws StandardException(Code)(Java Doc) final protected StandardException dataTypeConversion(String targetType)(Code)(Java Doc) public BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public boolean equals(Object other)(Code)(Java Doc) protected static int flip(int operator)(Code)(Java Doc) void genericSetObject(Object theValue) throws StandardException(Code)(Java Doc) public boolean getBoolean() throws StandardException(Code)(Java Doc) public byte getByte() throws StandardException(Code)(Java Doc) public byte[] getBytes() throws StandardException(Code)(Java Doc) public Date getDate(Calendar cal) throws StandardException(Code)(Java Doc) public double getDouble() throws StandardException(Code)(Java Doc) public float getFloat() throws StandardException(Code)(Java Doc) public int getInt() throws StandardException(Code)(Java Doc) public long getLong() throws StandardException(Code)(Java Doc) protected String getNationalString(LocaleFinder localeFinder) throws StandardException(Code)(Java Doc) public Object getObject() throws StandardException(Code)(Java Doc) public short getShort() throws StandardException(Code)(Java Doc) public InputStream getStream() throws StandardException(Code)(Java Doc) public Time getTime(Calendar cal) throws StandardException(Code)(Java Doc) public Timestamp getTimestamp(Calendar cal) throws StandardException(Code)(Java Doc) public String getTraceString() throws StandardException(Code)(Java Doc) String getTypeName(String className)(Code)(Java Doc) public BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue greaterThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue in(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList) throws StandardException(Code)(Java Doc) final protected StandardException invalidFormat()(Code)(Java Doc) final public BooleanDataValue isNotNull()(Code)(Java Doc) final public BooleanDataValue isNullOp()(Code)(Java Doc) public BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue lessThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException(Code)(Java Doc) public BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) final protected StandardException outOfRange()(Code)(Java Doc) public void setBigDecimal(Number bigDecimal) throws StandardException(Code)(Java Doc) protected void setFrom(DataValueDescriptor dvd) throws StandardException(Code)(Java Doc) public void setInto(PreparedStatement ps, int position) throws SQLException, StandardException(Code)(Java Doc) public void setInto(ResultSet rs, int position) throws SQLException, StandardException(Code)(Java Doc) void setObject(Object theValue) throws StandardException(Code)(Java Doc) public void setObjectForCast(Object theValue, boolean instanceOfResultType, String resultTypeClassName) throws StandardException(Code)(Java Doc) public void setToNull()(Code)(Java Doc) public void setValue(Time theValue) throws StandardException(Code)(Java Doc) public void setValue(Time theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(Timestamp theValue) throws StandardException(Code)(Java Doc) public void setValue(Timestamp theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(Date theValue) throws StandardException(Code)(Java Doc) public void setValue(Date theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(String theValue) throws StandardException(Code)(Java Doc) public void setValue(int theValue) throws StandardException(Code)(Java Doc) public void setValue(double theValue) throws StandardException(Code)(Java Doc) public void setValue(float theValue) throws StandardException(Code)(Java Doc) public void setValue(short theValue) throws StandardException(Code)(Java Doc) public void setValue(long theValue) throws StandardException(Code)(Java Doc) public void setValue(byte theValue) throws StandardException(Code)(Java Doc) public void setValue(boolean theValue) throws StandardException(Code)(Java Doc) public void setValue(byte[] theValue) throws StandardException(Code)(Java Doc) final public void setValue(DataValueDescriptor dvd) throws StandardException(Code)(Java Doc) public void setValue(InputStream theStream, int valueLength) throws StandardException(Code)(Java Doc) public void throwLangSetMismatch(Object value) throws StandardException(Code)(Java Doc) void throwLangSetMismatch(String argTypeName) throws StandardException(Code)(Java Doc) public int typePrecedence()(Code)(Java Doc) public int typeToBigDecimal() throws StandardException(Code)(Java Doc)
|
|
|