1 package gnu.text; 2 import java.text.FieldPosition ; 3 import java.io.Writer ; 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 text) 15 { 16 this.text = text.toCharArray(); 17 } 18 19 public LiteralFormat(StringBuffer 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 [] args, int start, Writer dst, FieldPosition fpos) 27 throws java.io.IOException 28 { 29 dst.write(text); 30 return start; 31 } 32 33 public Object parseObject(String text, java.text.ParsePosition status) 34 { 35 throw new Error ("LiteralFormat.parseObject - not implemented"); 36 } 37 38 39 public String content () 40 { 41 return new String (text); 42 } 43 44 public String toString() 45 { 46 StringBuffer sbuf = new StringBuffer ("LiteralFormat[\""); 47 sbuf.append(text); 48 sbuf.append("\"]"); 49 return sbuf.toString(); 50 } 51 } 52 | Popular Tags |