<!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.Format
</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.FieldPosition.html#_top_">Previous</a>  <a href="java.text.MessageFormat.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.text.Format
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----java.text.Format
</pre>
<hr>
<dl>
  <dt> public abstract class <b>Format</b>
  <dt> extends <a href="java.lang.Object.html#_top_">Object</a>
  <dt> implements <a href="java.io.Serializable.html#_top_">Serializable</a>, <a href="java.lang.Cloneable.html#_top_">Cloneable</a>
</dl>
<code>Format</code> is an abstract base class for formatting locale-sensitive
 information such as dates, messages, and numbers.
 <p>
 <code>Format</code> defines the programming interface for formatting
 locale-sensitive objects into <code>String</code>s (the
 <code>format</code> method) and for parsing <code>String</code>s back
 into objects (the <code>parseObject</code> method). Any <code>String</code>
 formatted by <code>format</code> is guaranteed to be parseable by
 <code>parseObject</code>.
 <p>
 If formatting is unsuccessful because the <code>Format</code> object
 cannot format the type of object specified, <code>format</code> throws an
 <code>IllegalArgumentException</code>. Otherwise, if there is something
 illformed about the object, <code>format</code> returns the Unicode
 replacement character <code>\\uFFFD</code>.
 <p>
 If there is no match when parsing,
 <code>parseObject(String)</code> throws a <code>ParseException</code>,
 and <code>parseObject(String, ParsePosition)</code> leaves the
 <code>ParsePosition</code> <code>index</code> member unchanged and
 returns <code>null</code>.
 <p>
 <STRONG>Subclassing:</STRONG>
 The JDK provides three concrete subclasses of <code>Format</code>--
 <code>DateFormat</code>, <code>MessageFormat</code>, and
 <code>NumberFormat</code>--for formatting dates, messages, and numbers,
 respectively.
 <p>
 Concrete subclasses <em>must</em> implement these two methods:
 <ol>
 <li> <code>format(Object obj, StringBuffer toAppendTo, FieldPosition pos)</code>
 <li> <code>parseObject (String source, ParsePosition pos)</code>
 </ol>
 <p>
 Most subclasses will also implement the following two methods:
 <ol>
 <li>
 <code>getInstance</code> for getting a useful format object appropriate
 for the current locale
 <li>
 <code>getInstance(Locale)</code> for getting a useful format
 object appropriate for the specified locale
 </ol>
 In addition, some subclasses may also choose to implement other
 <code>getXxxxInstance</code> methods for more specialized control. For
 example, the <code>NumberFormat</code> class provides
 <code>getPercentInstance</code> and <code>getCurrencyInstance</code>
 methods for getting specialized number formatters.
 <p>
 Subclasses of <code>Format</code> that allow programmers to create objects
 for locales (with <code>getInstance(Locale)</code> for example)
 must also implement the following class method:
 <blockquote>
 <pre>
 public static Locale[] getAvailableLocales()
 </pre>
 </blockquote>
 <p>
 And finally subclasses may define a set of constants to identify the various
 fields in the formatted output. These constants are used to create a FieldPosition
 object which identifies what information is contained in the field and its
 position in the formatted result. These constants should be named
 <code><em>item</em>_FIELD</code> where <code><em>item</em></code> identifies
 the field. For examples of these constants, see <code>ERA_FIELD</code> and its
 friends in <a href="java.text.DateFormat.html"><code>DateFormat</code></a>.
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.text.ParsePosition.html#_top_">ParsePosition</a>, <a href="java.text.FieldPosition.html#_top_">FieldPosition</a>, <a href="java.text.NumberFormat.html#_top_">NumberFormat</a>, <a href="java.text.DateFormat.html#_top_">DateFormat</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="#Format()"><b>Format</b></a>()
  <dd> 
</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="#clone()"><b>clone</b></a>()
  <dd>  Creates a new object of the same class as this object.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#format(java.lang.Object)"><b>format</b></a>(Object)
  <dd>  Formats an object to produce a string.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)"><b>format</b></a>(Object, StringBuffer, FieldPosition)
  <dd>  Formats an object to produce a string.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#parseObject(java.lang.String)"><b>parseObject</b></a>(String)
  <dd>  Parses a string to produce an object.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#parseObject(java.lang.String, java.text.ParsePosition)"><b>parseObject</b></a>(String, ParsePosition)
  <dd>  Parses a string to produce an object.
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="Format"></a>
<a name="Format()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>Format</b>
<pre>
 public Format()
</pre>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="format(java.lang.Object)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="format"><b>format</b></a>
<pre>
 public final <a href="java.lang.String.html#_top_">String</a> format(<a href="java.lang.Object.html#_top_">Object</a> obj)
</pre>
<dl>
  <dd> Formats an object to produce a string.
 <p>Subclasses will override the StringBuffer version of format.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> obj - The object to format
    <dt> <b>Returns:</b>
    <dd> Formatted string.
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> when the Format cannot format the
 type of object.
    <dt> <b>See Also:</b>
    <dd> <a href="java.text.MessageFormat.html#_top_">MessageFormat</a>, <a href="#format">format</a>
  </dl></dd>
</dl>
<a name="format(java.lang.Object, 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 abstract <a href="java.lang.StringBuffer.html#_top_">StringBuffer</a> format(<a href="java.lang.Object.html#_top_">Object</a> obj,
                                     <a href="java.lang.StringBuffer.html#_top_">StringBuffer</a> toAppendTo,
                                     <a href="java.text.FieldPosition.html#_top_">FieldPosition</a> pos)
</pre>
<dl>
  <dd> Formats an object to produce a string.
 Subclasses will implement for particular object, such as:
 <pre>
 StringBuffer format (Number obj, StringBuffer toAppendTo)
 Number parse (String str)
 </pre>
 These general routines allow polymorphic parsing and
 formatting for objects such as the MessageFormat.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> obj - The object to format
    <dd> toAppendTo - where the text is to be appended
    <dd> status - On input: an alignment field, if desired.
 On output: the offsets of the alignment field.
    <dt> <b>Returns:</b>
    <dd> the value passed in as toAppendTo (this allows chaining,
 as with StringBuffer.append())
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> when the Format cannot format the
 given object.
    <dt> <b>See Also:</b>
    <dd> <a href="java.text.MessageFormat.html#_top_">MessageFormat</a>, <a href="java.text.FieldPosition.html#_top_">FieldPosition</a>
  </dl></dd>
</dl>
<a name="parseObject(java.lang.String, java.text.ParsePosition)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="parseObject"><b>parseObject</b></a>
<pre>
 public abstract <a href="java.lang.Object.html#_top_">Object</a> parseObject(<a href="java.lang.String.html#_top_">String</a> source,
                                    <a href="java.text.ParsePosition.html#_top_">ParsePosition</a> status)
</pre>
<dl>
  <dd> Parses a string to produce an object.
 Subclasses will typically implement for particular object, such as:
 <pre>
       String format (Number obj);
       String format (long obj);
       String format (double obj);
       Number parse (String str);
 </pre>
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> ParsePosition - Input-Output parameter.
 <p>Before calling, set status.index to the offset you want to start
 parsing at in the source.
 After calling, status.index is the end of the text you parsed.
 If error occurs, index is unchanged.
 <p>When parsing, leading whitespace is discarded
 (with successful parse),
 while trailing whitespace is left as is.
 <p>Example:
 Parsing "_12_xy" (where _ represents a space) for a number,
 with index == 0 will result in
 the number 12, with status.index updated to 3
 (just before the second space).
 Parsing a second time will result in a ParseException
 since "xy" is not a number, and leave index at 3.
 <p>Subclasses will typically supply specific parse methods that
 return different types of values. Since methods can't overload on
 return types, these will typically be named "parse", while this
 polymorphic method will always be called parseObject.
 Any parse method that does not take a status should
 throw ParseException when no text in the required format is at
 the start position.
    <dt> <b>Returns:</b>
    <dd> Object parsed from string. In case of error, returns null.
    <dt> <b>See Also:</b>
    <dd> <a href="java.text.ParsePosition.html#_top_">ParsePosition</a>
  </dl></dd>
</dl>
<a name="parseObject(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="parseObject"><b>parseObject</b></a>
<pre>
 public <a href="java.lang.Object.html#_top_">Object</a> parseObject(<a href="java.lang.String.html#_top_">String</a> source) throws <a href="java.text.ParseException.html#_top_">ParseException</a>
</pre>
<dl>
  <dd> Parses a string to produce an object.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.text.ParseException.html#_top_">ParseException</a>
    <dd> if the specified string is invalid.
  </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> Creates a new object of the same class as this object.
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.lang.Object.html#clone()">clone</a> in class <a href="java.lang.Object.html#_top_">Object</a>
  </dl></dd>
</dl>
<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.FieldPosition.html#_top_">Previous</a>  <a href="java.text.MessageFormat.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
