Author: tv
Date: Tue Jul 26 18:44:19 2016
New Revision: 1754168

URL: http://svn.apache.org/viewvc?rev=1754168&view=rev
Log:
Remove commons-collections dependency

Modified:
    
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/ListOrderedMapCI.java
    
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
    
db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/SummaryHelperTest.java

Modified: 
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/ListOrderedMapCI.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/ListOrderedMapCI.java?rev=1754168&r1=1754167&r2=1754168&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/ListOrderedMapCI.java
 (original)
+++ 
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/ListOrderedMapCI.java
 Tue Jul 26 18:44:19 2016
@@ -19,17 +19,16 @@ package org.apache.torque.util;
  * under the License.
  */
 
-import org.apache.commons.collections.map.ListOrderedMap;
+import java.util.TreeMap;
 
 /**
- * A subclass of the Apache Commons ListOrderedMap that has case insensitive
- * String key methods.  This is done by converting all String keys to
- * lower case.
+ * A subclass of TreeMap that has case insensitive
+ * String key methods.
  *
  * @author <a href="mailto:greg.mon...@dukece.com";>Greg Monroe</a>
  * @version $Id$
  */
-public class ListOrderedMapCI extends ListOrderedMap
+public class ListOrderedMapCI<T> extends TreeMap<String, T>
 {
     /** Version id for serializing. */
     private static final long serialVersionUID = -4349246328751938554L;
@@ -39,72 +38,6 @@ public class ListOrderedMapCI extends Li
      */
     public ListOrderedMapCI()
     {
-        super();
-    }
-
-    /**
-     * Get the object associated with this key.
-     *
-     * @param key A case insensitive String.
-     * @return The value for this key
-     */
-    public Object get(String key)
-    {
-       return super.get(key.toLowerCase());
-    }
-
-    /**
-     * Adds a value to the end of the list with the specified key.
-     *
-     * @param key A case insensitive String.
-     * @param value The value to add
-     * @return The value for previously mapped to this key
-     */
-    public Object put(String key, Object value)
-    {
-        return super.put(key.toLowerCase(), value);
-    }
-
-    /**
-     * Puts a key-value mapping into the map at the specified index.
-     *
-     * @param index The index at which the mapping should be inserted.
-     * @param key A case insensitive String.
-     * @param value The value.
-     *
-     * @return The value for previously mapped to this key
-     */
-    public Object put(int index, String key, Object value)
-    {
-        return super.put(index, key.toLowerCase(), value);
-    }
-    /**
-     * Gets the index of the specified key.
-     *
-     * @param key A case insensitive String.
-     * @return the index, or -1 if not found
-     */
-    public int indexOf(String key)
-    {
-        return super.indexOf(key.toLowerCase());
-    }
-    /**
-     * Removes the mapping for the specified key.
-     * @param key A case insensitive String.
-     * @return the removed value, or null if none existed
-     */
-    public Object remove (String key)
-    {
-        return super.remove(key.toLowerCase());
-    }
-    /**
-     * Test if the key exists in the mapping.
-     *
-     * @param key The case insensitive key to test for.
-     * @return True if the key exists.
-     */
-    public boolean containsKey(String key)
-    {
-        return super.containsKey(key.toLowerCase());
+        super(String.CASE_INSENSITIVE_ORDER);
     }
 }

Modified: 
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java?rev=1754168&r1=1754167&r2=1754168&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
 (original)
+++ 
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
 Tue Jul 26 18:44:19 2016
@@ -25,9 +25,9 @@ import java.sql.Connection;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Vector;
 
-import org.apache.commons.collections.OrderedMapIterator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.torque.Column;
@@ -95,7 +95,7 @@ public class SummaryHelper
     private List<Column> groupByColumns;
     /** A ListOrderMapCI<String, Aggregate.Function> with the aggregate 
functions
      * to use in generating results. */
-    private ListOrderedMapCI aggregates;
+    private ListOrderedMapCI<SQLFunction> aggregates;
     /** Flag for excluding unnamed columns. */
     private boolean excludeExprColumns = false;
 
@@ -112,7 +112,7 @@ public class SummaryHelper
      *
      * @throws TorqueException if a database error occurs.
      */
-    public List<ListOrderedMapCI> summarize(
+    public List<ListOrderedMapCI<Object>> summarize(
                 final Criteria crit)
             throws TorqueException
     {
@@ -134,7 +134,7 @@ public class SummaryHelper
      *
      * @throws TorqueException if a database error occurs.
      */
-    public List<ListOrderedMapCI> summarize(
+    public List<ListOrderedMapCI<Object>> summarize(
                 final Criteria crit,
                 final List<Class<?>> resultTypes)
             throws TorqueException
@@ -143,7 +143,7 @@ public class SummaryHelper
         try
         {
             connection = Transaction.begin(crit.getDbName());
-            List<ListOrderedMapCI> result = summarize(crit, resultTypes, 
connection);
+            List<ListOrderedMapCI<Object>> result = summarize(crit, 
resultTypes, connection);
             Transaction.commit(connection);
             connection = null;
             return result;
@@ -171,7 +171,7 @@ public class SummaryHelper
      *
      * @throws TorqueException if a database error occurs.
      */
-    public List<ListOrderedMapCI> summarize(
+    public List<ListOrderedMapCI<Object>> summarize(
                 final Criteria crit,
                 final Connection conn)
             throws TorqueException
@@ -195,7 +195,7 @@ public class SummaryHelper
      *
      * @throws TorqueException if a database error occurs.
      */
-    public List<ListOrderedMapCI> summarize(
+    public List<ListOrderedMapCI<Object>> summarize(
                 final Criteria crit,
                 final List<Class<?>> resultTypes,
                 final Connection conn)
@@ -217,8 +217,8 @@ public class SummaryHelper
         List<List<Object>> rows
                 = peer.doSelect(c, new ObjectListMapper(resultTypes), conn);
 
-        List<ListOrderedMapCI> resultsList
-                = new ArrayList<ListOrderedMapCI>(rows.size());
+        List<ListOrderedMapCI<Object>> resultsList
+                = new ArrayList<ListOrderedMapCI<Object>>(rows.size());
         List<String> columnNames = new ArrayList<String>();
         for (Column column : c.getSelectColumns())
         {
@@ -227,7 +227,7 @@ public class SummaryHelper
         columnNames.addAll(c.getAsColumns().keySet());
         for (List<Object> row : rows)
         {
-            ListOrderedMapCI recordMap = new ListOrderedMapCI();
+            ListOrderedMapCI<Object> recordMap = new 
ListOrderedMapCI<Object>();
             for (int i = 0; i < row.size(); i++)
             {
                 Object value = row.get(i);
@@ -290,14 +290,11 @@ public class SummaryHelper
             logger.debug("From table defined by a where clause");
         }
 
-        ListOrderedMapCI cMap = getAggregates();
-        OrderedMapIterator iMap = cMap.orderedMapIterator();
-        while (iMap.hasNext())
+        for (Map.Entry<String, SQLFunction> entry : getAggregates().entrySet())
         {
-            String key = (String) iMap.next();
-            SQLFunction f = (SQLFunction) iMap.getValue();
+            SQLFunction f = entry.getValue();
             Column col =  f.getColumn();
-            c.addAsColumn(key, new ColumnImpl(
+            c.addAsColumn(entry.getKey(), new ColumnImpl(
                     null,
                     col.getTableName(),
                     col.getColumnName(),
@@ -385,11 +382,11 @@ public class SummaryHelper
      *
      * @return the avgColumns.  Will always return a ListOrderedMap object.
      */
-    public ListOrderedMapCI getAggregates()
+    public ListOrderedMapCI<SQLFunction> getAggregates()
     {
         if (aggregates == null)
         {
-            aggregates = new ListOrderedMapCI();
+            aggregates = new ListOrderedMapCI<SQLFunction>();
         }
         return aggregates;
     }
@@ -412,13 +409,15 @@ public class SummaryHelper
 
         while (i.hasNext())
         {
-            ListOrderedMapCI rec = (ListOrderedMapCI) i.next();
-            OrderedMapIterator rI = rec.orderedMapIterator();
+            @SuppressWarnings("unchecked")
+            ListOrderedMapCI<Object> rec = (ListOrderedMapCI<Object>) i.next();
+            Iterator<Map.Entry<String, Object>> rI = rec.entrySet().iterator();
             StringBuilder heading = new StringBuilder();
             StringBuilder recString = new StringBuilder();
             while (rI.hasNext())
             {
-                String colId = (String) rI.next();
+                Map.Entry<String, Object> entry = rI.next();
+                String colId = entry.getKey();
                 if (first)
                 {
                     heading.append("\"").append(colId).append("\"");
@@ -427,7 +426,7 @@ public class SummaryHelper
                         heading.append(", ");
                     }
                 }
-                Object v = rI.getValue();
+                Object v = entry.getValue();
                 recString.append(v.toString());
                 if (rI.hasNext())
                 {

Modified: 
db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/SummaryHelperTest.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/SummaryHelperTest.java?rev=1754168&r1=1754167&r2=1754168&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/SummaryHelperTest.java
 (original)
+++ 
db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/SummaryHelperTest.java
 Tue Jul 26 18:44:19 2016
@@ -143,7 +143,7 @@ public class SummaryHelperTest extends B
 
         // execute
         summary.addAggregate("count", new Count(columnMap1));
-        List<ListOrderedMapCI> results = summary.summarize(criteria, 
connection);
+        List<ListOrderedMapCI<Object>> results = summary.summarize(criteria, 
connection);
 
         // Verify result
         assertEquals(1, results.size());



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org
For additional commands, e-mail: torque-dev-h...@db.apache.org

Reply via email to