Package org.apache.derby.iapi.types
Interface NumberDataValue
- All Superinterfaces:
DataValueDescriptor
,Externalizable
,Formatable
,Orderable
,Serializable
,Storable
,TypedFormat
- All Known Implementing Classes:
NumberDataType
,SQLDecimal
,SQLDouble
,SQLInteger
,SQLLongint
,SQLReal
,SQLSmallint
,SQLTinyint
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
The minimum scale when dividing DecimalsFields 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
-
Method Summary
Modifier and TypeMethodDescriptionabsolute
(NumberDataValue result) The SQL ABSOLUTE operator.divide
(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) The SQL / operator.divide
(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result, int scale) The SQL / operator.minus
(NumberDataValue result) The SQL unary - operator.minus
(NumberDataValue left, NumberDataValue right, NumberDataValue result) The SQL - operator.mod
(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) The SQL mod operator.plus
(NumberDataValue addend1, NumberDataValue addend2, NumberDataValue result) The SQL + operator.void
Set the value of this NumberDataValue to the given value.sqrt
(NumberDataValue result) The SQL SQRT operator.times
(NumberDataValue left, NumberDataValue right, NumberDataValue result) The SQL * operator.Methods inherited from interface org.apache.derby.iapi.types.DataValueDescriptor
checkHostVariable, cloneHolder, cloneValue, coalesce, compare, compare, compare, compare, equals, estimateMemoryUsage, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLength, getLong, getNewNull, getObject, getShort, getStream, getString, getTime, getTimestamp, getTraceString, getTypeName, greaterOrEquals, greaterThan, hasStream, in, isNotNull, isNullOp, lessOrEquals, lessThan, normalize, notEquals, readExternalFromArray, recycle, setBigDecimal, setInto, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueFromResultSet, typePrecedence, typeToBigDecimal
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
Methods inherited from interface org.apache.derby.iapi.services.io.Storable
isNull, restoreToNull
Methods inherited from interface org.apache.derby.iapi.services.io.TypedFormat
getTypeFormatId
-
Field Details
-
MIN_DECIMAL_DIVIDE_SCALE
static final int MIN_DECIMAL_DIVIDE_SCALEThe minimum scale when dividing Decimals- See Also:
-
MAX_DECIMAL_PRECISION_SCALE
static final int MAX_DECIMAL_PRECISION_SCALE- See Also:
-
-
Method Details
-
plus
NumberDataValue plus(NumberDataValue addend1, NumberDataValue addend2, NumberDataValue result) throws StandardException The SQL + operator.- Parameters:
addend1
- One of the addendsaddend2
- The other addendresult
- The result of the previous call to this method, null if not called yet.- Returns:
- The sum of the two addends
- Throws:
StandardException
- Thrown on error, if result is non-null then its value will be unchanged.
-
minus
NumberDataValue minus(NumberDataValue left, NumberDataValue right, NumberDataValue result) throws StandardException The SQL - operator.- Parameters:
left
- The left operandright
- The right operandresult
- The result of the previous call to this method, null if not called yet.- Returns:
- left - right
- Throws:
StandardException
- Thrown on error, if result is non-null then its value will be unchanged.
-
times
NumberDataValue times(NumberDataValue left, NumberDataValue right, NumberDataValue result) throws StandardException The SQL * operator.- Parameters:
left
- The left operandright
- The right operandresult
- The result of the previous call to this method, null if not called yet.- Returns:
- left * right
- Throws:
StandardException
- Thrown on error, if result is non-null then its value will be unchanged.
-
divide
NumberDataValue divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) throws StandardException The SQL / operator.- Parameters:
dividend
- The numeratordivisor
- The denominatorresult
- The result of the previous call to this method, null if not called yet.- Returns:
- dividend / divisor
- Throws:
StandardException
- Thrown on error, if result is non-null then its value will be unchanged.
-
divide
NumberDataValue divide(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result, int scale) throws StandardException The SQL / operator.- Parameters:
dividend
- The numeratordivisor
- The denominatorresult
- The result of the previous call to this method, null if not called yet.scale
- The scale of the result, for decimal type. If pass in value < 0, can calculate it dynamically.- Returns:
- dividend / divisor
- Throws:
StandardException
- Thrown on error, if result is non-null then its value will be unchanged.
-
mod
NumberDataValue mod(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) throws StandardException The SQL mod operator.- Parameters:
dividend
- The numeratordivisor
- The denominatorresult
- The result of the previous call to this method, null if not called yet.- Returns:
- dividend / divisor
- Throws:
StandardException
- Thrown on error, if result is non-null then its value will be unchanged.
-
minus
The SQL unary - operator. Negates this NumberDataValue.- Parameters:
result
- The result of the previous call to this method, null if not called yet.- Returns:
- - operand
- Throws:
StandardException
- Thrown on error, if result is non-null then its value will be unchanged.
-
absolute
The SQL ABSOLUTE operator. Absolute value of this NumberDataValue.- Parameters:
result
- The result of the previous call to this method, null if not called yet.- Throws:
StandardException
- Thrown on error, if result is non-null then its value will be unchanged.
-
sqrt
The SQL SQRT operator. Sqrt value of this NumberDataValue.- Parameters:
result
- The result of the previous call to this method, null if not call yet.- Throws:
StandardException
- Thrown on error (a negative number), if result is non-null then its value will be unchanged.
-
setValue
Set the value of this NumberDataValue to the given value. This is only intended to be called when mapping values from the Java space into the SQL space, e.g. parameters and return types from procedures and functions. Each specific type is only expected to handle the explicit type according the JDBC.- SMALLINT from java.lang.Integer
- INTEGER from java.lang.Integer
- LONG from java.lang.Long
- FLOAT from java.lang.Float
- DOUBLE from java.lang.Double
- DECIMAL from java.math.BigDecimal
- Parameters:
theValue
- An Number containing the value to set this NumberDataValue to. Null means set the value to SQL null.- Throws:
StandardException
-