svn commit: r815936 - /ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r815936 - /ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java

doogie-3
Author: doogie
Date: Wed Sep 16 19:33:44 2009
New Revision: 815936

URL: http://svn.apache.org/viewvc?rev=815936&view=rev
Log:
Based on OFBIZ-891, allow Iterate to handle java.util.Iterator.

Modified:
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java?rev=815936&r1=815935&r2=815936&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java Wed Sep 16 19:33:44 2009
@@ -104,13 +104,9 @@
                     return false;
                 }
             }
-        } else {
+        } else if (objList instanceof Collection) {
             Collection<Object> theList = UtilGenerics.checkList(objList);
 
-            if (theList == null) {
-                if (Debug.infoOn()) Debug.logInfo("List not found with name " + listAcsr + ", doing nothing: " + rawString(), module);
-                return true;
-            }
             if (theList.size() == 0) {
                 if (Debug.verboseOn()) Debug.logVerbose("List with name " + listAcsr + " has zero entries, doing nothing: " + rawString(), module);
                 return true;
@@ -124,6 +120,25 @@
                     return false;
                 }
             }
+        } else if (objList instanceof Iterator) {
+            Iterator<Object> theIterator = UtilGenerics.cast(objList);
+            if (!theIterator.hasNext()) {
+                if (Debug.verboseOn()) Debug.logVerbose("List with name " + listAcsr + " has no more entries, doing nothing: " + rawString(), module);
+                return true;
+            }
+
+            while (theIterator.hasNext()) {
+                Object theEntry = theIterator.next();
+                entryAcsr.put(methodContext, theEntry);
+
+                if (!SimpleMethod.runSubOps(subOps, methodContext)) {
+                    // only return here if it returns false, otherwise just carry on
+                    return false;
+                }
+            }
+        } else {
+            if (Debug.infoOn()) Debug.logInfo("List not found with name " + listAcsr + ", doing nothing: " + rawString(), module);
+            return true;
         }
         entryAcsr.put(methodContext, oldEntryValue);
         return true;