|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.text.DigitList
Digit List. Private to DecimalFormat. Handles the transcoding between numeric values and strings of characters. Only handles non-negative numbers. The division of labor between DigitList and DecimalFormat is that DigitList handles the radix 10 representation issues; DecimalFormat handles the locale-specific issues such as positive/negative, grouping, decimal point, currency, and so on. A DigitList is really a representation of a floating point value. It may be an integer value; we assume that a double has sufficient precision to represent all digits of a long. The DigitList representation consists of a string of characters, which are the digits radix 10, from '0' to '9'. It also has a radix 10 exponent associated with it. The value represented by a DigitList object can be computed by mulitplying the fraction f, where 0 <= f < 1, derived by placing all the digits of the list to the right of the decimal point, by 10^exponent.
Locale
,
Format
,
NumberFormat
,
DecimalFormat
,
ChoiceFormat
,
MessageFormat
Field Summary | |
int |
count
|
static int |
DBL_DIG
|
int |
decimalAt
These data members are intentionally public and can be set directly. |
char[] |
digits
|
private static char[] |
LONG_MIN_REP
|
static int |
MAX_COUNT
The maximum number of significant digits in an IEEE 754 double, that is, in a Java double. |
private StringBuffer |
tempBuffer
|
Constructor Summary | |
(package private) |
DigitList()
|
Method Summary | |
void |
append(char digit)
Appends a digit to the list. |
void |
clear()
Clears out the digits. |
Object |
clone()
Creates a copy of this object. |
boolean |
equals(Object obj)
equality test between two digit lists. |
(package private) boolean |
fitsIntoLong(boolean isPositive,
boolean ignoreNegativeZero)
Return true if the number represented by this object can fit into a long. |
double |
getDouble()
Utility routine to get the value of the digit list If (count == 0) this throws a NumberFormatException, which mimics Long.parseLong(). |
long |
getLong()
Utility routine to get the value of the digit list. |
private StringBuffer |
getStringBuffer()
|
int |
hashCode()
Generates the hash code for the digit list. |
private boolean |
isLongMIN_VALUE()
Returns true if this DigitList represents Long.MIN_VALUE; false, otherwise. |
(package private) boolean |
isZero()
Return true if the represented number is zero. |
private static int |
parseInt(char[] str,
int offset)
|
private void |
round(int maximumDigits)
Round the representation to the given number of digits. |
void |
set(double source,
int maximumFractionDigits)
Set the digit list to a representation of the given double value. |
(package private) void |
set(double source,
int maximumDigits,
boolean fixedPoint)
Set the digit list to a representation of the given double value. |
void |
set(long source)
Utility routine to set the value of the digit list from a long |
void |
set(long source,
int maximumDigits)
Set the digit list to a representation of the given long value. |
private boolean |
shouldRoundUp(int maximumDigits)
Return true if truncating the representation to the given number of digits will result in an increment to the last digit. |
String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int MAX_COUNT
public static final int DBL_DIG
public int decimalAt
public int count
public char[] digits
private static final char[] LONG_MIN_REP
private StringBuffer tempBuffer
Constructor Detail |
DigitList()
Method Detail |
boolean isZero()
public void clear()
public void append(char digit)
public final double getDouble()
public final long getLong()
boolean fitsIntoLong(boolean isPositive, boolean ignoreNegativeZero)
isPositive
- true if this number should be regarded as positiveignoreNegativeZero
- true if -0 should be regarded as identical to
+0; otherwise they are considered distinct
public final void set(double source, int maximumFractionDigits)
source
- Value to be converted; must not be Inf, -Inf, Nan,
or a value <= 0.maximumFractionDigits
- The most fractional digits which should
be converted.final void set(double source, int maximumDigits, boolean fixedPoint)
source
- Value to be converted; must not be Inf, -Inf, Nan,
or a value <= 0.maximumDigits
- The most fractional or total digits which should
be converted.fixedPoint
- If true, then maximumDigits is the maximum
fractional digits to be converted. If false, total digits.private final void round(int maximumDigits)
maximumDigits
- The maximum number of digits to be shown.
Upon return, count will be less than or equal to maximumDigits.private boolean shouldRoundUp(int maximumDigits)
maximumDigits
- the number of digits to keep, from 0 to
count-1
. If 0, then all digits are rounded away, and
this method returns true if a one should be generated (e.g., formatting
0.09 with "#.#").
maximumDigits-1
should be
incrementedpublic final void set(long source)
public final void set(long source, int maximumDigits)
source
- Value to be converted; must be >= 0 or ==
Long.MIN_VALUE.maximumDigits
- The most digits which should be converted.
If maximumDigits is lower than the number of significant digits
in source, the representation will be rounded. Ignored if <= 0.public boolean equals(Object obj)
equals
in class Object
obj
- the reference object with which to compare.
true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
Hashtable
public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
Hashtable
public Object clone()
clone
in class Object
Cloneable
private boolean isLongMIN_VALUE()
private static final int parseInt(char[] str, int offset)
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString
in class Object
private StringBuffer getStringBuffer()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |