1 28 29 package com.idaremedia.antx.feedback; 30 31 import java.io.ByteArrayOutputStream ; 32 import java.io.IOException ; 33 34 import org.apache.log4j.or.ObjectRenderer; 35 36 import com.idaremedia.apis.UIStringManager; 37 38 import com.idaremedia.antx.AntX; 39 import com.idaremedia.antx.ErrorSnapshot; 40 import com.idaremedia.antx.helpers.Tk; 41 import com.idaremedia.antx.print.DisplayRequest; 42 import com.idaremedia.antx.print.ErrorPrinter; 43 44 55 56 public class ErrorSnapshotRenderer implements ObjectRenderer 57 { 58 61 public ErrorSnapshotRenderer() 62 { 63 m_printWorker = new ErrorPrinter(); 64 } 65 66 67 71 protected final UIStringManager uistrs() 72 { 73 return AntX.uistrs(); 74 } 75 76 77 84 protected final String defaultStringFrom(ErrorSnapshot es) 85 { 86 try { 87 ByteArrayOutputStream bos = new ByteArrayOutputStream (256); 88 DisplayRequest dr = new DisplayRequest(es); 89 m_printWorker.print(dr,bos); 90 String s = bos.toString(); 91 bos.close(); 92 bos = null; 93 return s; 94 } catch(IOException ioX) { 95 return es.toString(); 96 } 97 } 98 99 100 104 protected String stringFrom(ErrorSnapshot es) 105 { 106 return defaultStringFrom(es); 107 } 108 109 110 115 public String doRender(Object object) 116 { 117 if (object instanceof ErrorSnapshot) { 118 return stringFrom((ErrorSnapshot)object); 119 } 120 return Tk.stringFrom(object,null); 121 } 122 123 private final ErrorPrinter m_printWorker; 124 } 125 126 127 | Popular Tags |