1 14 package org.wings.io; 15 16 import javax.servlet.ServletOutputStream ; 17 import java.io.IOException ; 18 19 25 public final class ServletDevice implements Device { 26 private ServletOutputStream out; 27 28 29 public ServletDevice(ServletOutputStream out) { 30 this.out = out; 31 } 32 33 public boolean isSizePreserving() { return true; } 34 35 38 public void flush() throws IOException { 39 out.flush(); 40 } 41 42 public void close() throws IOException { 43 out.close(); 44 } 45 46 49 public Device print(String s) throws IOException { 50 if (s == null) 51 out.print("null"); 52 else 53 out.print(s); 54 return this; 55 } 56 57 60 public Device print(int i) throws IOException { 61 out.print(i); 62 return this; 63 } 64 65 68 public Device print(Object o) throws IOException { 69 if (o == null) 70 out.print("null"); 71 else 72 out.print(o.toString()); 73 return this; 74 } 75 76 79 public Device print(char c) throws IOException { 80 out.print(c); 81 return this; 82 } 83 84 87 public Device print(char[] c) throws IOException { 88 return print(c, 0, c.length - 1); 89 } 90 91 94 public Device print(char[] c, int start, int len) throws IOException { 95 final int end = start + len; 96 for (int i = start; i < end; ++i) 97 out.print(c[i]); 98 return this; 99 } 100 101 104 public Device write(int c) throws IOException { 105 out.write(c); 106 return this; 107 } 108 109 113 public Device write(byte b[]) throws IOException { 114 out.write(b); 115 return this; 116 } 117 118 122 public Device write(byte b[], int off, int len) throws IOException { 123 out.write(b, off, len); 124 return this; 125 } 126 } 127 128 129 | Popular Tags |