1 16 19 20 package org.apache.xalan.xsltc.runtime.output; 21 22 import java.io.BufferedWriter ; 23 import java.io.IOException ; 24 import java.io.Writer ; 25 26 29 class WriterOutputBuffer implements OutputBuffer { 30 private static final int KB = 1024; 31 private static int BUFFER_SIZE = 4 * KB; 32 33 static { 34 final String osName = System.getProperty("os.name"); 36 if (osName.equalsIgnoreCase("solaris")) { 37 BUFFER_SIZE = 32 * KB; 38 } 39 } 40 41 private Writer _writer; 42 43 49 public WriterOutputBuffer(Writer writer) { 50 _writer = new BufferedWriter (writer, BUFFER_SIZE); 51 } 52 53 public String close() { 54 try { 55 _writer.flush(); 56 } 57 catch (IOException e) { 58 throw new RuntimeException (e.toString()); 59 } 60 return ""; 61 } 62 63 public OutputBuffer append(String s) { 64 try { 65 _writer.write(s); 66 } 67 catch (IOException e) { 68 throw new RuntimeException (e.toString()); 69 } 70 return this; 71 } 72 73 public OutputBuffer append(char[] s, int from, int to) { 74 try { 75 _writer.write(s, from, to); 76 } 77 catch (IOException e) { 78 throw new RuntimeException (e.toString()); 79 } 80 return this; 81 } 82 83 public OutputBuffer append(char ch) { 84 try { 85 _writer.write(ch); 86 } 87 catch (IOException e) { 88 throw new RuntimeException (e.toString()); 89 } 90 return this; 91 } 92 } 93 94 95 | Popular Tags |