Skip to main content

[el-spec commits] [el-spec~source-code:49] sync up sources

  • From: kchung@...
  • To: commits@...
  • Subject: [el-spec commits] [el-spec~source-code:49] sync up sources
  • Date: Mon, 27 Feb 2012 22:31:26 +0000

Project:    el-spec
Repository: source-code
Revision:   49
Author:     kchung
Date:       2012-02-27 22:31:25 UTC
Link:       

Log Message:
------------
sync up sources




Revisions:
----------
49


Modified Paths:
---------------
trunk/impl/src/main/java/com/sun/el/query/ToLookup.java
trunk/impl/src/test/java/org/glassfish/el/test/LinqTest.java
trunk/impl/src/main/java/com/sun/el/query/Aggregate.java


Diffs:
------
Index: trunk/impl/src/test/java/org/glassfish/el/test/LinqTest.java
===================================================================
--- trunk/impl/src/test/java/org/glassfish/el/test/LinqTest.java        
(revision 48)
+++ trunk/impl/src/test/java/org/glassfish/el/test/LinqTest.java        
(revision 49)
@@ -16,7 +16,7 @@
     ELProcessor elp;
 
     @Before
-    public void setUP() {
+    public void setup() {
         Manager manager = Manager.getManager();
         manager.setupDB();
         elp = manager.getElp();
@@ -26,8 +26,8 @@
         System.out.println(msg);
     }
 
-    /*
-     * Test a Lingq query that returns a Map
+    /**
+     * Test a Ling query that returns a Map
      * @param name of the test
      * @param query The EL query string
      * @param expected The expected result of the Map. The element of the
@@ -54,7 +54,7 @@
         assertTrue(indx == expected.length);
     }
 
-    /*
+    /**
      * Test a Linq query that returns an Iterable.
      * @param name of the test
      * @param query The EL query string
Index: trunk/impl/src/main/java/com/sun/el/query/ToLookup.java
===================================================================
--- trunk/impl/src/main/java/com/sun/el/query/ToLookup.java     (revision 48)
+++ trunk/impl/src/main/java/com/sun/el/query/ToLookup.java     (revision 49)
@@ -12,7 +12,7 @@
 
 class ToLookup extends QueryOperator {
     @Override
-    public Map<Object, ArrayListGrouping<Object,Object>> invoke(
+    public Map<Object, GroupingImpl<Object,Object>> invoke(
                                    final ELContext context,
                                    final Iterable<Object> base,
                                    final Object[] params) {
@@ -25,8 +25,8 @@
         }
         final Comparator cmp = getComparator("toLookup", params, indexC, 
true);
 
-        Map<Object, ArrayListGrouping<Object,Object>> map =
-                    new HashMap<Object, ArrayListGrouping<Object,Object>>();
+        Map<Object, GroupingImpl<Object,Object>> map =
+                    new HashMap<Object, GroupingImpl<Object,Object>>();
 
         for (Object element: base) {
             Object key = keySelector.invoke(context, element);
@@ -39,16 +39,16 @@
         return map;
     }
 
-    private void addToGroup(Map<Object, ArrayListGrouping<Object,Object>> 
map,
+    private void addToGroup(Map<Object, GroupingImpl<Object,Object>> map,
                             Object key, Object value) {
         if (key == null || value == null) {
             return;
         }
 
-        ArrayListGrouping<Object, Object> g;
+        GroupingImpl<Object, Object> g;
         g = map.get(key);
         if (g == null) {
-            g = new ArrayListGrouping<Object,Object>(key);
+            g = new GroupingImpl<Object,Object>(key);
             map.put(key, g);
         }
         g.add(value);
Index: trunk/impl/src/main/java/com/sun/el/query/Aggregate.java
===================================================================
--- trunk/impl/src/main/java/com/sun/el/query/Aggregate.java    (revision 48)
+++ trunk/impl/src/main/java/com/sun/el/query/Aggregate.java    (revision 49)
@@ -11,26 +11,26 @@
                                    final Object[] params) {
         int curArg = 0;
         // Get the seed and set it to the accumulator
-        Object accumulator = getArgument("aggregate", params, curArg);
+        Object accumulator = getArgument("aggregate", params, curArg++);
         LambdaExpression func;
         if (accumulator instanceof LambdaExpression) {
             func = (LambdaExpression) accumulator;
             accumulator = null;
         } else {
-            curArg++;
             func = getLambda("aggregate", params, curArg++);
         }
         LambdaExpression resultSelector =
                 getLambda("aggregate", params, curArg, true);
         Iterator<Object> iter = base.iterator();
 
+        boolean first = true;
         while (iter.hasNext()) {
             Object element = iter.next();
-            if (accumulator == null) {
+            if (accumulator == null && first) {
                 accumulator = element;
-            } else {
-                accumulator = func.invoke(context, accumulator, element);
             }
+            first = false;
+            accumulator = func.invoke(context, accumulator, element);
         }
         if (resultSelector == null) {
             return accumulator;





[el-spec commits] [el-spec~source-code:49] sync up sources

kchung 02/27/2012
 
 
Close
loading
Please Confirm
Close