| java.lang.Object org.apache.derby.iapi.types.DataType org.apache.derby.iapi.types.NumberDataType org.apache.derby.iapi.types.SQLDecimal
SQLDecimal | final public class SQLDecimal extends NumberDataType implements VariableSizeDataValue(Code) | | SQLDecimal satisfies the DataValueDescriptor
interfaces (i.e., OrderableDataType). It implements a numeric/decimal column,
e.g. for * storing a column value; it can be specified
when constructed to not allow nulls. Nullability cannot be changed
after construction, as it affects the storage size and mechanism.
Because OrderableDataType is a subtype of DataType,
SQLDecimal can play a role in either a DataType/Row
or a OrderableDataType/Row, interchangeably.
We assume the store has a flag for nullness of the value,
and simply return a 0-length array for the stored form
when the value is null.
author: jamie |
Method Summary | |
public NumberDataValue | divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) | public NumberDataValue | divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result, int scale) | public int | estimateMemoryUsage() | public static BigDecimal | getBigDecimal(DataValueDescriptor value) | public boolean | getBoolean() | public byte | getByte() | public DataValueDescriptor | getClone() | public int | getDecimalValuePrecision() Return the SQL scale of this value, number of digits after the
decimal point, or zero for a whole number. | public int | getDecimalValueScale() Return the SQL scale of this value, number of digits after the
decimal point, or zero for a whole number. | public double | getDouble() If we have a value that is greater than the maximum double,
exception is thrown. | public float | getFloat() | public int | getInt() | public int | getLength() | public long | getLong() | public DataValueDescriptor | getNewNull() | public Object | getObject() | public short | getShort() | public String | getString() | public int | getTypeFormatId() Return my format identifier. | public String | getTypeName() | public int | hashCode() | protected boolean | isNegative() This method implements the isNegative method.
A boolean. | public boolean | isNull() | public NumberDataValue | minus(NumberDataValue left, NumberDataValue right, NumberDataValue result) This method implements the - operator for "decimal - decimal". | public NumberDataValue | minus(NumberDataValue result) This method implements the unary minus operator for double. | public void | normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) Normalization method - this method may be called when putting
a value into a SQLDecimal, for example, when inserting into a SQLDecimal
column. | public NumberDataValue | plus(NumberDataValue addend1, NumberDataValue addend2, NumberDataValue result) This method implements the + operator for DECIMAL. | public void | readExternal(ObjectInput in) Note the use of rawData: 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() | public void | setBigDecimal(Number theValue) Only to be called when the application sets a value using BigDecimal
through setBigDecimal calls. | protected void | setFrom(DataValueDescriptor theValue) | final public void | setInto(PreparedStatement ps, int position) Set the value into a PreparedStatement. | void | setObject(Object theValue) Set the value from a correctly typed BigDecimal object. | public void | setValue(String theValue) WARNING there is no checking to make sure
that theValue doesn't exceed the precision/scale of
the current SQLDecimal. | public void | setValue(double theValue) | public void | setValue(float theValue) | public void | setValue(long theValue) | public void | setValue(int theValue) | public void | setValue(Number theValue) Called when setting a DECIMAL value internally or from
through a procedure or function. | public void | setValue(boolean theValue) | public void | setValueFromResultSet(ResultSet resultSet, int colNumber, boolean isNullable) | public void | setWidth(int desiredPrecision, int desiredScale, boolean errorOnTrunc) Set the precision/scale of the to the desired values. | public NumberDataValue | times(NumberDataValue left, NumberDataValue right, NumberDataValue result) This method implements the * operator for "double * double". | public String | toString() | protected int | typeCompare(DataValueDescriptor arg) | public int | typePrecedence() | public int | typeToBigDecimal() DECIMAL implementation. | public void | writeExternal(ObjectOutput out) |
SQLDecimal | public SQLDecimal()(Code) | | no-arg constructor, required by Formattable
|
divide | 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) | | |
getBoolean | public boolean getBoolean()(Code) | | |
getDecimalValuePrecision | public int getDecimalValuePrecision()(Code) | | Return the SQL scale of this value, number of digits after the
decimal point, or zero for a whole number. This does not match the
return from BigDecimal.scale() since in J2SE 5.0 onwards that can return
negative scales.
|
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. This does not match the
return from BigDecimal.scale() since in J2SE 5.0 onwards that can return
negative scales.
|
getDouble | public double getDouble() throws StandardException(Code) | | If we have a value that is greater than the maximum double,
exception is thrown. Otherwise, ok. If the value is less
than can be represented by a double, ti will get set to
the smallest double value.
exception: StandardException - thrown on failure to convert |
getLength | public int getLength()(Code) | | |
hashCode | public int hashCode()(Code) | | |
isNegative | protected boolean isNegative()(Code) | | This method implements the isNegative method.
A boolean. If this.value is negative, return true.For positive values or null, return false. |
normalize | public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException(Code) | | Normalization method - this method may be called when putting
a value into a SQLDecimal, for example, when inserting into a SQLDecimal
column. See NormalizeResultSet in execution.
Note that truncation is allowed on the decimal portion
of a numeric only.
Parameters: desiredType - The type to normalize the source column to Parameters: source - The value to normalize throws: StandardException - Thrown for null intonon-nullable column, and fortruncation error |
setBigDecimal | public void setBigDecimal(Number theValue) throws StandardException(Code) | | Only to be called when the application sets a value using BigDecimal
through setBigDecimal calls.
|
setValue | public void setValue(String theValue) throws StandardException(Code) | | WARNING there is no checking to make sure
that theValue doesn't exceed the precision/scale of
the current SQLDecimal. It is just assumed that the
SQLDecimal is supposed to take the precision/scale of
the BigDecimalized String.
exception: StandardException - throws NumberFormatExceptionwhen the String format is not recognized. |
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.
|
setWidth | public void setWidth(int desiredPrecision, int desiredScale, boolean errorOnTrunc) throws StandardException(Code) | | Set the precision/scale of the to the desired values.
Used when CASTing. Ideally we'd recycle normalize(), but
the use is different.
Parameters: desiredPrecision - the desired precision -- IGNORE_PREICISIONif it is to be ignored. Parameters: desiredScale - the desired scale Parameters: errorOnTrunc - throw error on truncation (ignored -- always thrown if we truncate the non-decimal part ofthe value) exception: StandardException - Thrown on non-zero truncationif errorOnTrunc is true |
typeToBigDecimal | public int typeToBigDecimal()(Code) | | DECIMAL implementation. Convert to a BigDecimal using getObject
which will return a BigDecimal
|
writeExternal | public void writeExternal(ObjectOutput out) throws IOException(Code) | | Distill the BigDecimal to a byte array and
write out:
- scale (zero or positive) as a byte
- length of byte array as a byte
- 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)
|
|
|