19 package org.sleuthkit.datamodel;
 
   21 import java.io.IOException;
 
   22 import java.io.InputStream;
 
   29         private long currentOffset;
 
   30         private final long contentSize;
 
   34                 this.content = content;
 
   35                 this.currentOffset = 0;
 
   36                 this.contentSize = content.
getSize();
 
   41                 byte[] buff = 
new byte[1];
 
   42                 return (
read(buff) != -1) ? buff[0] & 0xFF : -1;
 
   47                 return read(b, 0, b.length);
 
   53                 final int buffLen = b.length;
 
   55                 if (buffLen == 0 || len == 0) {
 
   60                 if (contentSize == 0) {
 
   65                 if (off < 0 || off >= buffLen) {
 
   70                 if (currentOffset >= contentSize) {
 
   75                 int lenToRead = (int) Math.min(contentSize - currentOffset, len);
 
   78                 lenToRead = Math.min(lenToRead, buffLen - off);
 
   86                         retBuf = 
new byte[lenToRead];
 
   89                         final int lenRead = content.
read(retBuf, currentOffset, lenToRead);
 
   91                         if (lenRead == 0 || lenRead == -1) {
 
   95                                 currentOffset += lenRead;
 
   99                                         System.arraycopy(retBuf, 0, b, off, lenRead);
 
  112                 long len = contentSize - currentOffset;
 
  120         public long skip(
long n) 
throws IOException {
 
  123                 long toSkip = Math.min(n, contentSize - currentOffset);  
 
  124                 currentOffset += toSkip;
 
  130         public void close() throws IOException {
 
  156                 return currentOffset;
 
  167         public long seek(
long newPosition) {
 
  168                 if (newPosition < 0) {
 
  169                         throw new IllegalArgumentException(
"Illegal negative new position in the stream");
 
  172                 currentOffset = Math.min(newPosition, contentSize);
 
  173                 return currentOffset;
 
  183                 private static final long serialVersionUID = 1L;
 
  190                         super(message, cause);
 
long seek(long newPosition)
ReadContentInputStreamException(String message, Throwable cause)
int read(byte[] b, int off, int len)
int read(byte[] buf, long offset, long len)
ReadContentInputStream(Content content)
ReadContentInputStreamException(String message)
long getLength()
additional methods to facilitate stream seeking