|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.text.Format
java.text.NumberFormat
java.text.ChoiceFormat
public class ChoiceFormat
ChoiceFormat is used to associate strings with ranges of double values. The strings and ranges are either specified using arrays or with a pattern which is parsed to determine the Strings and ranges.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.text.NumberFormat |
|---|
NumberFormat.Field |
| Field Summary |
|---|
| Fields inherited from class java.text.NumberFormat |
|---|
FRACTION_FIELD, INTEGER_FIELD |
| Constructor Summary | |
|---|---|
ChoiceFormat(double[] limits,
String[] formats)
Constructs a new ChoiceFormat with the specified ranges and associated strings. |
|
ChoiceFormat(String template)
Constructs a new ChoiceFormat with the strings and ranges parsed from the specified pattern. |
|
| Method Summary | |
|---|---|
void |
applyPattern(String template)
Parses the pattern to determine new strings and ranges for this ChoiceFormat. |
Object |
clone()
Returns a new instance of ChoiceFormat with the same ranges and strings as this ChoiceFormat. |
boolean |
equals(Object object)
Compares the specified object to this ChoiceFormat and answer if they are equal. |
StringBuffer |
format(double value,
StringBuffer buffer,
FieldPosition field)
Appends to the specified StringBuffer the string associated with the range in which the specified double value fits. |
StringBuffer |
format(long value,
StringBuffer buffer,
FieldPosition field)
Appends to the specified StringBuffer the string associated with the range in which the specified long value fits. |
Object[] |
getFormats()
Returns the Strings associated with the ranges of this ChoiceFormat. |
double[] |
getLimits()
Returns the ranges of this ChoiceFormat. |
int |
hashCode()
Returns an integer hash code for the receiver. |
static double |
nextDouble(double value)
Returns the double value which is closest to the specified double but larger. |
static double |
nextDouble(double value,
boolean increment)
Returns the double value which is closest to the specified double but either larger or smaller as specified. |
Number |
parse(String string,
ParsePosition position)
Parse a Double from the specified String starting at the index specified by the ParsePosition. |
static double |
previousDouble(double value)
Returns the double value which is closest to the specified double but smaller. |
void |
setChoices(double[] limits,
String[] formats)
Sets the ranges and associated strings of this ChoiceFormat. |
String |
toPattern()
Returns the pattern of this ChoiceFormat which specified the ranges and their associated strings. |
| Methods inherited from class java.text.Format |
|---|
convertPattern, format, formatToCharacterIterator, getBundle, parseObject, upTo, upToWithQuotes |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ChoiceFormat(double[] limits,
String[] formats)
limits - an array of double, the ranges are greater or equal to the
value in lower index up to less than the value in the next
higher index. The bounds of the lowest and highest indexes are
negative and positive infinity.formats - the strings associated with the ranges. The lower bound of the
associated range is at the same index as the string.public ChoiceFormat(String template)
template - the pattern of strings and ranges
IllegalArgumentException - then an error occurs parsing the pattern| Method Detail |
|---|
public void applyPattern(String template)
template - the pattern of strings and ranges
IllegalArgumentException - then an error occurs parsing the patternpublic Object clone()
clone in class NumberFormatCloneablepublic boolean equals(Object object)
equals in class NumberFormatobject - the object to compare with this object
hashCode()
public StringBuffer format(double value,
StringBuffer buffer,
FieldPosition field)
format in class NumberFormatvalue - the double to formatbuffer - the StringBufferfield - a FieldPosition which is ignored
buffer
public StringBuffer format(long value,
StringBuffer buffer,
FieldPosition field)
format in class NumberFormatvalue - the long to formatbuffer - the StringBufferfield - a FieldPosition which is ignored
bufferpublic Object[] getFormats()
public double[] getLimits()
public int hashCode()
hashCode in class NumberFormatequals(java.lang.Object)public static final double nextDouble(double value)
value - a double value
public static double nextDouble(double value,
boolean increment)
value - a double valueincrement - true to get a larger value, false to get a smaller value
public Number parse(String string,
ParsePosition position)
parse in class NumberFormatstring - the String to parseposition - the ParsePosition, updated on return with the index following
the parsed text, or on error the index is unchanged and the
error index is set to the index where the error occurred
public static final double previousDouble(double value)
value - a double value
public void setChoices(double[] limits,
String[] formats)
limits - an array of double, the ranges are greater or equal to the
value in lower index up to less than the value in the next
higher index. The bounds of the lowest and highest indexes are
negative and positive infinity.formats - the strings associated with the ranges. The lower bound of the
range is at the same index as the string.public String toPattern()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||