You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/08/19 08:25:22 UTC

svn commit: r567356 - /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java

Author: jstrachan
Date: Sat Aug 18 23:25:21 2007
New Revision: 567356

URL: http://svn.apache.org/viewvc?view=rev&rev=567356
Log:
added some extra collection converter helper methods

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java?view=diff&rev=567356&r1=567355&r2=567356
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java Sat Aug 18 23:25:21 2007
@@ -16,15 +16,10 @@
  */
 package org.apache.camel.converter;
 
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.camel.Converter;
 
+import java.util.*;
+
 /**
  * Some core java.util Collection based
  * <a href="http://activemq.apache.org/camel/type-converter.html">Type Converters</a>
@@ -33,11 +28,10 @@
  */
 @Converter
 public class CollectionConverter {
-
     /**
      * Utility classes should not have a public constructor.
      */
-    private CollectionConverter() {        
+    private CollectionConverter() {
     }
 
     /**
@@ -59,6 +53,14 @@
         return Arrays.asList(array);
     }
 
+    /**
+     * Converts a collection to a List if it is not already
+     */
+    @Converter
+    public static List toList(Collection collection) {
+        return new ArrayList(collection);
+    }
+
     @Converter
     public static Set toSet(Object[] array) {
         Set answer = new HashSet();
@@ -76,5 +78,22 @@
     @Converter
     public static Set toSet(Map map) {
         return map.entrySet();
+    }
+
+    @Converter
+    public static Properties toProperties(Map map) {
+        Properties answer = new Properties();
+        answer.putAll(map);
+        return answer;
+    }
+
+    @Converter
+    public static Hashtable toHashtable(Map map) {
+        return new Hashtable(map);
+    }
+
+    @Converter
+    public static HashMap toHashMap(Map map) {
+        return new HashMap(map);
     }
 }



Re: svn commit: r567356 - /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java

Posted by Glen Mazza <gl...@verizon.net>.
Am Sonntag, den 19.08.2007, 06:25 +0000 schrieb jstrachan@apache.org:
> Author: jstrachan
> Date: Sat Aug 18 23:25:21 2007
> New Revision: 567356
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=567356
> Log:
> added some extra collection converter helper methods
> 
> Modified:
>     activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/CollectionConverter.java
> 
>  
> +import java.util.*;

Wildcard imports don't look very good IMO.

Glen