Author: doogie
Date: Wed Oct 17 20:07:05 2007 New Revision: 585809 URL: http://svn.apache.org/viewvc?rev=585809&view=rev Log: EntityListIterator is now generified. Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java?rev=585809&r1=585808&r2=585809&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java Wed Oct 17 20:07:05 2007 @@ -43,7 +43,7 @@ /** * Generic Entity Cursor List Iterator for Handling Cursored DB Results */ -public class EntityListIterator implements ListIterator { +public class EntityListIterator implements ListIterator<GenericValue> { /** Module Name Used for debugging */ public static final String module = EntityListIterator.class.getName(); @@ -51,7 +51,7 @@ protected SQLProcessor sqlp; protected ResultSet resultSet; protected ModelEntity modelEntity; - protected List selectFields; + protected List<ModelField> selectFields; protected ModelFieldTypeReader modelFieldTypeReader; protected boolean closed = false; protected boolean haveMadeValue = false; @@ -59,7 +59,7 @@ private boolean haveShowHasNextWarning = false; - public EntityListIterator(SQLProcessor sqlp, ModelEntity modelEntity, List selectFields, ModelFieldTypeReader modelFieldTypeReader) { + public EntityListIterator(SQLProcessor sqlp, ModelEntity modelEntity, List<ModelField> selectFields, ModelFieldTypeReader modelFieldTypeReader) { this.sqlp = sqlp; this.resultSet = sqlp.getResultSet(); this.modelEntity = modelEntity; @@ -140,7 +140,7 @@ GenericValue value = GenericValue.create(modelEntity); for (int j = 0; j < selectFields.size(); j++) { - ModelField curField = (ModelField) selectFields.get(j); + ModelField curField = selectFields.get(j); SqlJdbcUtil.getValue(resultSet, j + 1, curField, value, modelFieldTypeReader); } @@ -281,7 +281,7 @@ * while ((nextValue = (GenericValue) this.next()) != null) { ... } * */ - public Object next() { + public GenericValue next() { try { if (resultSet.next()) { return currentGenericValue(); @@ -329,7 +329,7 @@ } /** Moves the cursor to the previous position and returns the GenericValue object for that position; if there is no previous, returns null */ - public Object previous() { + public GenericValue previous() { try { if (resultSet.previous()) { return currentGenericValue(); @@ -388,15 +388,15 @@ } } - public List getCompleteList() throws GenericEntityException { + public List<GenericValue> getCompleteList() throws GenericEntityException { try { // if the resultSet has been moved forward at all, move back to the beginning if (haveMadeValue && !resultSet.isBeforeFirst()) { // do a quick check to see if the ResultSet is empty resultSet.beforeFirst(); } - List list = FastList.newInstance(); - Object nextValue = null; + List<GenericValue> list = FastList.newInstance(); + GenericValue nextValue = null; while ((nextValue = this.next()) != null) { list.add(nextValue); @@ -420,10 +420,10 @@ /** Gets a partial list of results starting at start and containing at most number elements. * Start is a one based value, ie 1 is the first element. */ - public List getPartialList(int start, int number) throws GenericEntityException { + public List<GenericValue> getPartialList(int start, int number) throws GenericEntityException { try { if (number == 0) return FastList.newInstance(); - List list = FastList.newInstance(); + List<GenericValue> list = FastList.newInstance(); // just in case the caller missed the 1 based thingy if (start == 0) start = 1; @@ -445,7 +445,7 @@ // get the first as the current one list.add(this.currentGenericValue()); - Object nextValue = null; + GenericValue nextValue = null; // init numRetreived to one since we have already grabbed the initial one int numRetreived = 1; @@ -470,7 +470,7 @@ } } - public void add(Object obj) { + public void add(GenericValue obj) { throw new GeneralRuntimeException("CursorListIterator currently only supports read-only access"); } @@ -478,7 +478,7 @@ throw new GeneralRuntimeException("CursorListIterator currently only supports read-only access"); } - public void set(Object obj) { + public void set(GenericValue obj) { throw new GeneralRuntimeException("CursorListIterator currently only supports read-only access"); } |
Free forum by Nabble | Edit this page |