KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > text > LiteralFormat


1 package gnu.text;
2 import java.text.FieldPosition JavaDoc;
3 import java.io.Writer JavaDoc;
4
5 public class LiteralFormat extends ReportFormat
6 {
7   char[] text;
8
9   public LiteralFormat(char[] text)
10   {
11     this.text = text;
12   }
13
14   public LiteralFormat(String JavaDoc text)
15   {
16     this.text = text.toCharArray();
17   }
18
19   public LiteralFormat(StringBuffer JavaDoc sbuf)
20   {
21     int len = sbuf.length();
22     text = new char[len];
23     sbuf.getChars(0, len, text, 0);
24   }
25
26   public int format(Object JavaDoc[] args, int start, Writer JavaDoc dst, FieldPosition JavaDoc fpos)
27     throws java.io.IOException JavaDoc
28   {
29     dst.write(text);
30     return start;
31   }
32
33   public Object JavaDoc parseObject(String JavaDoc text, java.text.ParsePosition JavaDoc status)
34   {
35     throw new Error JavaDoc("LiteralFormat.parseObject - not implemented");
36   }
37
38   /** Return the text that would be printed by the format. */
39   public String JavaDoc content ()
40   {
41     return new String JavaDoc(text);
42   }
43
44   public String JavaDoc toString()
45   {
46     StringBuffer JavaDoc sbuf = new StringBuffer JavaDoc("LiteralFormat[\"");
47     sbuf.append(text);
48     sbuf.append("\"]");
49     return sbuf.toString();
50   }
51 }
52
Popular Tags