| 1 package com.etymon.pj.object; 2 3 import java.io.*; 4 import java.util.*; 5 import com.etymon.pj.*; 6 7 11 public abstract class BaseObject 12 implements Cloneable { 13 14 19 public abstract Object clone() throws CloneNotSupportedException ; 20 21 27 public abstract long writePdf(OutputStream os) throws 28 IOException; 29 30 37 public static long write(OutputStream os, char c) 38 throws IOException { 39 os.write((int)c); 40 return 1; 41 } 42 43 50 public static long write(OutputStream os, byte[] b) 51 throws IOException { 52 os.write(b); 53 return b.length; 54 } 55 56 63 public static long write(OutputStream os, Object obj) 64 throws IOException { 65 return write(os, obj.toString().getBytes()); 66 } 67 68 75 public static long writeln(OutputStream os, Object obj) 76 throws IOException { 77 return write(os, obj) + write(os, PjConst.PDF_EOL); 78 } 79 80 84 public String toString() { 85 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 86 try { 87 writePdf(baos); 88 } 89 catch (IOException e) { 90 return null; 91 } 92 return baos.toString(); 93 } 94 95 } 96 | Popular Tags |