<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.text.ChoiceFormat
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.text.html">This Package</a>  <a href="java.text.BreakIterator.html#_top_">Previous</a>  <a href="java.text.CollationElementIterator.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.text.ChoiceFormat
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----<a href="java.text.Format.html#_top_">java.text.Format</a>
           |
           +----<a href="java.text.NumberFormat.html#_top_">java.text.NumberFormat</a>
                   |
                   +----java.text.ChoiceFormat
</pre>
<hr>
<dl>
  <dt> public class <b>ChoiceFormat</b>
  <dt> extends <a href="java.text.NumberFormat.html#_top_">NumberFormat</a>
</dl>
A <code>ChoiceFormat</code> allows you to attach a format to a range of numbers.
 It is generally used in a <code>MessageFormat</code> for handling plurals.
 The choice is specified with an ascending list of doubles, where each item
 specifies a half-open interval up to the next item:
 <blockquote>
 <pre>
 X matches j if and only if limit[j] <= X < limit[j+1]
 </pre>
 </blockquote>
 If there is no match, then either the first or last index is used, depending
 on whether the number (X) is too low or too high.
 <p>
 <strong>Note:</strong>
 <code>ChoiceFormat</code> differs from the other <code>Format</code>
 classes in that you create a <code>ChoiceFormat</code> object with a
 constructor (not with a <code>getInstance</code> style factory
 method). The factory methods aren't necessary because <code>ChoiceFormat</code>
 doesn't require any complex setup for a given locale. In fact,
 <code>ChoiceFormat</code> doesn't implement any locale specific behavior.
 <p>
 When creating a <code>ChoiceFormat</code>, you must specify an array of formats
 and an array of limits. The length of these arrays must be the same.
 For example,
 <ul>
 <li>
     <em>limits</em> = {1,2,3,4,5,6,7}<br>
     <em>formats</em> = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"}
 <lie>
     <em>limits</em> = {0, 1, ChoiceFormat.nextDouble(1)}<br>
     <em>formats</em> = {"no files", "one file", "many files"}<br>
     (<code>nextDouble</code> can be used to get the next higher double, to
     make the half-open interval.)
 </ul>
 <p>
 Here is a simple example that shows formatting and parsing:
 <blockquote>
 <pre>
 double[] limits = {1,2,3,4,5,6,7};
 String[] monthNames = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"};
 ChoiceFormat form = new ChoiceFormat(limits, monthNames);
 ParsePosition status = new ParsePosition(0);
 for (double i = 0.0; i <= 8.0; ++i) {
     status.setIndex(0);
     System.out.println(i + " -> " + form.format(i) + " -> "
                              + form.parse(form.format(i),status));
 }
 </pre>
 </blockquote>
 Here is a more complex example, with a pattern format:
 <blockquote>
 <pre>
 double[] filelimits = {0,1,2};
 String[] filepart = {"are no files","is one file","are {2} files"};
 ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
 Format[] testFormats = {fileform, null, NumberFormat.getInstance()};
 MessageFormat pattform = new MessageFormat("There {0} on {1}");
 pattform.setFormats(testFormats);
 Object[] testArgs = {null, "ADisk", null};
 for (int i = 0; i < 4; ++i) {
     testArgs[0] = new Integer(i);
     testArgs[2] = testArgs[0];
     System.out.println(pattform.format(testArgs));
 }
 </pre>
 </blockquote>
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.text.DecimalFormat.html#_top_">DecimalFormat</a>, <a href="java.text.MessageFormat.html#_top_">MessageFormat</a>
</dl>
<hr>
<a name="index"></a>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#ChoiceFormat(double[], java.lang.String[])"><b>ChoiceFormat</b></a>(double[], String[])
  <dd>  Constructs with the limits and the corresponding formats.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#ChoiceFormat(java.lang.String)"><b>ChoiceFormat</b></a>(String)
  <dd>  Constructs with limits and corresponding formats based on the pattern.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#applyPattern(java.lang.String)"><b>applyPattern</b></a>(String)
  <dd>  Sets the pattern.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#clone()"><b>clone</b></a>()
  <dd>  Overrides Cloneable

  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#equals(java.lang.Object)"><b>equals</b></a>(Object)
  <dd>  Equality comparision between two

  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#format(double, java.lang.StringBuffer, java.text.FieldPosition)"><b>format</b></a>(double, StringBuffer, FieldPosition)
  <dd>  Specialization of format.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#format(long, java.lang.StringBuffer, java.text.FieldPosition)"><b>format</b></a>(long, StringBuffer, FieldPosition)
  <dd>  Specialization of format.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getFormats()"><b>getFormats</b></a>()
  <dd>  Get the formats passed in the constructor.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getLimits()"><b>getLimits</b></a>()
  <dd>  Get the limits passed in the constructor.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#hashCode()"><b>hashCode</b></a>()
  <dd>  Generates a hash code for the message format object.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#nextDouble(double)"><b>nextDouble</b></a>(double)
  <dd>  Finds the least double greater than d.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#nextDouble(double, boolean)"><b>nextDouble</b></a>(double, boolean)
  <dd> 
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#parse(java.lang.String, java.text.ParsePosition)"><b>parse</b></a>(String, ParsePosition)
  <dd>  Returns a Long if possible (e.g.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#previousDouble(double)"><b>previousDouble</b></a>(double)
  <dd>  Finds the greatest double less than d.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setChoices(double[], java.lang.String[])"><b>setChoices</b></a>(double[], String[])
  <dd>  Set the choices to be used in formatting.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#toPattern()"><b>toPattern</b></a>()
  <dd>  Gets the pattern.
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="ChoiceFormat"></a>
<a name="ChoiceFormat(java.lang.String)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>ChoiceFormat</b>
<pre>
 public ChoiceFormat(<a href="java.lang.String.html#_top_">String</a> newPattern)
</pre>
<dl>
  <dd> Constructs with limits and corresponding formats based on the pattern.
<p>
</dl>
<a name="ChoiceFormat(double[], java.lang.String[])"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>ChoiceFormat</b>
<pre>
 public ChoiceFormat(double limits[],
                     <a href="java.lang.String.html#_top_">String</a> formats[])
</pre>
<dl>
  <dd> Constructs with the limits and the corresponding formats.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#setChoices">setChoices</a>
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="applyPattern(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="applyPattern"><b>applyPattern</b></a>
<pre>
 public void applyPattern(<a href="java.lang.String.html#_top_">String</a> newPattern)
</pre>
<dl>
  <dd> Sets the pattern.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> newPattern - See the class description.
  </dl></dd>
</dl>
<a name="toPattern()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="toPattern"><b>toPattern</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> toPattern()
</pre>
<dl>
  <dd> Gets the pattern.
<p>
</dl>
<a name="setChoices(double[], java.lang.String[])"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setChoices"><b>setChoices</b></a>
<pre>
 public void setChoices(double limits[],
                        <a href="java.lang.String.html#_top_">String</a> formats[])
</pre>
<dl>
  <dd> Set the choices to be used in formatting.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> limits - contains the top value that you want
 parsed with that format,and should be in ascending sorted order. When
 formatting X, the choice will be the i, where limit[i] <= X < limit[i+1].
    <dd> formats - are the formats you want to use for each limit.
 They can be either Format objects or Strings.
 When formatting with object Y,
 if the object is a NumberFormat, then ((NumberFormat) Y).format(X)
 is called. Otherwise Y.toString() is called.
  </dl></dd>
</dl>
<a name="getLimits()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getLimits"><b>getLimits</b></a>
<pre>
 public double[] getLimits()
</pre>
<dl>
  <dd> Get the limits passed in the constructor.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the limits.
  </dl></dd>
</dl>
<a name="getFormats()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getFormats"><b>getFormats</b></a>
<pre>
 public <a href="java.lang.Object.html#_top_">Object</a>[] getFormats()
</pre>
<dl>
  <dd> Get the formats passed in the constructor.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the formats.
  </dl></dd>
</dl>
<a name="format(long, java.lang.StringBuffer, java.text.FieldPosition)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="format"><b>format</b></a>
<pre>
 public <a href="java.lang.StringBuffer.html#_top_">StringBuffer</a> format(long number,
                            <a href="java.lang.StringBuffer.html#_top_">StringBuffer</a> toAppendTo,
                            <a href="java.text.FieldPosition.html#_top_">FieldPosition</a> status)
</pre>
<dl>
  <dd> Specialization of format. This method really calls
 <code>format(double, StringBuffer, FieldPosition)</code>
 thus the range of longs that are supported is only equal to
 the range that can be stored by double. This will never be
 a practical limitation.
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.text.NumberFormat.html#format(long, java.lang.StringBuffer, java.text.FieldPosition)">format</a> in class <a href="java.text.NumberFormat.html#_top_">NumberFormat</a>
  </dl></dd>
</dl>
<a name="format(double, java.lang.StringBuffer, java.text.FieldPosition)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="format"><b>format</b></a>
<pre>
 public <a href="java.lang.StringBuffer.html#_top_">StringBuffer</a> format(double number,
                            <a href="java.lang.StringBuffer.html#_top_">StringBuffer</a> toAppendTo,
                            <a href="java.text.FieldPosition.html#_top_">FieldPosition</a> status)
</pre>
<dl>
  <dd> Specialization of format.
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.text.NumberFormat.html#format(double, java.lang.StringBuffer, java.text.FieldPosition)">format</a> in class <a href="java.text.NumberFormat.html#_top_">NumberFormat</a>
  </dl></dd>
</dl>
<a name="parse(java.lang.String, java.text.ParsePosition)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="parse"><b>parse</b></a>
<pre>
 public <a href="java.lang.Number.html#_top_">Number</a> parse(<a href="java.lang.String.html#_top_">String</a> text,
                     <a href="java.text.ParsePosition.html#_top_">ParsePosition</a> status)
</pre>
<dl>
  <dd> Returns a Long if possible (e.g.
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.text.NumberFormat.html#parse(java.lang.String, java.text.ParsePosition)">parse</a> in class <a href="java.text.NumberFormat.html#_top_">NumberFormat</a>
  </dl></dd>
</dl>
<a name="nextDouble(double)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="nextDouble"><b>nextDouble</b></a>
<pre>
 public static final double nextDouble(double d)
</pre>
<dl>
  <dd> Finds the least double greater than d.
 If NaN, returns same value.
 <p>Used to make half-open intervals.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#previousDouble">previousDouble</a>
  </dl></dd>
</dl>
<a name="previousDouble(double)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="previousDouble"><b>previousDouble</b></a>
<pre>
 public static final double previousDouble(double d)
</pre>
<dl>
  <dd> Finds the greatest double less than d.
 If NaN, returns same value.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#nextDouble">nextDouble</a>
  </dl></dd>
</dl>
<a name="clone()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="clone"><b>clone</b></a>
<pre>
 public <a href="java.lang.Object.html#_top_">Object</a> clone()
</pre>
<dl>
  <dd> Overrides Cloneable
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.text.NumberFormat.html#clone()">clone</a> in class <a href="java.text.NumberFormat.html#_top_">NumberFormat</a>
  </dl></dd>
</dl>
<a name="hashCode()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="hashCode"><b>hashCode</b></a>
<pre>
 public int hashCode()
</pre>
<dl>
  <dd> Generates a hash code for the message format object.
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.text.NumberFormat.html#hashCode()">hashCode</a> in class <a href="java.text.NumberFormat.html#_top_">NumberFormat</a>
  </dl></dd>
</dl>
<a name="equals(java.lang.Object)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="equals"><b>equals</b></a>
<pre>
 public boolean equals(<a href="java.lang.Object.html#_top_">Object</a> obj)
</pre>
<dl>
  <dd> Equality comparision between two
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.text.NumberFormat.html#equals(java.lang.Object)">equals</a> in class <a href="java.text.NumberFormat.html#_top_">NumberFormat</a>
  </dl></dd>
</dl>
<a name="nextDouble(double, boolean)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="nextDouble"><b>nextDouble</b></a>
<pre>
 public static double nextDouble(double d,
                                 boolean positive)
</pre>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.text.html">This Package</a>  <a href="java.text.BreakIterator.html#_top_">Previous</a>  <a href="java.text.CollationElementIterator.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
