Android
java.text
public class

java.text.ChoiceFormat

java.lang.Object
java.text.Format Serializable Cloneable
java.text.NumberFormat
java.text.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.

Summary

Constants inherited from class java.text.NumberFormat

Public Constructors

            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.

Public Methods

          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.
    final  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.
    final  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.NumberFormat
Methods inherited from class java.text.Format
Methods inherited from class java.lang.Object

Details

Public Constructors

public ChoiceFormat(double[] limits, String[] formats)

Constructs a new ChoiceFormat with the specified ranges and associated strings.

Parameters

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)

Constructs a new ChoiceFormat with the strings and ranges parsed from the specified pattern.

Parameters

template the pattern of strings and ranges

Throws

IllegalArgumentException then an error occurs parsing the pattern

Public Methods

public void applyPattern(String template)

Parses the pattern to determine new strings and ranges for this ChoiceFormat.

Parameters

template the pattern of strings and ranges

Throws

IllegalArgumentException then an error occurs parsing the pattern

public Object clone()

Returns a new instance of ChoiceFormat with the same ranges and strings as this ChoiceFormat.

Returns

  • a shallow copy of this ChoiceFormat

See Also

public boolean equals(Object object)

Compares the specified object to this ChoiceFormat and answer if they are equal. The object must be an instance of ChoiceFormat and have the same limits and formats.

Parameters

object the object to compare with this object

Returns

  • true if the specified object is equal to this ChoiceFormat, false otherwise

See Also

public 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.

Parameters

value the double to format
buffer the StringBuffer
field a FieldPosition which is ignored

Returns

  • the StringBuffer parameter buffer

public 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.

Parameters

value the long to format
buffer the StringBuffer
field a FieldPosition which is ignored

Returns

  • the StringBuffer parameter buffer

public Object[] getFormats()

Returns the Strings associated with the ranges of this ChoiceFormat.

Returns

  • an array of String

public double[] getLimits()

Returns the ranges of this ChoiceFormat.

Returns

  • 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.

public int hashCode()

Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Returns

  • the receiver's hash

See Also

public static final double nextDouble(double value)

Returns the double value which is closest to the specified double but larger.

Parameters

value a double value

Returns

  • the next larger double value

public 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.

Parameters

value a double value
increment true to get a larger value, false to get a smaller value

Returns

  • the next larger or smaller double value

public Number parse(String string, ParsePosition position)

Parse a Double from the specified String starting at the index specified by the ParsePosition. The String is compared to the strings of this ChoiceFormat and if a match occurs, the answer is the lower bound of the corresponding range. If the string is successfully parsed, the index of the ParsePosition is updated to the index following the parsed text.

Parameters

string the String to parse
position 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

Returns

  • a Double resulting from the parse, or Double.NaN if there is an error

public static final double previousDouble(double value)

Returns the double value which is closest to the specified double but smaller.

Parameters

value a double value

Returns

  • the next smaller double value

public void setChoices(double[] limits, String[] formats)

Sets the ranges and associated strings of this ChoiceFormat.

Parameters

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()

Returns the pattern of this ChoiceFormat which specified the ranges and their associated strings.

Returns

  • the pattern
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56