Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * CursorCursorFeed.java
  *
  * Created on March 24, 2005, 9:56 AM
  */
 
 package org.sapia.util.cursor.impl;
 

Author(s):
yduchesne
public class CursorCursorFeed implements CursorFeed{
  
  private Cursor _cursor;
  private boolean _enableClose;
  private Batch _current;
  
  public CursorCursorFeed(Cursor cursor){
     = cursor;
  }
  
  
Indicates if this instance should close its underlying cursor upon its own close() method being called. Defaults to false.

Parameters:
enabled if true, this instance will call its encapsulated cursor's own close() method.
  public void setEnableClose(boolean enabled){
     = enabled;
  }
  
  public int read(Object[] bufferthrows Exception{
    if( == null || !.hasNext()){
      if(.hasNextBatch()){
         = .nextBatch();
        if(!.hasNext()){
          return 0;
        }
      }
      else{
        return 0;
      }
    }
    int count = 0;
    while(count < buffer.length){
      buffer[count] = .next();
      count++;
    }
    return count;
  }
  public int available() throws Exception{
    if( == null || !.hasNext()){
      if(.hasNextBatch()){
         = .nextBatch();
        if(!.hasNext()){
          return 0;
        }
        return .getCount();
      }
      else{
        return 0;
      }
    }
    return .getCount() - .getPos();
  }
  
  public void close(){
    if()
      .close();
  }
  
New to GrepCode? Check out our FAQ X