1 23 24 25 package org.apache.slide.webdav.logger; 26 27 import java.io.IOException ; 28 29 import javax.servlet.ServletInputStream ; 30 31 import org.apache.slide.common.Domain; 32 33 37 public class XServletInputStreamFacade extends ServletInputStream { 38 private ServletInputStream in; 39 private XByteBuffer byteBuf; 40 41 public XServletInputStreamFacade( ServletInputStream in ) { 42 if ( Domain.isInitialized()) Domain.debug("Create XServletInputStreamFacade"); 43 this.in = in; 44 byteBuf = new XByteBuffer(); 45 } 46 47 48 49 public int read() throws IOException { 50 if ( Domain.isInitialized())Domain.debug("ENTER: XServletInputStreamFacade:read()"); 51 int result = in.read(); 52 byteBuf.write(result); 53 if ( Domain.isInitialized())Domain.debug("LEAVE: XServletInputStreamFacade:read() result = " + result ); 54 return result; 55 } 56 57 public int read(byte[] b) throws IOException { 58 if ( Domain.isInitialized()) Domain.debug("ENTER: XServletInputStreamFacade:read(byte[] b)"); 59 int result = in.read(b); 60 byteBuf.write( b, 0, result ); 61 if ( Domain.isInitialized()) Domain.debug("LEAVE: XServletInputStreamFacade:read(byte[] b) result = " + result ); 62 return result; 63 } 64 65 public int read(byte[] b, int off, int len) throws IOException { 66 if ( Domain.isInitialized()) Domain.debug("ENTER: XServletInputStreamFacade:read(byte[] b, off="+off+" len="+len+" )"); 67 int result = in.read(b, off, len); 68 byteBuf.write( b, off, result ); 69 if ( Domain.isInitialized()) Domain.debug("LEAVE: XServletInputStreamFacade:read(byte[] b, off="+off+" len="+len+" ) result = " + result ); 70 return result; 71 } 72 73 81 public long skip(long n) throws IOException { 82 return in.skip(n); 83 } 84 85 101 public synchronized int available() throws IOException { 102 return in.available(); 103 } 104 105 113 public synchronized void mark(int readlimit) { 114 in.mark(readlimit); 115 } 116 117 131 public synchronized void reset() throws IOException { 132 in.reset(); 133 } 134 135 146 public boolean markSupported() { 147 return in.markSupported(); 148 } 149 150 156 public void close() throws IOException { 157 in.close(); 158 } 159 160 163 public String getBufferContent() { 164 return byteBuf.getBufferContent(); 165 } 166 167 170 public int getNumberOfBytesWritten() { 171 return byteBuf.getNumberOfBytesWritten(); 172 } 173 174 } 175 | Popular Tags |