OSDN Git Service

Initial revision
[pf3gnuchains/gcc-fork.git] / libjava / java / text / Format.java
1 /* Copyright (C) 1998, 1999  Cygnus Solutions
2
3    This file is part of libgcj.
4
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
7 details.  */
8
9 package java.text;
10
11 /**
12  * @author Per Bothner <bothner@cygnus.com>
13  * @date October 25, 1998.
14  */
15 /* Written using "Java Class Libraries", 2nd edition, plus online
16  * API docs for JDK 1.2 beta from http://www.javasoft.com.
17  * Status:  Believed complete and correct.
18  */
19
20 public abstract class Format implements java.io.Serializable, Cloneable
21 {
22   public Format ()
23   {
24   }
25
26   public abstract StringBuffer format (Object obj,
27                                        StringBuffer sbuf, FieldPosition pos);
28
29   public final String format (Object obj)
30   {
31     StringBuffer sbuf = new StringBuffer();
32     format(obj, sbuf, new FieldPosition(0));
33     return sbuf.toString();
34   }
35
36   public abstract Object parseObject (String source, ParsePosition pos);
37
38   public Object parseObject (String source) throws ParseException
39   {
40     ParsePosition pos = new ParsePosition(0);
41     Object result = parseObject (source, pos);
42     if (result == null)
43       {
44         int index = pos.getErrorIndex();
45         if (index < 0)
46           index = pos.getIndex();
47         throw new ParseException("parseObject failed", index);
48       }
49     return result;
50   }
51 }