Skip to main content

[el-spec commits] [el-spec~source-code:101] Add index to forEach

  • From: kchung@...
  • To: commits@...
  • Subject: [el-spec commits] [el-spec~source-code:101] Add index to forEach
  • Date: Tue, 22 May 2012 03:14:23 +0000

Project:    el-spec
Repository: source-code
Revision:   101
Author:     kchung
Date:       2012-05-22 03:14:22 UTC
Link:       

Log Message:
------------
Add index to forEach




Revisions:
----------
101


Modified Paths:
---------------
trunk/impl/src/main/java/com/sun/el/query/QueryOperator.java
trunk/impl/src/main/java/com/sun/el/query/ForEach.java


Diffs:
------
Index: trunk/impl/src/main/java/com/sun/el/query/ForEach.java
===================================================================
--- trunk/impl/src/main/java/com/sun/el/query/ForEach.java      (revision 100)
+++ trunk/impl/src/main/java/com/sun/el/query/ForEach.java      (revision 101)
@@ -46,15 +46,15 @@
 import javax.el.LambdaExpression;
 
 class ForEach extends QueryOperator {
-
     @Override
     public Object invoke(final ELContext context,
-                       final Iterable<Object> base,
-                       final Object[] params) {
-        final LambdaExpression func = getLambda("forEach", params, 0, false);
+                         final Iterable<Object> base,
+                         final Object[] params) {
 
-        for (Object item: base) {
-            func.invoke(context, item);
+        final LambdaExpression action = getLambda("forEach", params, 0, 
false);
+        int index = 0;
+        for (Object obj: base) {
+            action.invoke(context, obj, index);
         }
         return null;
     }
Index: trunk/impl/src/main/java/com/sun/el/query/QueryOperator.java
===================================================================
--- trunk/impl/src/main/java/com/sun/el/query/QueryOperator.java        
(revision 100)
+++ trunk/impl/src/main/java/com/sun/el/query/QueryOperator.java        
(revision 101)
@@ -103,8 +103,8 @@
         operators.put("min", new Min());
         operators.put("max", new Max());
         operators.put("average", new Average());
+        operators.put("aggregate", new Aggregate());
         operators.put("forEach", new ForEach());
-        operators.put("aggregate", new Aggregate());
     }
 
     public abstract Object invoke(ELContext context,





[el-spec commits] [el-spec~source-code:101] Add index to forEach

kchung 05/22/2012
 
 
Close
loading
Please Confirm
Close