Serializable
, oracle.jdbc.internal.OracleNumber
public class NUMBER extends Datum implements oracle.jdbc.internal.OracleNumber
The NUMBER class provides converisons between the Oracle Number (lnxnum_t) data type and Java types byte[], byte, short, integer, long, float, double, String, BigInteger. and BigDecimal.
The internal data for this object is stored as a byte array in the super class' storage area.
Static methods are used for conversions.
The LNX length included format is not supported. The byte array passed to or returned by any method is assumed to have the proper length accessible by the byte[].length
instance variable.
ojiOracleDatumWithConnection, targetDatum
Constructor | Description |
---|---|
NUMBER() |
Constructs a NUMBER object initialized to zero.
|
NUMBER(boolean boolNum) |
Constructs a Number object initialized to the specified boolean value.
|
NUMBER(byte byteNum) |
Constructs a Number object initialized to the specified byte value.
|
NUMBER(byte[] num) |
Constructs a NUMBER object initialized to the value specified by the byte array.
|
NUMBER(double doubleNum) |
Constructs a Number object initialized to the specified double value.
|
NUMBER(float floatNum) |
Constructs a Number object initialized to the specified float value.
|
NUMBER(int intNum) |
Constructs a Number object initialized to the specified integer value.
|
NUMBER(long longNum) |
Constructs a Number object initialized to the specified long value.
|
NUMBER(short shortNum) |
Constructs a Number object initialized to the specified short value.
|
NUMBER(Object obj) |
Constructs a NUMBER object initialized to the value specified by the object
|
NUMBER(String StringNum, int scale) |
Constructs a NUMBER object initialized to the specified String value.
|
NUMBER(BigDecimal BigDecNum) |
Constructs a NUMBER object initialized to the specified BigDecimal value.
|
NUMBER(BigInteger BigIntNum) |
Constructs a NUMBER object initialized to the specified BigInteger value.
|
Modifier and Type | Method | Description |
---|---|---|
NUMBER |
abs() |
Returns a new NUMBER object initialized to the absolute value of NUMBER.
|
NUMBER |
acos() |
Returns a new NUMBER object initialized to the arc cosine value of NUMBER.
|
NUMBER |
add(NUMBER n) |
Returns a new NUMBER object initialized to the value of the addition of the NUMBER value and n.
|
NUMBER |
asin() |
Returns a new NUMBER object initialized to the arc sine value of NUMBER.
|
NUMBER |
atan() |
Returns a new NUMBER object initialized to the arc tangent value of NUMBER.
|
NUMBER |
atan2(NUMBER x) |
Returns a new NUMBER object initialized to the value of atan2(NUMBER/x).
|
BigDecimal |
bigDecimalValue() |
Calls toBigDecimalto convert internal Oracle Number into a Java BigDecimal.
|
BigInteger |
bigIntegerValue() |
Calls toBigInteger to convert internal Oracle Number to a Java BigInteger.
|
boolean |
booleanValue() |
Calls toBoolean to convert internal Oracle Number to a Java boolean.
|
byte |
byteValue() |
Calls toByte to convert internal Oracle Number to a Java byte.
|
NUMBER |
ceil() |
Returns a new NUMBER object initialized to the ceiling of NUMBER value.
|
int |
compareTo(NUMBER n) |
Returns -1 if NUMBER is less than n, 0 if NUMBER and n are equal (==), 1 if NUMBER is greater than n.
|
NUMBER |
cos() |
Returns a new NUMBER object initialized to the cosine value of NUMBER.
|
NUMBER |
cosh() |
Returns a new NUMBER object initialized to the hyperbolic cosine value of NUMBER.
|
NUMBER |
decrement() |
Returns a new NUMBER object initialized to the NUMBER value decremented by 1.
|
NUMBER |
div(NUMBER n) |
Returns a new NUMBER object initialized to the division of NUMBER value by n.
|
double |
doubleValue() |
Calls toDouble to convert internal Oracle Number to a Java double.
|
static NUMBER |
e() |
Returns a new NUMBER object initialized to the value of e.
|
NUMBER |
exp() |
Returns a new NUMBER object initialized to the value of e raised to NUMBER value.
|
NUMBER |
floatingPointRound(int precision) |
Returns a new NUMBER object initialized to Number rounded to precision significant decimal digits.
|
float |
floatValue() |
Calls toFloat to convert internal Oracle Number to a Java float.
|
NUMBER |
floor() |
Returns a new NUMBER object initialized to the floor of NUMBER value.
|
static NUMBER |
formattedTextToNumber(String num, String fmt, String lang) |
Returns a NUMBER converted from Num controlled by the format fmt.
|
NUMBER |
increment() |
Returns a new NUMBER object initialized to the NUMBER value incremented by 1.
|
int |
intValue() |
Calls toInt to convert internal Oracle Number to a Java int.
|
boolean |
isConvertibleTo(Class cls) |
Determines if the object can be converted to a particular class
|
boolean |
isInf() |
Returns true if NUMBER value is positive or negative infinity and a false otherwise.
|
boolean |
isInt() |
Returns true if NUMBER value is finite and integral.
|
boolean |
isNegInf() |
Returns returns true if NUMBER is negative infinity and false otherwise.
|
boolean |
isPosInf() |
Returns true if NUMBER is positive infinity and false otherwise.
|
static boolean |
isValid(byte[] num) |
Checks if a given Oracle Number is valid
|
boolean |
isZero() |
Returns true if NUMBER is zero.
|
NUMBER |
ln() |
Returns a new NUMBER object initialized to the natural logarithm of the NUMBER value.
|
static NUMBER |
ln10() |
Returns a new NUMBER object initialized to the value of ln(10).
|
NUMBER |
log(NUMBER base) |
Returns a new NUMBER object initialized to the logarithm to the base base of the NUMBER value.
|
long |
longValue() |
Calls toLong to convert internal Oracle Number to a Java long.
|
Object |
makeJdbcArray(int arraySize) |
Returns a JDBC array representation of the datum
|
NUMBER |
mod(NUMBER n) |
Returns a new NUMBER object initialized to the remainder of the division of NUMBER/n.
|
NUMBER |
mul(NUMBER n) |
Returns a new NUMBER object initialized to product of NUMBER and n.
|
NUMBER |
negate() |
Returns a new NUMBER object initialized to the negated NUMBER value.
|
static NUMBER |
negInf() |
Returns a new NUMBER object initialized to negative infinity.
|
static NUMBER |
pi() |
Returns a new NUMBER object initialized to the value of pi.
|
static NUMBER |
posInf() |
Returns a new NUMBER object initialized to positive infinity.
|
NUMBER |
pow(int exp) |
Returns a new NUMBER object initialized to NUMBER value raised to the exp power.
|
NUMBER |
pow(NUMBER exp) |
Returns a new NUMBER object initialized to the value of NUMBER value raised to the exp power.
|
NUMBER |
round(int decimal_place) |
Returns a new NUMBER object initialized to the NUMBER value rounded to specified decimal place decimal_place.
|
NUMBER |
scale(int left, int right, boolean[] big) |
Returns a new NUMBER object initialized to the value determined by the rounding performed based on the right parameter below.
|
NUMBER |
shift(int digits) |
Returns a new NUMBER object initialized the NUMBER value shifted digits decimal places.
|
short |
shortValue() |
Calls toShort to convert internal Oracle Number to a Java short.
|
int |
sign() |
Returns -1 if the sign of NUMBER is negative, 0 if NUMBER is 0, and > 0 if NUMBER is positive.
|
NUMBER |
sin() |
Returns a new NUMBER object initialized to the sine of the NUMBER.
|
NUMBER |
sinh() |
Returns a new NUMBER object initialized to the hyperbolic sine of NUMBER.
|
NUMBER |
sqroot() |
Returns a new NUMBER object initialized to the square root of NUMBER.
|
String |
stringValue() |
Calls toString to convert internal Oracle Number to a Java String.
|
NUMBER |
sub(NUMBER n) |
Returns a new NUMBER object initialized to the difference of NUMBER and n.
|
NUMBER |
tan() |
Returns a new NUMBER object initialized to the tangent of NUMBER.
|
NUMBER |
tanh() |
Returns a new NUMBER object initialized to the hyperbolic tangent of Number.
|
static NUMBER |
textToPrecisionNumber(String num, boolean precflag, int preclen, boolean scaleflag, int scalelen, String lang) |
Returns a NUMBER object initialized to the value in num as described below.
|
static BigDecimal |
toBigDecimal(byte[] num) |
Converts an Oracle Number into a Java BigDecimal.
|
static BigInteger |
toBigInteger(byte[] num) |
Converts an Oracle Number into a Java BigInteger.
|
static boolean |
toBoolean(byte[] num) |
Convert an Oracle Number to a Java boolean.
|
static byte |
toByte(byte[] num) |
Converts an Oracle Number into a Java byte.
|
byte[] |
toBytes() |
Returns the internal Oracle Number byte array.
|
static byte[] |
toBytes(boolean boolNum) |
Converts a Java boolean to an Oracle Number byte array.
|
static byte[] |
toBytes(byte byteNum) |
Converts a Java byte to an Oracle Number byte array.
|
static byte[] |
toBytes(double doubleNum) |
Converts a Java double to an Oracle Number byte array.
|
static byte[] |
toBytes(float floatNum) |
Converts a Java float to an Oracle Number byte array.
|
static byte[] |
toBytes(int intNum) |
Converts a Java int to an Oracle Number byte array.
|
static byte[] |
toBytes(long longNum) |
Converts a Java long to an Oracle Number byte array.
|
static byte[] |
toBytes(short shortNum) |
Converts a Java short to an Oracle Number byte array.
|
static byte[] |
toBytes(String StringNum, int scale) |
Converts a Java String to an Oracle Number byte array.
|
static byte[] |
toBytes(BigDecimal BigDecNum) |
Converts a Java BigDecimal to an Oracle Number byte array.
|
static byte[] |
toBytes(BigInteger BigIntNum) |
Converts a Java BigInteger to an Oracle Number byte array.
|
static double |
toDouble(byte[] num) |
Converts an Oracle Number into a Java double.
|
static float |
toFloat(byte[] num) |
Converts an Oracle Number into a Java float.
|
String |
toFormattedText(String fmt, String lang) |
Returns a new String based on the format specified in fmt and NUMBER.
|
static int |
toInt(byte[] num) |
Converts an Oracle Number into a Java int.
|
Object |
toJdbc() |
Returns the JDBC representation of the datum object
|
static long |
toLong(byte[] num) |
Converts an Oracle Number into a Java long.
|
static short |
toShort(byte[] num) |
Converts an Oracle Number into a Java xemacs short.
|
static String |
toString(byte[] num) |
Convert an Oracle Number to a Java String.
|
String |
toText(int outStringLength, String lang) |
Returns a String with the unformatted representation of NUMBER.
|
NUMBER |
truncate(int decimal_place) |
Returns a new NUMBER object initialized to the NUMBER value truncated to specified decimal place decimal_place.
|
static NUMBER |
zero() |
Returns a new NUMBER object initialized to zero.
|
asciiStreamValue, binaryStreamValue, bytesEqual, bytesHashCode, characterStreamValue, compareBytes, dateValue, equals, getBytes, getConnectionDuringExceptionHandling, getLength, getStream, isNull, setBytes, setShareBytes, shareBytes, stringValue, timestampValue, timestampValue, timeValue, timeValue, toClass
public NUMBER()
public NUMBER(byte[] num)
a.length
is the length of the Oracle Number in bytes.num
- Oracle Number in byte array formatpublic NUMBER(byte byteNum)
byteNum
- The Java byte valuepublic NUMBER(int intNum)
intNum
- The Java integer valuepublic NUMBER(long longNum)
longNum
- The Java long valuepublic NUMBER(short shortNum)
shortNum
- The Java short valuepublic NUMBER(float floatNum)
floatNum
- The Java float valuepublic NUMBER(double doubleNum) throws SQLException
doubleNum
- The Java double valueSQLException
- on over/underflow of the Oracle Number exponent and on overflow of the mantissa.public NUMBER(BigDecimal BigDecNum) throws SQLException
Since there doesn't seem to be a way to represent +-inf using a BigDecimal this condition isn't considered.
Notes:
BigDecNum
- The BigDecimal used to initialize NUMBER.SQLException
- on over/underflow of the Oracle Number exponent and on overflow of the mantissa.public NUMBER(BigInteger BigIntNum) throws SQLException
BigIntNum
- The Java BigInteger from which to construct the Oracle number.SQLException
- on overflow of the Oracle Number exponent and on overflow of the mantissa.public NUMBER(String StringNum, int scale) throws SQLException
StringNum
- The Java String from which to construct the Oracle number.scale
- scale to useSQLException
- on over/underflow of the Oracle Number exponent and on overflow of the mantissa.public NUMBER(boolean boolNum)
boolNum
- The Java boolean valuepublic NUMBER(Object obj) throws SQLException
obj
- Object valueSQLException
- if initialization is not allowedpublic static double toDouble(byte[] num)
num
- Oracle Number in byte array formatpublic static float toFloat(byte[] num)
num
- Oracle Number in byte array formatpublic static long toLong(byte[] num) throws SQLException
num
- Oracle Number in byte array formatSQLException
- if the Oracle Number exponent is out of range.public static int toInt(byte[] num) throws SQLException
num
- Oracle Number in byte array formatSQLException
- if the Oracle Number exponent is out of range.public static short toShort(byte[] num) throws SQLException
num
- Oracle Number in byte array formatSQLException
- if the Oracle Number exponent is out of range.public static byte toByte(byte[] num) throws SQLException
num
- Oracle Number in byte array formatSQLException
- if the Oracle Number exponent is out of range.public static BigInteger toBigInteger(byte[] num) throws SQLException
num
- Oracle Number in byte array formatSQLException
- if the Oracle Number exponent is out of range.public static BigDecimal toBigDecimal(byte[] num) throws SQLException
num
- Oracle Number in byte array formatSQLException
- on over/underflow of the Oracle Number exponent and on overflow of the mantissa.public static String toString(byte[] num)
num
- Oracle Number in byte array formatpublic static boolean toBoolean(byte[] num)
false
and non-zero values translate to true
,num
- Oracle Number in byte array formatpublic static byte[] toBytes(double doubleNum) throws SQLException
doubleNum
- Java double valuelength
instance variable holds Oracle Number length in bytes.SQLException
- on over/underflow of the Oracle Number exponent and on overflow of the mantissa.public static byte[] toBytes(float floatNum)
floatNum
- Java float valuelength
instance variable holds Oracle Number length in bytes.public static byte[] toBytes(long longNum)
longNum
- Java long valuelength
instance variable holds Oracle Number length in bytes.public static byte[] toBytes(int intNum)
intNum
- Java int valuelength
instance variable holds Oracle Number length in bytes.public static byte[] toBytes(short shortNum)
shortNum
- Java short valuelength
instance variable holds Oracle Number length in bytes.public static byte[] toBytes(byte byteNum)
byteNum
- Java byte valuelength
instance variable holds Oracle Number length in bytes.public static byte[] toBytes(BigInteger BigIntNum) throws SQLException
BigIntNum
- Java BigInteger valuelength
instance variable holds Oracle Number length in bytes.SQLException
- will be thrown if the Oracle Number exponent or mantissa overflows.public static byte[] toBytes(BigDecimal BigDecNum) throws SQLException
BigDecNum
- Java BigDecimal valuelength
instance variable holds Oracle Number length in bytes.SQLException
- on overflow/underflow of the Oracle Number exponent or mantissa.public static byte[] toBytes(String StringNum, int scale) throws SQLException
Notes:
StringNum
- Java String valuescale
- scale to uselength
instance variable holds Oracle Number length in bytes.SQLException
- on over/underflow of the Oracle Number exponentpublic static byte[] toBytes(boolean boolNum)
true
value translates to 1 and a false
value translates to 0.boolNum
- Java boolean valuelength
instance variable holds Oracle Number length in bytes.public byte[] toBytes()
toBytes
in interface oracle.jdbc.internal.OracleNumber
length
instance variable holds Oracle Number length in bytes.public double doubleValue()
doubleValue
in class Datum
public float floatValue()
floatValue
in class Datum
public long longValue() throws SQLException
longValue
in class Datum
SQLException
- if the Oracle Number exponent is out of range.public int intValue() throws SQLException
intValue
in class Datum
SQLException
- if the Oracle Number exponent is out of range.public short shortValue() throws SQLException
SQLException
- if the Oracle Number exponent is out of range.public byte byteValue() throws SQLException
byteValue
in class Datum
SQLException
- if the Oracle Number exponent is out of range.public BigInteger bigIntegerValue() throws SQLException
SQLException
- if the Oracle Number exponent is out of range.public BigDecimal bigDecimalValue() throws SQLException
bigDecimalValue
in class Datum
SQLException
- on over/underflow of the Oracle Number exponent and on overflow of the mantissa.public String stringValue()
stringValue
in interface oracle.jdbc.internal.OracleNumber
stringValue
in class Datum
public boolean booleanValue()
booleanValue
in class Datum
public Object toJdbc() throws SQLException
toJdbc
in class Datum
SQLException
- if conversion to JDBC representation results in an errorpublic Object makeJdbcArray(int arraySize)
makeJdbcArray
in class Datum
arraySize
- size of the arraySQLException
- if conversion to JDBC array representation results in an errorpublic boolean isConvertibleTo(Class cls)
isConvertibleTo
in class Datum
cls
- Class to convert topublic NUMBER abs() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER acos() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER add(NUMBER n) throws SQLException
n
- input Oracle NumberSQLException
- if Java implementation is not availablepublic NUMBER asin() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER atan() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER atan2(NUMBER x) throws SQLException
x
- input Oracle NumberSQLException
- if Java implementation is not availablepublic NUMBER ceil() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER cos() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER cosh() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER decrement() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER div(NUMBER n) throws SQLException
n
- input Oracle NumberSQLException
- if Java implementation is not availablepublic NUMBER exp() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER floatingPointRound(int precision) throws SQLException
precision
- input precisionSQLException
- if Java implementation is not availablepublic NUMBER floor() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER increment() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER ln() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER log(NUMBER base) throws SQLException
base
- Base for calculating logarithmSQLException
- if Java implementation is not availablepublic NUMBER mod(NUMBER n) throws SQLException
n
- input Oracle NumberSQLException
- if Java implementation is not availablepublic NUMBER mul(NUMBER n) throws SQLException
n
- input Oracle NumberSQLException
- if Java implementation is not availablepublic NUMBER negate() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER pow(NUMBER exp) throws SQLException
exp
- input Oracle Number exponentSQLException
- if Java implementation is not availablepublic NUMBER pow(int exp) throws SQLException
exp
- input integral exponentSQLException
- if Java implementation is not availablepublic NUMBER round(int decimal_place) throws SQLException
decimal_place
- decimal place to round toSQLException
- if Java implementation is not availablepublic NUMBER scale(int left, int right, boolean[] big) throws SQLException
left
- maximum number of decimal digits to the left of the decimal point. It will not effect the number but big will return true if this value is exceeded.right
- maximum number of decimal digits to the right of the decimal point. The number is rounded at this point. Negative values are allowed.big
- set to true if the number of left-hand-side digits is exceeded and false otherwise. If big is null, it is left unset.SQLException
- if Java implementation is not availablepublic NUMBER shift(int digits) throws SQLException
digits
- number of decimal places to shift. Can be negative. Positive values shift the decimal place to the right and negative values to the left. For example, if NUMBER corresponds to 1234.5 and digits == -1, the new NUMBER object will correspond to 123.45.SQLException
- if Java implementation is not availablepublic NUMBER sin() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER sinh() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER sqroot() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER sub(NUMBER n) throws SQLException
n
- input Oracle NumberSQLException
- if Java implementation is not availablepublic NUMBER tan() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER tanh() throws SQLException
SQLException
- if Java implementation is not availablepublic NUMBER truncate(int decimal_place) throws SQLException
decimal_place
- decimal place to truncate toSQLException
- if Java implementation is not availablepublic static NUMBER formattedTextToNumber(String num, String fmt, String lang) throws SQLException
num
- input string representing a numeric valuefmt
- format string [see "Oracle 8 Server Concepts Manual" or "CORE User's Guide Appendix D"]lang
- the NLS language the conversion is to be performed in, null indicates use default.SQLException
- if Java implementation is not availablepublic static NUMBER textToPrecisionNumber(String num, boolean precflag, int preclen, boolean scaleflag, int scalelen, String lang) throws SQLException
num
- input string representing a numeric valueprecflag
- if true, then a precision restriction should be appliedpreclen
- the maximum number of the decimal digits the NUMBER may have, subject to the scale requirement. The number is NOT rounded if more than preclen decimal digits must be placed in the number to meet the scale requirement. ncp is set to 0 if the precision restriction is violated. preclen is ignored if precflag is false.scaleflag
- if true then scale restriction should be appliedscalelen
- the maximum number of decimal digits to the right of the decimal point in the NUMBER Negative values are allowed. Any excess digits are rounded off, this is not reported. If enough digits are available in the input, the maximum digits will be written to the right of the decimal place even if the percussion restriction is violated. scalelen is ignored if scaleflag is false. if precision is specified but scale is not, the scale is assumed to be 0.lang
- the NLS language the conversion is to be performed in, null indicates use default.SQLException
- if Java implementation is not availablepublic String toFormattedText(String fmt, String lang) throws SQLException
For pure Java implementation only Notes:
fmt
- format string [see "Oracle 8 Server Concepts Manual" or "CORE User's Guide Appendix D"]lang
- the NLS language the conversion is to be performed in, null indicates use default.SQLException
public String toText(int outStringLength, String lang) throws SQLException
outStringLength
- |outStringLength| is the length of the result string. If outStringLength < 0, the result string is in scientific notation.lang
- the NLS language the conversion is to be performed in, null indicates use default.SQLException
- if Java implementation is not availablepublic int compareTo(NUMBER n)
n
- input Oracle Numberpublic boolean isInf()
public boolean isNegInf()
public boolean isPosInf()
public boolean isInt()
public static boolean isValid(byte[] num)
num
- input Oracle Numberpublic boolean isZero()
public static NUMBER e()
public static NUMBER ln10()
public static NUMBER negInf()
public static NUMBER pi()
public static NUMBER posInf()
public static NUMBER zero()
public int sign()