package mir.entity;\r
\r
+import java.util.*;\r
+import mir.util.*;\r
import mir.storage.*;\r
import mir.entity.*;\r
\r
-public class EntityBrowser {\r
+public class EntityBrowser implements RewindableIterator {\r
\r
private StorageObject storage;\r
private String whereClause;\r
rewind();\r
}\r
\r
- private void rewind() throws StorageObjectException {\r
- currentBatch = storage.selectByWhereClause(whereClause, orderByClause,\r
- 0, batchSize);\r
-\r
- position=0;\r
+ public void rewind() {\r
+ try {\r
+ currentBatch = storage.selectByWhereClause(whereClause, orderByClause, 0, batchSize);\r
+ position=0;\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
}\r
\r
private void readNextBatch() throws StorageObjectException {\r
}\r
}\r
\r
- public boolean hasNext() throws StorageObjectException {\r
- if (position>=currentBatch.size() && currentBatch.hasNextBatch()) {\r
- readNextBatch();\r
- }\r
+ public boolean hasNext() {\r
+ try {\r
+ if (position>=currentBatch.size() && currentBatch.hasNextBatch()) {\r
+ readNextBatch();\r
+ }\r
\r
- return (position<currentBatch.size());\r
+ return (position<currentBatch.size());\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
}\r
\r
- public Entity next() throws StorageObjectException {\r
- if (hasNext()) {\r
- Entity result = currentBatch.elementAt(position);\r
- position=position+1;\r
+ public Object next() {\r
+ try {\r
+ if (hasNext()) {\r
+ Entity result = currentBatch.elementAt(position);\r
+ position=position+1;\r
\r
- return result;\r
+ return result;\r
+ }\r
+ else {\r
+ return null;\r
+ }\r
}\r
- else {\r
- return null;\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
}\r
}\r
+\r
+ public void remove() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
}
\ No newline at end of file