Coverage Report - org.galagosearch.core.index.PositionalByteStream
 
Classes in this File Line Coverage Branch Coverage Complexity
PositionalByteStream
0%
0/15
0%
0/4
0
 
 1  
 // BSD License (http://www.galagosearch.org/license)
 2  
 
 3  
 package org.galagosearch.core.index;
 4  
 
 5  
 import java.io.EOFException;
 6  
 import java.io.IOException;
 7  
 import java.io.InputStream;
 8  
 
 9  
 public class PositionalByteStream extends InputStream {
 10  0
     int pos = 0;
 11  
     InputStream input;
 12  
     
 13  0
     public PositionalByteStream(InputStream in) {
 14  0
         this.input = in;
 15  0
         this.pos = 0;
 16  0
     }
 17  
     
 18  
     @Override
 19  
     public int read(byte[] buffer) throws IOException {
 20  0
         int result = input.read(buffer);
 21  0
         if(result > 0)
 22  0
             pos += result;
 23  0
         return result;
 24  
     }
 25  
 
 26  
     public int read() throws IOException {
 27  0
         int result = input.read();
 28  0
         if(result >= 0)
 29  0
             pos += 1;
 30  
         else
 31  0
             throw new EOFException("Read off the end of the stream.");
 32  0
         return result;
 33  
     }
 34  
 
 35  
     public int position() {
 36  0
         return pos;
 37  
     }
 38  
 }