Coverage Report - org.galagosearch.tupleflow.OrderedReader
 
Classes in this File Line Coverage Branch Coverage Complexity
OrderedReader
0%
0/23
0%
0/2
0
 
 1  
 // BSD License (http://www.galagosearch.org/license)
 2  
 
 3  
 package org.galagosearch.tupleflow;
 4  
 
 5  
 import java.io.EOFException;
 6  
 import java.io.IOException;
 7  
 
 8  
 public abstract class OrderedReader<T> implements TypeReader<T>, ExNihiloSource<T> {
 9  
     protected Processor<T> processor;
 10  
     protected ArrayInput input;
 11  
     protected boolean needsInit;
 12  0
     protected T last = null;
 13  0
     protected int batchCount = 0;
 14  
     
 15  0
     public OrderedReader(ArrayInput input, Processor<T> processor) {
 16  0
         this.input = input;
 17  0
         this.processor = processor;
 18  0
         needsInit = true;
 19  0
         last = clone(null);
 20  0
     }
 21  
     
 22  
     public OrderedReader(ArrayInput input) {
 23  0
         this(input, null);
 24  0
     }
 25  
     
 26  
     public void setProcessor(Processor<T> processor) {
 27  0
         this.processor = processor;
 28  0
     }
 29  
 
 30  
     public void run() throws IOException {
 31  0
         T object = null;
 32  0
         while ((object = read()) != null) {
 33  0
             processor.process(object);
 34  
         }
 35  0
         processor.close();
 36  0
     }
 37  
     
 38  
     public T read() throws IOException {
 39  
         try {
 40  0
             readTuple();
 41  0
         } catch(EOFException e) {
 42  0
             return null;
 43  0
         }
 44  
         
 45  0
         return clone(last);
 46  
     }
 47  
     
 48  0
     public void readTuple() throws IOException {}
 49  
     public abstract T clone(T object);
 50  
 }