public class IfxDecimal extends IfxObject
Modifier and Type | Field and Description |
---|---|
static short |
BYTEMASK |
static short |
BYTEMASK7 |
static short |
BYTESHIFT |
static short |
BYTESIGNED |
protected byte[] |
dec_dgts
Array of base 100 digits (2 per byte)
|
protected short |
dec_exp
Exponent in base 100
|
protected short |
dec_ndgts
Base 100 digits
|
protected short |
dec_pos
Sign.
|
static short |
DECEXPZERO
indicates ZERO decimal number
|
static short |
DECPOSNEGATIVE
indicates NEGATIVE decimal number
|
static short |
DECPOSNULL
indicates NULL decimal number
|
static short |
DECPOSPOSITIVE
indicates POSITIVE decimal number
|
static int |
DECSIZE
number of bytes allocated for IFX DECIMAL
|
static java.lang.String |
digChar |
conn, extendedID, extendedName, extendedOwner, ifxType, isNull, jdbcType, sourceType, trace, typeMap, used_in_update
Constructor and Description |
---|
IfxDecimal()
Null Decimal constructor
|
IfxDecimal(java.math.BigDecimal n)
Constructs an IfxDecimal given a java.math.BigDecimal
|
IfxDecimal(byte[] b)
Constructs an IfxDecimal given an Informix internal decimal byte array.
|
Modifier and Type | Method and Description |
---|---|
protected void |
computeEncodedLength()
Compute the precision and scale of the value
|
protected static int |
decLength(int length)
Return the storage/network size of this decimal
bases on the encoded length.
|
boolean |
equals(java.lang.Object other)
Find out whether two objects are equal.
|
protected int |
extractExponent(java.lang.String num,
int start)
Given number string checks if it contains an exponent
checking from start char.
|
void |
fromBoolean(boolean val)
Converted to the BigDecimal value.
|
void |
fromBoolean(java.lang.Boolean val)
Convert a Boolean to a BigDecimal value.
|
void |
fromBoolean(java.lang.Boolean val,
int scale) |
void |
fromByte(byte val)
Converted to the BigDecimal value.
|
void |
fromByte(java.lang.Byte val)
Converted from a Byte to a BigDecimal value.
|
void |
fromByte(java.lang.Byte val,
int scale) |
void |
fromDecimal(java.math.BigDecimal val)
Converted to the BigDecimal value.
|
void |
fromDecimal(java.math.BigDecimal val,
int scale) |
void |
fromDecimal(java.math.BigDecimal val,
int scale,
short encodedLength) |
void |
fromDouble(double val)
Converted to the BigDecimal value.
|
void |
fromDouble(java.lang.Double val)
Convert a Double to a BigDecimal value.
|
void |
fromDouble(java.lang.Double val,
int scale) |
void |
fromFloat(float val)
Converted to the BigDecimal value.
|
void |
fromFloat(java.lang.Float val)
Convert a Float to a BigDecimal value.
|
void |
fromFloat(java.lang.Float val,
int scale) |
void |
fromIfx(byte[] b,
int offset,
int length,
short prec)
Convert BigDecimal value from the given Informix network format
|
void |
fromIfx(byte[] b,
short prec)
Convert BigDecimal value from the given Informix network format
|
void |
fromInt(int val)
Converted to the BigDecimal value.
|
void |
fromInt(java.lang.Integer val)
Convert a Integer to a BigDecimal value.
|
void |
fromInt(java.lang.Integer val,
int scale) |
void |
fromLong(long val)
Converted to the BigDecimal value.
|
void |
fromLong(java.lang.Long val)
Convert from a Long to a BigDecimal value.
|
void |
fromLong(java.lang.Long val,
int scale) |
void |
fromShort(short val)
Converted to the BigDecimal value.
|
void |
fromShort(java.lang.Short val)
Convert from a Short to the BigDecimal value.
|
void |
fromShort(java.lang.Short val,
int scale) |
void |
fromString(java.lang.String str)
Convert from String value.
|
void |
fromString(java.lang.String str,
int scale) |
short |
getEncodedLength()
Get the encoded length with precision
|
protected static java.lang.String |
getIfxTypeName(int length)
Given the length of a decimal, return the full decimal
type.
|
int |
getScale() |
protected static int |
precDec(int length)
Return the decimal precision of a decimal type
(digits to right).
|
protected static int |
precTot(int length)
Return the total precision of a decimal type.
|
void |
setEncodedLength(int encodedLength)
Set the encoded length with precision
|
boolean |
toBoolean()
Return the Boolean value of the object.
|
byte |
toByte()
Return the byte value of the object.
|
java.math.BigDecimal |
toDecimal()
Return the BigDecimal value of the object.
|
double |
toDouble()
Return the double value of the object.
|
float |
toFloat()
Return the float value of the object.
|
byte[] |
toIfx()
Convert BigDecimal value into Informix network format
|
byte[] |
toIfxTuple()
Convert BigDecimal value into Informix tuple format
|
int |
toInt()
Return the integer value of the object.
|
long |
toLong()
Return the long value of the object.
|
java.lang.Object |
toObject()
Return IfxDecimal cast as Object.
|
short |
toShort()
Return the short value of the object.
|
java.lang.String |
toString()
Convert value to a string.
|
clear, clearWarning, fromAsciiStream, fromAsciiStream, fromBinaryStream, fromBinaryStream, fromBlob, fromBytes, fromCharacterStream, fromCharacterStream, fromClob, fromDate, fromIfx, fromIfx, fromIfx, fromIfx, fromInputStream, fromInputStream, fromIntervalDF, fromIntervalYM, fromNClob, fromObject, fromObject, fromObject, fromRowId, fromSQLXML, fromString, fromTime, fromTimestamp, get_used_in_update, getWarning, isNull, nullify, set_used_in_update, setConnection, setExtendedTypeName, setIfxType, setTypeMap, toAsciiStream, toBinaryStream, toBlob, toBytes, toCharacterStream, toClob, toDate, toIfxBSONObject, toInputStream, toInterval, toIntervalDF, toIntervalYM, toNClob, toObject, toRowId, toSQLXML, toTime, toTimestamp, toUnloadString, unnullify
protected short dec_exp
protected short dec_pos
protected short dec_ndgts
protected byte[] dec_dgts
public static final java.lang.String digChar
public static final int DECSIZE
public static final short DECPOSNULL
public static final short DECPOSPOSITIVE
public static final short DECPOSNEGATIVE
public static final short DECEXPZERO
public static final short BYTESHIFT
public static final short BYTEMASK
public static final short BYTESIGNED
public static final short BYTEMASK7
public IfxDecimal() throws java.sql.SQLException
java.sql.SQLException
public IfxDecimal(java.math.BigDecimal n) throws java.sql.SQLException
n
- BigDecimal from which equivalent Decimal is createdjava.sql.SQLException
public IfxDecimal(byte[] b) throws java.sql.SQLException
b
- byte from Informix internal decimal datajava.sql.SQLException
public byte[] toIfx()
public byte[] toIfxTuple()
toIfxTuple
in class IfxObject
public void fromIfx(byte[] b, short prec)
public void fromIfx(byte[] b, int offset, int length, short prec)
public java.lang.Object toObject() throws java.sql.SQLException
public byte toByte() throws java.sql.SQLException
public void fromByte(java.lang.Byte val) throws java.sql.SQLException
public void fromByte(java.lang.Byte val, int scale) throws java.sql.SQLException
java.sql.SQLException
public void fromByte(byte val) throws java.sql.SQLException
public short toShort() throws java.sql.SQLException
public void fromShort(java.lang.Short val) throws java.sql.SQLException
public void fromShort(java.lang.Short val, int scale) throws java.sql.SQLException
java.sql.SQLException
public void fromShort(short val) throws java.sql.SQLException
public int toInt() throws java.sql.SQLException
public void fromInt(java.lang.Integer val) throws java.sql.SQLException
public void fromInt(java.lang.Integer val, int scale) throws java.sql.SQLException
java.sql.SQLException
public void fromInt(int val) throws java.sql.SQLException
public long toLong() throws java.sql.SQLException
public void fromLong(java.lang.Long val) throws java.sql.SQLException
public void fromLong(java.lang.Long val, int scale) throws java.sql.SQLException
java.sql.SQLException
public void fromLong(long val) throws java.sql.SQLException
public float toFloat() throws java.sql.SQLException
public void fromFloat(java.lang.Float val) throws java.sql.SQLException
public void fromFloat(java.lang.Float val, int scale) throws java.sql.SQLException
java.sql.SQLException
public void fromFloat(float val) throws java.sql.SQLException
public double toDouble() throws java.sql.SQLException
public void fromDouble(java.lang.Double val) throws java.sql.SQLException
fromDouble
in class IfxObject
val
- the valuejava.sql.SQLException
- if the conversion failedpublic void fromDouble(java.lang.Double val, int scale) throws java.sql.SQLException
java.sql.SQLException
public void fromDouble(double val) throws java.sql.SQLException
fromDouble
in class IfxObject
val
- the valuejava.sql.SQLException
- if the conversion failedpublic java.math.BigDecimal toDecimal() throws java.sql.SQLException
public void fromDecimal(java.math.BigDecimal val) throws java.sql.SQLException
fromDecimal
in class IfxObject
val
- the valuejava.sql.SQLException
- if the conversion failedpublic void fromDecimal(java.math.BigDecimal val, int scale) throws java.sql.SQLException
fromDecimal
in class IfxObject
java.sql.SQLException
public void fromDecimal(java.math.BigDecimal val, int scale, short encodedLength) throws java.sql.SQLException
java.sql.SQLException
public boolean toBoolean() throws java.sql.SQLException
public void fromBoolean(java.lang.Boolean val) throws java.sql.SQLException
fromBoolean
in class IfxObject
val
- the valuejava.sql.SQLException
- if the conversion failedpublic void fromBoolean(java.lang.Boolean val, int scale) throws java.sql.SQLException
java.sql.SQLException
public void fromBoolean(boolean val) throws java.sql.SQLException
fromBoolean
in class IfxObject
val
- the value
if val is false, then set the BigDecimal to 0
otherwise, set it to 1java.sql.SQLException
- if the conversion failedpublic java.lang.String toString()
public void fromString(java.lang.String str) throws java.sql.SQLException
fromString
in class IfxObject
str
- the String valuejava.sql.SQLException
- if the conversion failedpublic void fromString(java.lang.String str, int scale) throws java.sql.SQLException
java.sql.SQLException
public boolean equals(java.lang.Object other)
public int getScale()
public short getEncodedLength()
getEncodedLength
in class IfxObject
public void setEncodedLength(int encodedLength)
protected void computeEncodedLength()
protected int extractExponent(java.lang.String num, int start)
num
- number as a string which may have an exponentstart
- position where to start looking in stringprotected static int precTot(int length)
length
- - the length of the decimal type.protected static int precDec(int length)
length
- - the length of the decimal type.protected static int decLength(int length)
length
- - the length of the decimal type.protected static java.lang.String getIfxTypeName(int length)
length
- - the length of the decimal type.