1 9 10 package org.jboss.portal.format.render; 11 12 import java.io.IOException ; 13 import java.io.Writer ; 14 15 import org.apache.log4j.Logger; 16 17 20 public abstract class AbstractRenderer 21 { 22 23 24 25 protected final Logger log = Logger.getLogger(getClass()); 26 27 28 protected Writer writer = null; 29 30 31 public abstract void render(char[] chars, int offset, int length); 32 33 34 35 public void render(String string) { 36 char[] tmp = string.toCharArray(); 37 render(tmp, 0, tmp.length); 38 } 39 40 43 public final void setWriter(Writer writer) 44 { 45 this.writer = writer; 46 } 47 48 51 protected final void write(String s) 52 { 53 try 54 { 55 writer.write(s); 56 } 57 catch (IOException e) 58 { 59 log.error("Cannot write to output", e); 60 } 61 } 62 63 66 protected final void write(char[] chars, int offset, int length) 67 { 68 try 69 { 70 writer.write(chars, offset, length); 71 } 72 catch (IOException e) 73 { 74 log.error("Cannot write to output", e); 75 } 76 } 77 78 79 80 81 } 82 | Popular Tags |