01: package gnu.text;
02:
03: import java.text.FieldPosition;
04: import java.io.Writer;
05:
06: public class LiteralFormat extends ReportFormat {
07: char[] text;
08:
09: public LiteralFormat(char[] text) {
10: this .text = text;
11: }
12:
13: public LiteralFormat(String text) {
14: this .text = text.toCharArray();
15: }
16:
17: public LiteralFormat(StringBuffer sbuf) {
18: int len = sbuf.length();
19: text = new char[len];
20: sbuf.getChars(0, len, text, 0);
21: }
22:
23: public int format(Object[] args, int start, Writer dst,
24: FieldPosition fpos) throws java.io.IOException {
25: dst.write(text);
26: return start;
27: }
28:
29: public Object parseObject(String text,
30: java.text.ParsePosition status) {
31: throw new Error("LiteralFormat.parseObject - not implemented");
32: }
33:
34: /** Return the text that would be printed by the format. */
35: public String content() {
36: return new String(text);
37: }
38:
39: public String toString() {
40: StringBuffer sbuf = new StringBuffer("LiteralFormat[\"");
41: sbuf.append(text);
42: sbuf.append("\"]");
43: return sbuf.toString();
44: }
45: }
|