1 40 package org.dspace.content; 41 42 import java.sql.SQLException ; 43 44 import org.dspace.core.Context; 45 import org.dspace.storage.rdbms.TableRow; 46 import org.dspace.storage.rdbms.TableRowIterator; 47 48 57 public class ItemIterator 58 { 59 62 63 64 private Context ourContext; 65 66 67 private TableRowIterator itemRows; 68 69 78 ItemIterator(Context context, TableRowIterator rows) 79 { 80 ourContext = context; 81 itemRows = rows; 82 } 83 84 89 public boolean hasNext() throws SQLException 90 { 91 return itemRows.hasNext(); 92 } 93 94 100 public Item next() throws SQLException 101 { 102 if (itemRows.hasNext()) 103 { 104 TableRow row = itemRows.next(); 106 107 Item fromCache = (Item) ourContext.fromCache(Item.class, row 109 .getIntColumn("item_id")); 110 111 if (fromCache != null) 112 { 113 return fromCache; 114 } 115 else 116 { 117 return new Item(ourContext, row); 118 } 119 } 120 else 121 { 122 return null; 123 } 124 } 125 } 126 | Popular Tags |