1 package org.sapia.util.cursor.impl; 2 3 import java.util.List ; 4 5 import org.sapia.util.cursor.CursorFeed; 6 7 19 public class ListCursorFeed implements CursorFeed{ 20 21 private List _feed; 22 private int _currentIndex; 23 private boolean _closed; 24 25 public ListCursorFeed(List feed){ 26 _feed = feed; 27 } 28 29 32 public int read(Object [] buffer) throws Exception { 33 int count = 0; 34 if(_closed || _currentIndex >= _feed.size()){ 35 return 0; 36 } 37 for(; count < buffer.length; _currentIndex++, count++){ 38 buffer[count] =_feed.get(_currentIndex); 39 } 40 return count; 41 } 42 43 46 public int available() throws Exception { 47 if(_closed){ 48 return 0; 49 } 50 return _feed.size() - _currentIndex; 51 } 52 53 56 public void close() { 57 _closed = true; 58 } 59 } 60 | Popular Tags |