1 14 package org.wings.io; 15 16 import java.io.Serializable ; 17 18 19 28 public final class NullDevice implements Device, Serializable { 29 30 public static NullDevice DEFAULT = new NullDevice(); 31 32 private long byteCount; 33 34 public NullDevice() { 35 byteCount = 0; 36 } 37 38 public boolean isSizePreserving() { return true; } 39 40 43 public void flush() { } 44 45 public void close() { } 46 47 50 public long getSize() { return byteCount; } 51 52 55 public void resetSize() { byteCount = 0; } 56 57 60 public Device print(char c) { 61 ++byteCount; 62 return this; 63 } 64 65 68 public Device print(char[] c) { 69 if (c != null) byteCount += c.length; 70 return this; 71 } 72 73 77 public Device print(char[] c, int start, int len) { 78 byteCount += len; 79 return this; 80 } 81 82 84 87 public Device print(String s) { 88 if (s != null) byteCount += s.length(); 89 return this; 90 } 91 92 95 public Device print(int i) { 96 byteCount += String.valueOf(i).length(); 97 return this; 98 } 99 100 103 public Device print(Object o) { 104 if (o != null) byteCount += o.toString().length(); 105 return this; 106 } 107 108 111 112 115 public Device write(int c) { 116 ++byteCount; 117 return this; 118 } 119 120 124 public Device write(byte b[]) { 125 if (b != null) byteCount += b.length; 126 return this; 127 } 128 129 133 public Device write(byte b[], int off, int len) { 134 if (b != null) byteCount += len; 135 return this; 136 } 137 } 138 139 140 | Popular Tags |