|
BEA Systems, Inc. | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Number
weblogic.wtc.jatmi.Decimal
This class provides a Java implementation of the Tuxedo packed decimal
type. Packed decimals appear only in Tuxedo View buffers. The class
methods provide convenience routines to create packed decimals from
Strings and numbers and to convert a packed decimal object
to a String or number. A Decimal
encodes a number as
an array of bytes in base-100 and a signed exponent (-64 to +63).
The byte array is of fixed size with the implied decimal point to the
left of the first byte. The exponent represents powers of 100. A special
exponent value DECPOSNULL
indicates a Decimal
with null (undefined) value.
Field Summary | |
static int |
DECPOSNULL
Exponent value indicating a null Decimal , i.e., a Decimal
with undefined value. |
static int |
DECSIZE
Size of the array of bytes representing the digits of the Decimal . |
Constructor Summary | |
Decimal()
Constructs a newly allocated Decimal object with null value. |
|
Decimal(byte bval)
Constructs a newly allocated Decimal object from a
byte value. |
|
Decimal(double value)
Constructs a newly allocated Decimal object from a double value. |
|
Decimal(float value)
Constructs a newly allocated Decimal object from a float value. |
|
Decimal(int ival)
Constructs a newly allocated Decimal object from an
int value. |
|
Decimal(int sign,
int exponent,
int numDigits,
byte[] digits)
Constructs a newly allocated Decimal object using the values
specified by its parameters. |
|
Decimal(long lval)
Constructs a newly allocated Decimal object from a
long value. |
|
Decimal(short sval)
Constructs a newly allocated Decimal object from a
short value. |
|
Decimal(String str)
Constructs a newly allocated Decimal object from a String value. |
Method Summary | |
byte |
byteValue()
Converts the Decimal to a byte value. |
int |
compareTo(Decimal other)
Compares two Decimal objects numerically. |
int |
compareTo(Object other)
Compares this Decimal object to another object. |
byte[] |
digits()
Returns the actual decimal digits. |
double |
doubleValue()
Converts the Decimal to a double value. |
boolean |
equals(Object obj)
Compares this object to another object. |
int |
exponent()
Returns the exponent of the Decimal value. |
float |
floatValue()
Converts the Decimal to a float value. |
int |
intValue()
Converts the Decimal to an int value. |
long |
longValue()
Converts the Decimal to a long value. |
Decimal |
negate()
Creates a newly allocated Decimal whose value is (-this ). |
int |
numDigits()
Returns the number of significant digits in the Decimal value. |
short |
shortValue()
Converts the Decimal to a short value. |
int |
sign()
Returns the sign of the Decimal value. |
String |
toString()
Converts the Decimal to a String . |
static String |
toString(Decimal dec)
Converts the input Decimal to a String . |
static Decimal |
valueOf(String s)
Constructs a newly allocated Decimal object from a String value. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.lang.Comparable |
compareTo |
Field Detail |
public static final int DECPOSNULL
Decimal
, i.e., a Decimal
with undefined value. Null Decimals cannot be compared numerically
with other Decimals.
public static final int DECSIZE
Decimal
.
Constructor Detail |
public Decimal()
Decimal
object with null value.
The sign of the object is set to DECPOSNULL
.
DECPOSNULL
public Decimal(byte bval)
Decimal
object from a
byte
value.
public Decimal(double value) throws NumberFormatException
Decimal
object from a double
value.
NumberFormatException
- if the value would overflow or
underflow when converted to Decimal
or if the value
represents a NaN or infinity.public Decimal(float value) throws NumberFormatException
Decimal
object from a float
value.
NumberFormatException
- if the value represents a NaN or infinity.public Decimal(int ival)
Decimal
object from an
int
value.
public Decimal(int sign, int exponent, int numDigits, byte[] digits)
Decimal
object using the values
specified by its parameters.
NumberFormatException
- if any of the input parameters do not
obey the described constraintsDECPOSNULL
,
DECSIZE
public Decimal(long lval)
Decimal
object from a
long
value.
public Decimal(short sval)
Decimal
object from a
short
value.
public Decimal(String str) throws NumberFormatException
Decimal
object from a String
value. The String
is converted to a Decimal
value as if by the valueOf
method.
NumberFormatException
- if the value is in the wrong format or
would overflow or underflow when converted to Decimal.valueOf(String)
Method Detail |
public byte byteValue() throws NumberFormatException
Decimal
to a byte
value.
byte
value representing the Decimal
. If
the Decimal
has a null value, Byte.MIN_VALUE
is returned.
NumberFormatException
- if the Decimal
value cannot be
represented as a byte
.public int compareTo(Decimal other) throws NumberFormatException
Decimal
objects numerically. Neither
object can have a null value.
other
- a Decimal
that is compared against this
object.
NumberFormatException
- if either of the objects has a null value,
that is, if their exponent is equal to DECPOSNULL
.DECPOSNULL
public int compareTo(Object other) throws NumberFormatException
Decimal
object to another object. If the
other object is a Decimal
, this function behaves like
compareTo(Decimal)
. Otherwise, it throws a ClassCastException
.
ClassCastException
- if obj is not a Decimal
NumberFormatException
- if either of the objects has a null value,
that is, if their exponent is equal to DECPOSNULL
.DECPOSNULL
public byte[] digits()
public double doubleValue()
Decimal
to a double
value.
double
value representing the Decimal
. If
the Decimal
has a null value, Double.MIN_VALUE
is returned.public boolean equals(Object obj)
Decimal
object with the same value as the current object. The values are
equal if the objects have identical bit patterns. Note that null
valued Decimals may be compared in this operation
(unlike compareTo(Decimal)
).
obj
- the other object to compare
Decimal
with the same value as the current object.public int exponent()
Decimal
value. The exponent
represents powers of 100.
public float floatValue() throws NumberFormatException
Decimal
to a float
value.
float
value representing the Decimal
. If
the Decimal
has a null value, Float.MIN_VALUE
is returned.
NumberFormatException
- if the Decimal
value would cause overflow
when converted to a float
.public int intValue() throws NumberFormatException
Decimal
to an int
value.
int
value representing the Decimal
. If
the Decimal
has a null value, Integer.MIN_VALUE
is returned.
NumberFormatException
- if the Decimal
value cannot be
represented as an int
.public long longValue() throws NumberFormatException
Decimal
to a long
value.
long
value representing the Decimal
. If
the Decimal
has a null value, Long.MIN_VALUE
is returned.
NumberFormatException
- if the Decimal
value cannot be
represented as a long
.public Decimal negate()
Decimal
whose value is (-this
).
Decimal
whose value is (-this
). If the original Decimal
has a null value, that is, its sign is DECPOSNULL
, a new null Decimal
is returned.DECPOSNULL
public int numDigits()
Decimal
value.
Decimal
value.public short shortValue() throws NumberFormatException
Decimal
to a short
value.
short
value representing the Decimal
. If
the Decimal
has a null value, Short.MIN_VALUE
is returned.
NumberFormatException
- if the Decimal
value cannot be
represented as a short
.public int sign()
Decimal
value.
DECPOSNULL
a null value.DECPOSNULL
public String toString() throws NumberFormatException
Decimal
to a String
. The String
is
in the format that the Java Double.toString
method would
generate for an equivalent double
value.
String
value representing the Decimal
.
NumberFormatException
- if the Decimal
value cannot be
represented as a double
.public static String toString(Decimal dec) throws NumberFormatException
Decimal
to a String
. The String
is
in the format that the Java Double.toString
method would
generate for an equivalent double
value.
dec
- the Decimal
object to convert.
String
value representing the Decimal
.
NumberFormatException
- if the Decimal
value cannot be
represented as a double
.public static Decimal valueOf(String s) throws NumberFormatException
Decimal
object from a String
value. The String
is converted to a Decimal
value. The String
must be in the format accepted
by the Java Double.parseDouble
method.
NumberFormatException
- if the value is in the wrong format or
would overflow or underflow when converted to Decimal
.
|
Documentation is available at http://download.oracle.com/docs/cd/E13222_01/wls/docs90 Copyright 2005 BEA Systems Inc. |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |