1 4 5 package com.etymon.pjx; 6 7 import java.io.*; 8 9 14 public abstract class PdfObject 15 implements Cloneable { 16 17 25 public PdfObject filter(PdfObjectFilter f) throws PdfFormatException { 26 PdfObject obj = f.preFilter(this); 27 if (obj == null) { 28 return f.postFilter(null); 29 } else { 30 return obj.filterContents(f); 31 } 32 } 33 34 44 protected PdfObject filterContents(PdfObjectFilter f) throws PdfFormatException { 45 return f.postFilter(this); 46 } 47 48 52 public Object clone() { 53 try { 54 return super.clone(); 55 } 56 catch (CloneNotSupportedException e) { 57 return null; } 59 } 60 61 66 public boolean equals(Object obj) { 67 return super.equals(obj); 68 } 69 70 74 public int hashCode() { 75 return super.hashCode(); 76 } 77 78 83 public String toString() { 84 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 85 try { 86 PdfWriter w = new PdfWriter(baos); 87 writePdf(w, false); 88 w.close(); 89 baos.close(); 90 } 91 catch (IOException e) { 92 return null; 93 } 94 return baos.toString(); 95 } 96 97 108 protected abstract int writePdf(PdfWriter w, boolean spacing) throws IOException; 109 110 } 111 | Popular Tags |