1 16 package org.apache.commons.vfs.util; 17 18 import org.apache.commons.vfs.RandomAccessContent; 19 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 23 28 public class MonitorRandomAccessContent implements RandomAccessContent 29 { 30 private final RandomAccessContent content; 31 private boolean finished; 32 33 public MonitorRandomAccessContent(final RandomAccessContent content) 34 { 35 this.content = content; 36 } 37 38 41 protected void onClose() throws IOException 42 { 43 } 44 45 48 public void close() throws IOException 49 { 50 if (finished) 51 { 52 return; 53 } 54 55 IOException exc = null; 57 try 58 { 59 content.close(); 60 } 61 catch (final IOException ioe) 62 { 63 exc = ioe; 64 } 65 66 exc = null; 68 try 69 { 70 onClose(); 71 } 72 catch (final IOException ioe) 73 { 74 exc = ioe; 75 } 76 77 finished = true; 78 79 if (exc != null) 80 { 81 throw exc; 82 } 83 } 84 85 public long getFilePointer() throws IOException 86 { 87 return content.getFilePointer(); 88 } 89 90 public void seek(long pos) throws IOException 91 { 92 content.seek(pos); 93 } 94 95 public long length() throws IOException 96 { 97 return content.length(); 98 } 99 100 public void write(int b) throws IOException 101 { 102 content.write(b); 103 } 104 105 public void write(byte[] b) throws IOException 106 { 107 content.write(b); 108 } 109 110 public void write(byte[] b, int off, int len) throws IOException 111 { 112 content.write(b, off, len); 113 } 114 115 public void writeBoolean(boolean v) throws IOException 116 { 117 content.writeBoolean(v); 118 } 119 120 public void writeByte(int v) throws IOException 121 { 122 content.writeByte(v); 123 } 124 125 public void writeShort(int v) throws IOException 126 { 127 content.writeShort(v); 128 } 129 130 public void writeChar(int v) throws IOException 131 { 132 content.writeChar(v); 133 } 134 135 public void writeInt(int v) throws IOException 136 { 137 content.writeInt(v); 138 } 139 140 public void writeLong(long v) throws IOException 141 { 142 content.writeLong(v); 143 } 144 145 public void writeFloat(float v) throws IOException 146 { 147 content.writeFloat(v); 148 } 149 150 public void writeDouble(double v) throws IOException 151 { 152 content.writeDouble(v); 153 } 154 155 public void writeBytes(String s) throws IOException 156 { 157 content.writeBytes(s); 158 } 159 160 public void writeChars(String s) throws IOException 161 { 162 content.writeChars(s); 163 } 164 165 public void writeUTF(String str) throws IOException 166 { 167 content.writeUTF(str); 168 } 169 170 public void readFully(byte[] b) throws IOException 171 { 172 content.readFully(b); 173 } 174 175 public void readFully(byte[] b, int off, int len) throws IOException 176 { 177 content.readFully(b, off, len); 178 } 179 180 public int skipBytes(int n) throws IOException 181 { 182 return content.skipBytes(n); 183 } 184 185 public boolean readBoolean() throws IOException 186 { 187 return content.readBoolean(); 188 } 189 190 public byte readByte() throws IOException 191 { 192 return content.readByte(); 193 } 194 195 public int readUnsignedByte() throws IOException 196 { 197 return content.readUnsignedByte(); 198 } 199 200 public short readShort() throws IOException 201 { 202 return content.readShort(); 203 } 204 205 public int readUnsignedShort() throws IOException 206 { 207 return content.readUnsignedShort(); 208 } 209 210 public char readChar() throws IOException 211 { 212 return content.readChar(); 213 } 214 215 public int readInt() throws IOException 216 { 217 return content.readInt(); 218 } 219 220 public long readLong() throws IOException 221 { 222 return content.readLong(); 223 } 224 225 public float readFloat() throws IOException 226 { 227 return content.readFloat(); 228 } 229 230 public double readDouble() throws IOException 231 { 232 return content.readDouble(); 233 } 234 235 public String readLine() throws IOException 236 { 237 return content.readLine(); 238 } 239 240 public String readUTF() throws IOException 241 { 242 return content.readUTF(); 243 } 244 245 public InputStream getInputStream() throws IOException 246 { 247 return content.getInputStream(); 248 } 249 } 250 | Popular Tags |