You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2013/11/08 22:08:33 UTC

svn commit: r1540186 [3/6] - in /commons/proper/beanutils/trunk: ./ src/changes/ src/main/java/org/apache/commons/beanutils/ src/main/java/org/apache/commons/beanutils/converters/ src/main/java/org/apache/commons/beanutils/locale/ src/test/java/org/apa...

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java Fri Nov  8 21:08:30 2013
@@ -30,6 +30,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.commons.beanutils.expression.DefaultResolver;
 import org.apache.commons.beanutils.expression.Resolver;
@@ -112,10 +113,10 @@ public class PropertyUtilsBean {
      * The cache of PropertyDescriptor arrays for beans we have already
      * introspected, keyed by the java.lang.Class of this object.
      */
-    private WeakFastHashMap descriptorsCache = null;
-    private WeakFastHashMap mappedDescriptorsCache = null;
-    private static final Class[] EMPTY_CLASS_PARAMETERS = new Class[0];
-    private static final Class[] LIST_CLASS_PARAMETER = new Class[] {java.util.List.class};
+    private WeakFastHashMap<Class<?>, PropertyDescriptor[]> descriptorsCache = null;
+    private WeakFastHashMap<Class<?>, FastHashMap> mappedDescriptorsCache = null;
+    private static final Class<?>[] EMPTY_CLASS_PARAMETERS = new Class[0];
+    private static final Class<?>[] LIST_CLASS_PARAMETER = new Class[] {java.util.List.class};
 
     /** An empty object array */
     private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
@@ -127,9 +128,9 @@ public class PropertyUtilsBean {
 
     /** Base constructor */
     public PropertyUtilsBean() {
-        descriptorsCache = new WeakFastHashMap();
+        descriptorsCache = new WeakFastHashMap<Class<?>, PropertyDescriptor[]>();
         descriptorsCache.setFast(true);
-        mappedDescriptorsCache = new WeakFastHashMap();
+        mappedDescriptorsCache = new WeakFastHashMap<Class<?>, FastHashMap>();
         mappedDescriptorsCache.setFast(true);
     }
 
@@ -253,9 +254,9 @@ public class PropertyUtilsBean {
                 }
             }
         } else if (orig instanceof Map) {
-            Iterator entries = ((Map) orig).entrySet().iterator();
+            Iterator<?> entries = ((Map<?, ?>) orig).entrySet().iterator();
             while (entries.hasNext()) {
-                Map.Entry entry = (Map.Entry) entries.next();
+                Map.Entry<?, ?> entry = (Entry<?, ?>) entries.next();
                 String name = (String)entry.getKey();
                 if (isWriteable(dest, name)) {
                     try {
@@ -315,14 +316,14 @@ public class PropertyUtilsBean {
      * @exception NoSuchMethodException if an accessor method for this
      *  propety cannot be found
      */
-    public Map describe(Object bean)
+    public Map<String, Object> describe(Object bean)
             throws IllegalAccessException, InvocationTargetException,
             NoSuchMethodException {
 
         if (bean == null) {
             throw new IllegalArgumentException("No bean specified");
         }
-        Map description = new HashMap();
+        Map<String, Object> description = new HashMap<String, Object>();
         if (bean instanceof DynaBean) {
             DynaProperty[] descriptors =
                 ((DynaBean) bean).getDynaClass().getDynaProperties();
@@ -438,7 +439,7 @@ public class PropertyUtilsBean {
             if (bean.getClass().isArray()) {
                 return Array.get(bean, index);
             } else if (bean instanceof List) {
-                return ((List)bean).get(index);
+                return ((List<?>)bean).get(index);
             }
         }
         if (name == null) {
@@ -502,7 +503,7 @@ public class PropertyUtilsBean {
                         "' is not indexed on bean class '" + bean.getClass() + "'");
             } else {
                 //get the List's value
-                return ((java.util.List) value).get(index);
+                return ((java.util.List<?>) value).get(index);
             }
         } else {
             //get the array's value
@@ -646,7 +647,7 @@ public class PropertyUtilsBean {
             Object invokeResult = invokeMethod(readMethod, bean, EMPTY_OBJECT_ARRAY);
             /* test and fetch from the map */
             if (invokeResult instanceof java.util.Map) {
-              result = ((java.util.Map)invokeResult).get(key);
+              result = ((java.util.Map<?, ?>)invokeResult).get(key);
             }
           } else {
             throw new NoSuchMethodException("Property '" + name +
@@ -669,14 +670,14 @@ public class PropertyUtilsBean {
      * @deprecated This method should not be exposed
      */
     @Deprecated
-    public FastHashMap getMappedPropertyDescriptors(Class beanClass) {
+    public FastHashMap getMappedPropertyDescriptors(Class<?> beanClass) {
 
         if (beanClass == null) {
             return null;
         }
 
         // Look up any cached descriptors for this bean class
-        return (FastHashMap) mappedDescriptorsCache.get(beanClass);
+        return mappedDescriptorsCache.get(beanClass);
 
     }
 
@@ -737,7 +738,7 @@ public class PropertyUtilsBean {
             String next = resolver.next(name);
             Object nestedBean = null;
             if (bean instanceof Map) {
-                nestedBean = getPropertyOfMapBean((Map) bean, next);
+                nestedBean = getPropertyOfMapBean((Map<?, ?>) bean, next);
             } else if (resolver.isMapped(next)) {
                 nestedBean = getMappedProperty(bean, next);
             } else if (resolver.isIndexed(next)) {
@@ -755,7 +756,7 @@ public class PropertyUtilsBean {
         }
 
         if (bean instanceof Map) {
-            bean = getPropertyOfMapBean((Map) bean, name);
+            bean = getPropertyOfMapBean((Map<?, ?>) bean, name);
         } else if (resolver.isMapped(name)) {
             bean = getMappedProperty(bean, name);
         } else if (resolver.isIndexed(name)) {
@@ -791,7 +792,7 @@ public class PropertyUtilsBean {
      * no simple method is available.
      * @since 1.8.0
      */
-    protected Object getPropertyOfMapBean(Map bean, String propertyName)
+    protected Object getPropertyOfMapBean(Map<?, ?> bean, String propertyName)
         throws IllegalArgumentException, IllegalAccessException,
         InvocationTargetException, NoSuchMethodException {
 
@@ -954,7 +955,7 @@ public class PropertyUtilsBean {
      * @exception IllegalArgumentException if <code>beanClass</code> is null
      */
     public PropertyDescriptor[]
-            getPropertyDescriptors(Class beanClass) {
+            getPropertyDescriptors(Class<?> beanClass) {
 
         if (beanClass == null) {
             throw new IllegalArgumentException("No bean class specified");
@@ -963,7 +964,7 @@ public class PropertyUtilsBean {
         // Look up any cached descriptors for this bean class
         PropertyDescriptor[] descriptors = null;
         descriptors =
-                (PropertyDescriptor[]) descriptorsCache.get(beanClass);
+                descriptorsCache.get(beanClass);
         if (descriptors != null) {
             return (descriptors);
         }
@@ -1031,7 +1032,7 @@ public class PropertyUtilsBean {
                         Method[] methods = beanClass.getMethods();
                         for (int j = 0; j < methods.length; j++) {
                             if (methods[j].getName().equals(methodName)) {
-                                Class[] parameterTypes = methods[j].getParameterTypes();
+                                Class<?>[] parameterTypes = methods[j].getParameterTypes();
                                 if (parameterTypes.length == 1 &&
                                     List.class.isAssignableFrom(parameterTypes[0])) {
                                     writeMethod = methods[j];
@@ -1110,7 +1111,7 @@ public class PropertyUtilsBean {
      * @exception NoSuchMethodException if an accessor method for this
      *  propety cannot be found
      */
-    public Class getPropertyEditorClass(Object bean, String name)
+    public Class<?> getPropertyEditorClass(Object bean, String name)
             throws IllegalAccessException, InvocationTargetException,
             NoSuchMethodException {
 
@@ -1158,7 +1159,7 @@ public class PropertyUtilsBean {
      * @exception NoSuchMethodException if an accessor method for this
      *  propety cannot be found
      */
-    public Class getPropertyType(Object bean, String name)
+    public Class<?> getPropertyType(Object bean, String name)
             throws IllegalAccessException, InvocationTargetException,
             NoSuchMethodException {
 
@@ -1193,7 +1194,7 @@ public class PropertyUtilsBean {
             if (descriptor == null) {
                 return (null);
             }
-            Class type = descriptor.getType();
+            Class<?> type = descriptor.getType();
             if (type == null) {
                 return (null);
             } else if (type.isArray()) {
@@ -1246,7 +1247,7 @@ public class PropertyUtilsBean {
      * @param descriptor Property descriptor to return a getter for
      * @return The read method
      */
-    Method getReadMethod(Class clazz, PropertyDescriptor descriptor) {
+    Method getReadMethod(Class<?> clazz, PropertyDescriptor descriptor) {
         return (MethodUtils.getAccessibleMethod(clazz, descriptor.getReadMethod()));
     }
 
@@ -1355,7 +1356,7 @@ public class PropertyUtilsBean {
      * @param descriptor Property descriptor to return a setter for
      * @return The write method
      */
-    Method getWriteMethod(Class clazz, PropertyDescriptor descriptor) {
+    Method getWriteMethod(Class<?> clazz, PropertyDescriptor descriptor) {
         return (MethodUtils.getAccessibleMethod(clazz, descriptor.getWriteMethod()));
     }
 
@@ -1637,7 +1638,8 @@ public class PropertyUtilsBean {
                 Array.set(bean, index, value);
                 return;
             } else if (bean instanceof List) {
-                ((List)bean).set(index, value);
+                List<Object> list = toObjectList(bean);
+                list.set(index, value);
                 return;
             }
         }
@@ -1711,7 +1713,8 @@ public class PropertyUtilsBean {
         if (!array.getClass().isArray()) {
             if (array instanceof List) {
                 // Modify the specified value in the List
-                ((List) array).set(index, value);
+                List<Object> list = toObjectList(array);
+                list.set(index, value);
             } else {
                 throw new IllegalArgumentException("Property '" + name +
                         "' is not indexed on bean class '" + bean.getClass() + "'");
@@ -1864,7 +1867,8 @@ public class PropertyUtilsBean {
             Object invokeResult = invokeMethod(readMethod, bean, EMPTY_OBJECT_ARRAY);
             /* test and fetch from the map */
             if (invokeResult instanceof java.util.Map) {
-              ((java.util.Map)invokeResult).put(key, value);
+              java.util.Map<String, Object> map = toPropertyMap(invokeResult);
+              map.put(key, value);
             }
           } else {
             throw new NoSuchMethodException("Property '" + name +
@@ -1924,7 +1928,7 @@ public class PropertyUtilsBean {
             String next = resolver.next(name);
             Object nestedBean = null;
             if (bean instanceof Map) {
-                nestedBean = getPropertyOfMapBean((Map)bean, next);
+                nestedBean = getPropertyOfMapBean((Map<?, ?>)bean, next);
             } else if (resolver.isMapped(next)) {
                 nestedBean = getMappedProperty(bean, next);
             } else if (resolver.isIndexed(next)) {
@@ -1942,7 +1946,7 @@ public class PropertyUtilsBean {
         }
 
         if (bean instanceof Map) {
-            setPropertyOfMapBean((Map) bean, name, value);
+            setPropertyOfMapBean(toPropertyMap(bean), name, value);
         } else if (resolver.isMapped(name)) {
             setMappedProperty(bean, name, value);
         } else if (resolver.isIndexed(name)) {
@@ -2009,7 +2013,7 @@ public class PropertyUtilsBean {
      * no simple method is available.
      * @since 1.8.0
      */
-    protected void setPropertyOfMapBean(Map bean, String propertyName, Object value)
+    protected void setPropertyOfMapBean(Map<String, Object> bean, String propertyName, Object value)
         throws IllegalArgumentException, IllegalAccessException,
         InvocationTargetException, NoSuchMethodException {
 
@@ -2180,7 +2184,7 @@ public class PropertyUtilsBean {
                 }
             }
             String expectedString = "";
-            Class[] parTypes = method.getParameterTypes();
+            Class<?>[] parTypes = method.getParameterTypes();
             if (parTypes != null) {
                 for (int i = 0; i < parTypes.length; i++) {
                     if (i > 0) {
@@ -2217,7 +2221,7 @@ public class PropertyUtilsBean {
                 }
             }
             String expectedString = "";
-            Class[] parTypes = method.getParameterTypes();
+            Class<?>[] parTypes = method.getParameterTypes();
             if (parTypes != null) {
                 for (int i = 0; i < parTypes.length; i++) {
                     if (i > 0) {
@@ -2242,4 +2246,34 @@ public class PropertyUtilsBean {
 
         }
     }
+
+    /**
+     * Converts an object to a list of objects. This method is used when dealing
+     * with indexed properties. It assumes that indexed properties are stored as
+     * lists of objects.
+     *
+     * @param obj the object to be converted
+     * @return the resulting list of objects
+     */
+    private static List<Object> toObjectList(Object obj) {
+        @SuppressWarnings("unchecked")
+        // indexed properties are stored in lists of objects
+        List<Object> list = (List<Object>) obj;
+        return list;
+    }
+
+    /**
+     * Converts an object to a map with property values. This method is used
+     * when dealing with mapped properties. It assumes that mapped properties
+     * are stored in a Map&lt;String, Object&gt;.
+     *
+     * @param obj the object to be converted
+     * @return the resulting properties map
+     */
+    private static Map<String, Object> toPropertyMap(Object obj) {
+        @SuppressWarnings("unchecked")
+        // mapped properties are stores in maps of type <String, Object>
+        Map<String, Object> map = (Map<String, Object>) obj;
+        return map;
+    }
 }

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ResultSetDynaClass.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ResultSetDynaClass.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ResultSetDynaClass.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ResultSetDynaClass.java Fri Nov  8 21:08:30 2013
@@ -190,7 +190,7 @@ public class ResultSetDynaClass extends 
      * should be called only once.</p>
      * @return An <code>Iterator</code> of {@link DynaBean} instances
      */
-    public Iterator iterator() {
+    public Iterator<DynaBean> iterator() {
 
         return (new ResultSetIterator(this));
 
@@ -236,7 +236,7 @@ public class ResultSetDynaClass extends 
      * @throws SQLException if the class cannot be loaded
      */
     @Override
-    protected Class loadClass(String className) throws SQLException {
+    protected Class<?> loadClass(String className) throws SQLException {
 
         try {
             return getClass().getClassLoader().loadClass(className);

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ResultSetIterator.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ResultSetIterator.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ResultSetIterator.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/ResultSetIterator.java Fri Nov  8 21:08:30 2013
@@ -33,7 +33,7 @@ import java.util.NoSuchElementException;
  * @version $Id$
  */
 
-public class ResultSetIterator implements DynaBean, Iterator {
+public class ResultSetIterator implements DynaBean, Iterator<DynaBean> {
 
 
     // ------------------------------------------------------------ Constructor
@@ -301,7 +301,7 @@ public class ResultSetIterator implement
      *
      * @return advance to the new row and return this
      */
-    public Object next() {
+    public DynaBean next() {
 
         try {
             advance();

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/RowSetDynaClass.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/RowSetDynaClass.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/RowSetDynaClass.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/RowSetDynaClass.java Fri Nov  8 21:08:30 2013
@@ -82,7 +82,7 @@ public class RowSetDynaClass extends JDB
      * the original <code>ResultSet</code> on which this
      * {@link RowSetDynaClass} was based.</p>
      */
-    protected List rows = new ArrayList();
+    protected List<DynaBean> rows = new ArrayList<DynaBean>();
 
     // ----------------------------------------------------------- Constructors
 
@@ -261,7 +261,7 @@ public class RowSetDynaClass extends JDB
      *
      * @return A <code>List</code> of {@link DynaBean} instances
      */
-    public List getRows() {
+    public List<DynaBean> getRows() {
 
         return (this.rows);
 

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/WeakFastHashMap.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/WeakFastHashMap.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/WeakFastHashMap.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/WeakFastHashMap.java Fri Nov  8 21:08:30 2013
@@ -61,12 +61,12 @@ import java.util.WeakHashMap;
  * @since Commons Collections 1.0
  * @version $Id$
  */
-class WeakFastHashMap extends HashMap {
+class WeakFastHashMap<K, V> extends HashMap<K, V> {
 
     /**
      * The underlying map we are managing.
      */
-    private Map map = null;
+    private Map<K, V> map = null;
 
     /**
      * Are we currently operating in "fast" mode?
@@ -110,7 +110,7 @@ class WeakFastHashMap extends HashMap {
      *
      * @param map  the map whose mappings are to be copied
      */
-    public WeakFastHashMap(Map map) {
+    public WeakFastHashMap(Map<? extends K, ? extends V> map) {
         super();
         this.map = createMap(map);
     }
@@ -153,7 +153,7 @@ class WeakFastHashMap extends HashMap {
      * @return the value mapped to that key, or null
      */
     @Override
-    public Object get(Object key) {
+    public V get(Object key) {
         if (fast) {
             return (map.get(key));
         } else {
@@ -247,11 +247,11 @@ class WeakFastHashMap extends HashMap {
      * @return the value previously mapped to the key, or null
      */
     @Override
-    public Object put(Object key, Object value) {
+    public V put(K key, V value) {
         if (fast) {
             synchronized (this) {
-                Map temp = cloneMap(map);
-                Object result = temp.put(key, value);
+                Map<K, V> temp = cloneMap(map);
+                V result = temp.put(key, value);
                 map = temp;
                 return (result);
             }
@@ -269,10 +269,10 @@ class WeakFastHashMap extends HashMap {
      * @param in  the map whose mappings are to be copied
      */
     @Override
-    public void putAll(Map in) {
+    public void putAll(Map<? extends K, ? extends V> in) {
         if (fast) {
             synchronized (this) {
-                Map temp =  cloneMap(map);
+                Map<K, V> temp =  cloneMap(map);
                 temp.putAll(in);
                 map = temp;
             }
@@ -291,11 +291,11 @@ class WeakFastHashMap extends HashMap {
      * @return the value removed, or null
      */
     @Override
-    public Object remove(Object key) {
+    public V remove(Object key) {
         if (fast) {
             synchronized (this) {
-                Map temp = cloneMap(map);
-                Object result = temp.remove(key);
+                Map<K, V> temp = cloneMap(map);
+                V result = temp.remove(key);
                 map = temp;
                 return (result);
             }
@@ -342,18 +342,16 @@ class WeakFastHashMap extends HashMap {
         } else if (!(o instanceof Map)) {
             return (false);
         }
-        Map mo = (Map) o;
+        Map<?, ?> mo = (Map<?, ?>) o;
 
         // Compare the two maps for equality
         if (fast) {
             if (mo.size() != map.size()) {
                 return (false);
             }
-            Iterator i = map.entrySet().iterator();
-            while (i.hasNext()) {
-                Map.Entry e = (Map.Entry) i.next();
-                Object key = e.getKey();
-                Object value = e.getValue();
+            for (Map.Entry<K, V> e : map.entrySet()) {
+                K key = e.getKey();
+                V value = e.getValue();
                 if (value == null) {
                     if (!(mo.get(key) == null && mo.containsKey(key))) {
                         return (false);
@@ -371,11 +369,9 @@ class WeakFastHashMap extends HashMap {
                 if (mo.size() != map.size()) {
                     return (false);
                 }
-                Iterator i = map.entrySet().iterator();
-                while (i.hasNext()) {
-                    Map.Entry e = (Map.Entry) i.next();
-                    Object key = e.getKey();
-                    Object value = e.getValue();
+                for (Map.Entry<K, V> e : map.entrySet()) {
+                    K key = e.getKey();
+                    V value = e.getValue();
                     if (value == null) {
                         if (!(mo.get(key) == null && mo.containsKey(key))) {
                             return (false);
@@ -402,17 +398,15 @@ class WeakFastHashMap extends HashMap {
     public int hashCode() {
         if (fast) {
             int h = 0;
-            Iterator i = map.entrySet().iterator();
-            while (i.hasNext()) {
-                h += i.next().hashCode();
+            for (Map.Entry<K, V> e : map.entrySet()) {
+                h += e.hashCode();
             }
             return (h);
         } else {
             synchronized (map) {
                 int h = 0;
-                Iterator i = map.entrySet().iterator();
-                while (i.hasNext()) {
-                    h += i.next().hashCode();
+                for (Map.Entry<K, V> e : map.entrySet()) {
+                    h += e.hashCode();
                 }
                 return (h);
             }
@@ -427,12 +421,12 @@ class WeakFastHashMap extends HashMap {
      */
     @Override
     public Object clone() {
-        WeakFastHashMap results = null;
+        WeakFastHashMap<K, V> results = null;
         if (fast) {
-            results = new WeakFastHashMap(map);
+            results = new WeakFastHashMap<K, V>(map);
         } else {
             synchronized (map) {
-                results = new WeakFastHashMap(map);
+                results = new WeakFastHashMap<K, V>(map);
             }
         }
         results.setFast(getFast());
@@ -448,7 +442,7 @@ class WeakFastHashMap extends HashMap {
      * @return the set of map Map entries
      */
     @Override
-    public Set entrySet() {
+    public Set<Map.Entry<K, V>> entrySet() {
         return new EntrySet();
     }
 
@@ -457,7 +451,7 @@ class WeakFastHashMap extends HashMap {
      * @return the set of the Map's keys
      */
     @Override
-    public Set keySet() {
+    public Set<K> keySet() {
         return new KeySet();
     }
 
@@ -466,30 +460,30 @@ class WeakFastHashMap extends HashMap {
      * @return the set of the Map's values
      */
     @Override
-    public Collection values() {
+    public Collection<V> values() {
         return new Values();
     }
 
     // Abstractions on Map creations (for subclasses such as WeakFastHashMap)
     // ----------------------------------------------------------------------
 
-    protected Map createMap() {
-        return new WeakHashMap();
+    protected Map<K, V> createMap() {
+        return new WeakHashMap<K, V>();
     }
 
-    protected Map createMap(int capacity) {
-        return new WeakHashMap(capacity);
+    protected Map<K, V> createMap(int capacity) {
+        return new WeakHashMap<K, V>(capacity);
     }
 
-    protected Map createMap(int capacity, float factor) {
-        return new WeakHashMap(capacity, factor);
+    protected Map<K, V> createMap(int capacity, float factor) {
+        return new WeakHashMap<K, V>(capacity, factor);
     }
 
-    protected Map createMap(Map map) {
-        return new WeakHashMap(map);
+    protected Map<K, V> createMap(Map<? extends K, ? extends V> map) {
+        return new WeakHashMap<K, V>(map);
     }
 
-    protected Map cloneMap(Map map) {
+    protected Map<K, V> cloneMap(Map<? extends K, ? extends V> map) {
         return createMap(map);
     }
 
@@ -498,14 +492,16 @@ class WeakFastHashMap extends HashMap {
 
     /**
      * Abstract collection implementation shared by keySet(), values() and entrySet().
+     *
+     * @param <E> the element type
      */
-    private abstract class CollectionView implements Collection {
+    private abstract class CollectionView<E> implements Collection<E> {
 
         public CollectionView() {
         }
 
-        protected abstract Collection get(Map map);
-        protected abstract Object iteratorNext(Map.Entry entry);
+        protected abstract Collection<E> get(Map<K, V> map);
+        protected abstract E iteratorNext(Map.Entry<K, V> entry);
 
 
         public void clear() {
@@ -523,7 +519,7 @@ class WeakFastHashMap extends HashMap {
         public boolean remove(Object o) {
             if (fast) {
                 synchronized (WeakFastHashMap.this) {
-                    Map temp = cloneMap(map);
+                    Map<K, V> temp = cloneMap(map);
                     boolean r = get(temp).remove(o);
                     map = temp;
                     return r;
@@ -535,10 +531,10 @@ class WeakFastHashMap extends HashMap {
             }
         }
 
-        public boolean removeAll(Collection o) {
+        public boolean removeAll(Collection<?> o) {
             if (fast) {
                 synchronized (WeakFastHashMap.this) {
-                    Map temp = cloneMap(map);
+                    Map<K, V> temp = cloneMap(map);
                     boolean r = get(temp).removeAll(o);
                     map = temp;
                     return r;
@@ -550,10 +546,10 @@ class WeakFastHashMap extends HashMap {
             }
         }
 
-        public boolean retainAll(Collection o) {
+        public boolean retainAll(Collection<?> o) {
             if (fast) {
                 synchronized (WeakFastHashMap.this) {
-                    Map temp = cloneMap(map);
+                    Map<K, V> temp = cloneMap(map);
                     boolean r = get(temp).retainAll(o);
                     map = temp;
                     return r;
@@ -596,7 +592,7 @@ class WeakFastHashMap extends HashMap {
             }
         }
 
-        public boolean containsAll(Collection o) {
+        public boolean containsAll(Collection<?> o) {
             if (fast) {
                 return get(map).containsAll(o);
             } else {
@@ -606,7 +602,7 @@ class WeakFastHashMap extends HashMap {
             }
         }
 
-        public Object[] toArray(Object[] o) {
+        public <T> T[] toArray(T[] o) {
             if (fast) {
                 return get(map).toArray(o);
             } else {
@@ -652,23 +648,23 @@ class WeakFastHashMap extends HashMap {
             }
         }
 
-        public boolean add(Object o) {
+        public boolean add(E o) {
             throw new UnsupportedOperationException();
         }
 
-        public boolean addAll(Collection c) {
+        public boolean addAll(Collection<? extends E> c) {
             throw new UnsupportedOperationException();
         }
 
-        public Iterator iterator() {
+        public Iterator<E> iterator() {
             return new CollectionViewIterator();
         }
 
-        private class CollectionViewIterator implements Iterator {
+        private class CollectionViewIterator implements Iterator<E> {
 
-            private Map expected;
-            private Map.Entry lastReturned = null;
-            private final Iterator iterator;
+            private Map<K, V> expected;
+            private Map.Entry<K, V> lastReturned = null;
+            private final Iterator<Map.Entry<K, V>> iterator;
 
             public CollectionViewIterator() {
                 this.expected = map;
@@ -682,11 +678,11 @@ class WeakFastHashMap extends HashMap {
                 return iterator.hasNext();
             }
 
-            public Object next() {
+            public E next() {
                 if (expected != map) {
                     throw new ConcurrentModificationException();
                 }
-                lastReturned = (Map.Entry)iterator.next();
+                lastReturned = iterator.next();
                 return iteratorNext(lastReturned);
             }
 
@@ -714,15 +710,15 @@ class WeakFastHashMap extends HashMap {
     /**
      * Set implementation over the keys of the FastHashMap
      */
-    private class KeySet extends CollectionView implements Set {
+    private class KeySet extends CollectionView<K> implements Set<K> {
 
         @Override
-        protected Collection get(Map map) {
+        protected Collection<K> get(Map<K, V> map) {
             return map.keySet();
         }
 
         @Override
-        protected Object iteratorNext(Map.Entry entry) {
+        protected K iteratorNext(Map.Entry<K, V> entry) {
             return entry.getKey();
         }
 
@@ -731,15 +727,15 @@ class WeakFastHashMap extends HashMap {
     /**
      * Collection implementation over the values of the FastHashMap
      */
-    private class Values extends CollectionView {
+    private class Values extends CollectionView<V> {
 
         @Override
-        protected Collection get(Map map) {
+        protected Collection<V> get(Map<K, V> map) {
             return map.values();
         }
 
         @Override
-        protected Object iteratorNext(Map.Entry entry) {
+        protected V iteratorNext(Map.Entry<K, V> entry) {
             return entry.getValue();
         }
     }
@@ -747,15 +743,15 @@ class WeakFastHashMap extends HashMap {
     /**
      * Set implementation over the entries of the FastHashMap
      */
-    private class EntrySet extends CollectionView implements Set {
+    private class EntrySet extends CollectionView<Map.Entry<K, V>> implements Set<Map.Entry<K, V>> {
 
         @Override
-        protected Collection get(Map map) {
+        protected Collection<Map.Entry<K, V>> get(Map<K, V> map) {
             return map.entrySet();
         }
 
         @Override
-        protected Object iteratorNext(Map.Entry entry) {
+        protected Map.Entry<K, V> iteratorNext(Map.Entry<K, V> entry) {
             return entry;
         }
 

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/WrapDynaClass.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/WrapDynaClass.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/WrapDynaClass.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/WrapDynaClass.java Fri Nov  8 21:08:30 2013
@@ -60,9 +60,9 @@ public class WrapDynaClass implements Dy
      *
      * @param beanClass JavaBean class to be introspected around
      */
-    private WrapDynaClass(Class beanClass) {
+    private WrapDynaClass(Class<?> beanClass) {
 
-        this.beanClassRef = new SoftReference(beanClass);
+        this.beanClassRef = new SoftReference<Class<?>>(beanClass);
         this.beanClassName = beanClass.getName();
         introspect();
 
@@ -79,7 +79,7 @@ public class WrapDynaClass implements Dy
     /**
      * Reference to the JavaBean class represented by this WrapDynaClass.
      */
-    private Reference beanClassRef = null;
+    private Reference<Class<?>> beanClassRef = null;
 
     /**
      * The JavaBean <code>Class</code> which is represented by this
@@ -88,7 +88,7 @@ public class WrapDynaClass implements Dy
      * @deprecated No longer initialized, use getBeanClass() method instead
      */
     @Deprecated
-    protected Class beanClass = null;
+    protected Class<?> beanClass = null;
 
 
     /**
@@ -102,7 +102,7 @@ public class WrapDynaClass implements Dy
      * property name.  Individual descriptor instances will be the same
      * instances as those in the <code>descriptors</code> list.
      */
-    protected HashMap descriptorsMap = new HashMap();
+    protected HashMap<String, PropertyDescriptor> descriptorsMap = new HashMap<String, PropertyDescriptor>();
 
 
     /**
@@ -116,25 +116,25 @@ public class WrapDynaClass implements Dy
      * keyed by the property name.  Individual descriptor instances will
      * be the same instances as those in the <code>properties</code> list.
      */
-    protected HashMap propertiesMap = new HashMap();
+    protected HashMap<String, DynaProperty> propertiesMap = new HashMap<String, DynaProperty>();
 
 
     // ------------------------------------------------------- Static Variables
 
 
-    private static final ContextClassLoaderLocal CLASSLOADER_CACHE =
-        new ContextClassLoaderLocal() {
+    private static final ContextClassLoaderLocal<Map<Object, Object>> CLASSLOADER_CACHE =
+        new ContextClassLoaderLocal<Map<Object, Object>>() {
             @Override
-            protected Object initialValue() {
-                return new WeakHashMap();
+            protected Map<Object, Object> initialValue() {
+                return new WeakHashMap<Object, Object>();
         }
     };
 
     /**
      * Get the wrap dyna classes cache
      */
-    private static Map getDynaClassesMap() {
-        return (Map)CLASSLOADER_CACHE.get();
+    private static Map<Object, Object> getDynaClassesMap() {
+        return CLASSLOADER_CACHE.get();
     }
 
     /**
@@ -174,7 +174,7 @@ public class WrapDynaClass implements Dy
      * @deprecated The dynaClasses Map will be removed in a subsequent release
      */
     @Deprecated
-    protected static HashMap dynaClasses = new HashMap() {
+    protected static HashMap<Object, Object> dynaClasses = new HashMap<Object, Object>() {
         @Override
         public void clear() {
             getDynaClassesMap().clear();
@@ -188,7 +188,7 @@ public class WrapDynaClass implements Dy
             return getDynaClassesMap().containsValue(value);
         }
         @Override
-        public Set entrySet() {
+        public Set<Map.Entry<Object, Object>> entrySet() {
             return getDynaClassesMap().entrySet();
         }
         @Override
@@ -208,7 +208,7 @@ public class WrapDynaClass implements Dy
             return getDynaClassesMap().isEmpty();
         }
         @Override
-        public Set keySet() {
+        public Set<Object> keySet() {
             return getDynaClassesMap().keySet();
         }
         @Override
@@ -216,7 +216,7 @@ public class WrapDynaClass implements Dy
             return getDynaClassesMap().put(key, value);
         }
         @Override
-        public void putAll(Map m) {
+        public void putAll(Map<? extends Object, ? extends Object> m) {
             getDynaClassesMap().putAll(m);
         }
         @Override
@@ -228,7 +228,7 @@ public class WrapDynaClass implements Dy
             return getDynaClassesMap().size();
         }
         @Override
-        public Collection values() {
+        public Collection<Object> values() {
             return getDynaClassesMap().values();
         }
     };
@@ -242,8 +242,8 @@ public class WrapDynaClass implements Dy
      * @return the class of the underlying wrapped bean
      * @since 1.8.0
      */
-    protected Class getBeanClass() {
-        return (Class)beanClassRef.get();
+    protected Class<?> getBeanClass() {
+        return beanClassRef.get();
     }
 
     /**
@@ -277,7 +277,7 @@ public class WrapDynaClass implements Dy
             throw new IllegalArgumentException
                     ("No property name specified");
         }
-        return ((DynaProperty) propertiesMap.get(name));
+        return (propertiesMap.get(name));
 
     }
 
@@ -345,7 +345,7 @@ public class WrapDynaClass implements Dy
      */
     public PropertyDescriptor getPropertyDescriptor(String name) {
 
-        return ((PropertyDescriptor) descriptorsMap.get(name));
+        return (descriptorsMap.get(name));
 
     }
 
@@ -370,7 +370,7 @@ public class WrapDynaClass implements Dy
      * @param beanClass Bean class for which a WrapDynaClass is requested
      * @return A new <i>Wrap</i> {@link DynaClass}
      */
-    public static WrapDynaClass createDynaClass(Class beanClass) {
+    public static WrapDynaClass createDynaClass(Class<?> beanClass) {
 
             WrapDynaClass dynaClass =
                     (WrapDynaClass) getDynaClassesMap().get(beanClass);
@@ -392,16 +392,16 @@ public class WrapDynaClass implements Dy
     protected void introspect() {
 
         // Look up the property descriptors for this bean class
-        Class beanClass = getBeanClass();
+        Class<?> beanClass = getBeanClass();
         PropertyDescriptor[] regulars =
                 PropertyUtils.getPropertyDescriptors(beanClass);
         if (regulars == null) {
             regulars = new PropertyDescriptor[0];
         }
-        Map mappeds =
+        Map<?, ?> mappeds =
                 PropertyUtils.getMappedPropertyDescriptors(beanClass);
         if (mappeds == null) {
-            mappeds = new HashMap();
+            mappeds = new HashMap<Object, Object>();
         }
 
         // Construct corresponding DynaProperty information
@@ -416,7 +416,7 @@ public class WrapDynaClass implements Dy
                     properties[i]);
         }
         int j = regulars.length;
-        Iterator names = mappeds.keySet().iterator();
+        Iterator<?> names = mappeds.keySet().iterator();
         while (names.hasNext()) {
             String name = (String) names.next();
             PropertyDescriptor descriptor =

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/AbstractConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/AbstractConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/AbstractConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/AbstractConverter.java Fri Nov  8 21:08:30 2013
@@ -18,11 +18,13 @@ package org.apache.commons.beanutils.con
 
 import java.lang.reflect.Array;
 import java.util.Collection;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.beanutils.ConversionException;
+import org.apache.commons.beanutils.ConvertUtils;
 import org.apache.commons.beanutils.Converter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Base {@link Converter} implementation that provides the structure
@@ -43,6 +45,12 @@ import org.apache.commons.beanutils.Conv
  *     <li><code>convertToType(Class, value)</code> - convert
  *         to the specified type</li>
  * </ul>
+ * <p>
+ * The default value has to be compliant to the default type of this
+ * converter - which is enforced by the generic type parameter. If a
+ * conversion is not possible and a default value is set, the converter
+ * tries to transform the default value to the requested target type.
+ * If this fails, a {@code ConversionException} if thrown.
  *
  * @version $Id$
  * @since 1.8.0
@@ -112,16 +120,21 @@ public abstract class AbstractConverter 
      * Convert the input object into an output object of the
      * specified type.
      *
+     * @param <T> the target type of the conversion
      * @param type Data type to which this value should be converted
      * @param value The input value to be converted
      * @return The converted value.
      * @throws ConversionException if conversion cannot be performed
      * successfully and no default is specified.
      */
-    public Object convert(Class type, Object value) {
+    public <T> T convert(Class<T> type, Object value) {
 
-        Class sourceType  = value == null ? null : value.getClass();
-        Class targetType  = primitive(type  == null ? getDefaultType() : type);
+        if (type == null) {
+            return convertToDefaultType(type, value);
+        }
+
+        Class<?> sourceType  = value == null ? null : value.getClass();
+        Class<T> targetType  = ConvertUtils.primitiveToWrapper(type);
 
         if (log().isDebugEnabled()) {
             log().debug("Converting"
@@ -141,7 +154,7 @@ public abstract class AbstractConverter 
         try {
             // Convert --> String
             if (targetType.equals(String.class)) {
-                return convertToString(value);
+                return targetType.cast(convertToString(value));
 
             // No conversion necessary
             } else if (targetType.equals(sourceType)) {
@@ -149,7 +162,7 @@ public abstract class AbstractConverter 
                     log().debug("    No conversion required, value is already a "
                                     + toString(targetType));
                 }
-                return value;
+                return targetType.cast(value);
 
             // Convert --> Type
             } else {
@@ -158,7 +171,7 @@ public abstract class AbstractConverter 
                     log().debug("    Converted to " + toString(targetType) +
                                    " value '" + result + "'");
                 }
-                return result;
+                return targetType.cast(result);
             }
         } catch (Throwable t) {
             return handleError(targetType, value, t);
@@ -194,7 +207,7 @@ public abstract class AbstractConverter 
      * @return The converted value.
      * @throws Throwable if an error occurs converting to the specified type
      */
-    protected abstract Object convertToType(Class type, Object value) throws Throwable;
+    protected abstract <T> T convertToType(Class<T> type, Object value) throws Throwable;
 
     /**
      * Return the first element from an Array (or Collection)
@@ -218,7 +231,7 @@ public abstract class AbstractConverter 
             }
         }
         if (value instanceof Collection) {
-            Collection collection = (Collection)value;
+            Collection<?> collection = (Collection<?>)value;
             if (collection.size() > 0) {
                 return collection.iterator().next();
             } else {
@@ -241,7 +254,7 @@ public abstract class AbstractConverter 
      * @throws ConversionException if no default value has been
      * specified for this {@link Converter}.
      */
-    protected Object handleError(Class type, Object value, Throwable cause) {
+    protected <T> T handleError(Class<T> type, Object value, Throwable cause) {
         if (log().isDebugEnabled()) {
             if (cause instanceof ConversionException) {
                 log().debug("    Conversion threw ConversionException: " + cause.getMessage());
@@ -279,15 +292,16 @@ public abstract class AbstractConverter 
     /**
      * Handle missing values.
      * <p>
-     * If a default value has been specified then it is returned
-     * otherwise a ConversionException is thrown.
+     * If a default value has been specified, then it is returned (after a cast
+     * to the desired target class); otherwise a ConversionException is thrown.
      *
+     * @param <T> the desired target type
      * @param type Data type to which this value should be converted.
      * @return The default value.
      * @throws ConversionException if no default value has been
      * specified for this {@link Converter}.
      */
-    protected Object handleMissing(Class type) {
+    protected <T> T handleMissing(Class<T> type) {
 
         if (useDefault || type.equals(String.class)) {
             Object value = getDefault(type);
@@ -295,8 +309,8 @@ public abstract class AbstractConverter 
                 try {
                     value = convertToType(type, defaultValue);
                 } catch (Throwable t) {
-                    log().error("    Default conversion to " + toString(type)
-                            + "failed: " + t);
+                    throw new ConversionException("Default conversion to " + toString(type)
+                            + " failed.", t);
                 }
             }
             if (log().isDebugEnabled()) {
@@ -304,7 +318,8 @@ public abstract class AbstractConverter 
                         + (value == null ? "" : toString(value.getClass()) + " ")
                         + "value '" + defaultValue + "'");
             }
-            return value;
+            // value is now either null or of the desired target type
+            return type.cast(value);
         }
 
         ConversionException cex =  new ConversionException("No value specified for '" +
@@ -348,7 +363,7 @@ public abstract class AbstractConverter 
      *
      * @return The default type this <code>Converter</code> handles.
      */
-    protected abstract Class getDefaultType();
+    protected abstract Class<?> getDefaultType();
 
     /**
      * Return the default value for conversions to the specified
@@ -356,10 +371,10 @@ public abstract class AbstractConverter 
      * @param type Data type to which this value should be converted.
      * @return The default value for the specified type.
      */
-    protected Object getDefault(Class type) {
+    protected Object getDefault(Class<?> type) {
         if (type.equals(String.class)) {
             return null;
-        } else {
+        } else  {
             return defaultValue;
         }
     }
@@ -394,47 +409,16 @@ public abstract class AbstractConverter 
     }
 
     /**
-     * Change primitve Class types to the associated wrapper class.
-     * @param type The class type to check.
-     * @return The converted type.
-     */
-     Class primitive(Class type) {
-        if (type == null || !type.isPrimitive()) {
-            return type;
-        }
-
-        if (type == Integer.TYPE) {
-            return Integer.class;
-        } else if (type == Double.TYPE) {
-            return Double.class;
-        } else if (type == Long.TYPE) {
-            return Long.class;
-        } else if (type == Boolean.TYPE) {
-            return Boolean.class;
-        } else if (type == Float.TYPE) {
-            return Float.class;
-        } else if (type == Short.TYPE) {
-            return Short.class;
-        } else if (type == Byte.TYPE) {
-            return Byte.class;
-        } else if (type == Character.TYPE) {
-            return Character.class;
-        } else {
-            return type;
-        }
-    }
-
-    /**
      * Provide a String representation of a <code>java.lang.Class</code>.
      * @param type The <code>java.lang.Class</code>.
      * @return The String representation.
      */
-    String toString(Class type) {
+    String toString(Class<?> type) {
         String typeName = null;
         if (type == null) {
             typeName = "null";
         } else if (type.isArray()) {
-            Class elementType = type.getComponentType();
+            Class<?> elementType = type.getComponentType();
             int count = 1;
             while (elementType.isArray()) {
                 elementType = elementType .getComponentType();
@@ -456,4 +440,35 @@ public abstract class AbstractConverter 
         }
         return typeName;
     }
+
+    /**
+     * Performs a conversion to the default type. This method is called if we do
+     * not have a target class. In this case, the T parameter is not set.
+     * Therefore, we can cast to it (which is required to fulfill the contract
+     * of the method signature).
+     *
+     * @param <T> the type of the result object
+     * @param targetClass the target class of the conversion
+     * @param value the value to be converted
+     * @return the converted value
+     */
+    private <T> T convertToDefaultType(Class<T> targetClass, Object value) {
+        @SuppressWarnings("unchecked")
+        T result = (T) convert(getDefaultType(), value);
+        return result;
+    }
+
+    /**
+     * Generates a standard conversion exception with a message indicating that
+     * the passed in value cannot be converted to the desired target type.
+     *
+     * @param type the target type
+     * @param value the value to be converted
+     * @return a {@code ConversionException} with a standard message
+     * @since 1.9
+     */
+    protected ConversionException conversionException(Class<?> type, Object value) {
+        return new ConversionException("Can't convert value '" + value
+                + "' to type " + type);
+    }
 }

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ArrayConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ArrayConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ArrayConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ArrayConverter.java Fri Nov  8 21:08:30 2013
@@ -16,15 +16,16 @@
  */
 package org.apache.commons.beanutils.converters;
 
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Collection;
+import java.io.IOException;
 import java.io.StreamTokenizer;
 import java.io.StringReader;
-import java.io.IOException;
 import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.commons.beanutils.ConversionException;
 import org.apache.commons.beanutils.Converter;
 
@@ -53,7 +54,7 @@ import org.apache.commons.beanutils.Conv
  *         or by converting the first element in the array to a String - this
  *         is controlled by the {@link ArrayConverter#setOnlyFirstToString(boolean)}
  *         parameter.</li>
- *     <li><b>Multi Dimensional Arrays</b> - its possible to convert a <code>String</code>
+ *     <li><b>Multi Dimensional Arrays</b> - it is possible to convert a <code>String</code>
  *         to a multi-dimensional arrays, by embedding {@link ArrayConverter}
  *         within each other - see example below.</li>
  *     <li><b>Default Value</b></li>
@@ -121,12 +122,13 @@ import org.apache.commons.beanutils.Conv
  *    int[][] result = (int[][])matrixConverter.convert(int[][].class, matrixString);
  * </pre>
  *
+ * @param <D> the default type of this array converter
  * @version $Id$
  * @since 1.8.0
  */
 public class ArrayConverter extends AbstractConverter {
 
-    private final Object defaultTypeInstance;
+    private final Class<?> defaultType;
     private final Converter elementConverter;
     private int defaultSize;
     private char delimiter    = ',';
@@ -145,7 +147,7 @@ public class ArrayConverter extends Abst
      * @param elementConverter Converter used to convert
      *  individual array elements.
      */
-    public ArrayConverter(Class defaultType, Converter elementConverter) {
+    public ArrayConverter(Class<?> defaultType, Converter elementConverter) {
         super();
         if (defaultType == null) {
             throw new IllegalArgumentException("Default type is missing");
@@ -156,7 +158,7 @@ public class ArrayConverter extends Abst
         if (elementConverter == null) {
             throw new IllegalArgumentException("Component Converter is missing.");
         }
-        this.defaultTypeInstance = Array.newInstance(defaultType.getComponentType(), 0);
+        this.defaultType = defaultType;
         this.elementConverter = elementConverter;
     }
 
@@ -172,7 +174,7 @@ public class ArrayConverter extends Abst
      * @param defaultSize Specifies the size of the default array value or if less
      *  than zero indicates that a <code>null</code> default value should be used.
      */
-    public ArrayConverter(Class defaultType, Converter elementConverter, int defaultSize) {
+    public ArrayConverter(Class<?> defaultType, Converter elementConverter, int defaultSize) {
         this(defaultType, elementConverter);
         this.defaultSize = defaultSize;
         Object defaultValue = null;
@@ -220,8 +222,8 @@ public class ArrayConverter extends Abst
      * @return The default type this <code>Converter</code> handles.
      */
     @Override
-    protected Class getDefaultType() {
-        return defaultTypeInstance.getClass();
+    protected Class<?> getDefaultType() {
+        return defaultType;
     }
 
     /**
@@ -235,12 +237,12 @@ public class ArrayConverter extends Abst
     protected String convertToString(Object value) throws Throwable {
 
         int size = 0;
-        Iterator iterator = null;
-        Class type = value.getClass();
+        Iterator<?> iterator = null;
+        Class<?> type = value.getClass();
         if (type.isArray()) {
             size = Array.getLength(value);
         } else {
-            Collection collection = convertToCollection(type, value);
+            Collection<?> collection = convertToCollection(type, value);
             size = collection.size();
             iterator = collection.iterator();
         }
@@ -254,7 +256,7 @@ public class ArrayConverter extends Abst
         }
 
         // Create a StringBuffer containing a delimited list of the values
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
         for (int i = 0; i < size; i++) {
             if (i > 0) {
                 buffer.append(delimiter);
@@ -279,7 +281,7 @@ public class ArrayConverter extends Abst
      * @throws Throwable if an error occurs converting to the specified type
      */
     @Override
-    protected Object convertToType(Class type, Object value) throws Throwable {
+    protected <T> T convertToType(Class<T> type, Object value) throws Throwable {
 
         if (!type.isArray()) {
             throw new ConversionException(toString(getClass())
@@ -289,17 +291,17 @@ public class ArrayConverter extends Abst
 
         // Handle the source
         int size = 0;
-        Iterator iterator = null;
+        Iterator<?> iterator = null;
         if (value.getClass().isArray()) {
             size = Array.getLength(value);
         } else {
-            Collection collection = convertToCollection(type, value);
+            Collection<?> collection = convertToCollection(type, value);
             size = collection.size();
             iterator = collection.iterator();
         }
 
         // Allocate a new Array
-        Class componentType = type.getComponentType();
+        Class<?> componentType = type.getComponentType();
         Object newArray = Array.newInstance(componentType, size);
 
         // Convert and set each element in the new Array
@@ -311,7 +313,11 @@ public class ArrayConverter extends Abst
             Array.set(newArray, i, element);
         }
 
-        return newArray;
+        @SuppressWarnings("unchecked")
+        // This is safe because T is an array type and newArray is an array of
+        // T's component type
+        T result = (T) newArray;
+        return result;
     }
 
     /**
@@ -346,14 +352,14 @@ public class ArrayConverter extends Abst
      * @param value value to be converted
      * @return Collection elements.
      */
-    protected Collection convertToCollection(Class type, Object value) {
+    protected Collection<?> convertToCollection(Class<?> type, Object value) {
         if (value instanceof Collection) {
-            return (Collection)value;
+            return (Collection<?>)value;
         }
         if (value instanceof Number ||
             value instanceof Boolean ||
             value instanceof java.util.Date) {
-            List list = new ArrayList(1);
+            List<Object> list = new ArrayList<Object>(1);
             list.add(value);
             return list;
         }
@@ -368,7 +374,7 @@ public class ArrayConverter extends Abst
      * @return The default value for the specified type.
      */
     @Override
-    protected Object getDefault(Class type) {
+    protected Object getDefault(Class<?> type) {
         if (type.equals(String.class)) {
             return null;
         }
@@ -393,7 +399,7 @@ public class ArrayConverter extends Abst
      */
     @Override
     public String toString() {
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
         buffer.append(toString(getClass()));
         buffer.append("[UseDefault=");
         buffer.append(isUseDefault());
@@ -425,7 +431,7 @@ public class ArrayConverter extends Abst
      * @throws NullPointerException if <code>svalue</code>
      *  is <code>null</code>
      */
-    private List parseElements(Class type, String value) {
+    private List<String> parseElements(Class<?> type, String value) {
 
         if (log().isDebugEnabled()) {
             log().debug("Parsing elements, delimiter=[" + delimiter + "], value=[" + value + "]");
@@ -450,13 +456,13 @@ public class ArrayConverter extends Abst
             }
 
             // Split comma-delimited tokens into a List
-            List list = null;
+            List<String> list = null;
             while (true) {
                 int ttype = st.nextToken();
                 if ((ttype == StreamTokenizer.TT_WORD) || (ttype > 0)) {
                     if (st.sval != null) {
                         if (list == null) {
-                            list = new ArrayList();
+                            list = new ArrayList<String>();
                         }
                         list.add(st.sval);
                     }
@@ -469,7 +475,7 @@ public class ArrayConverter extends Abst
             }
 
             if (list == null) {
-                list = Collections.EMPTY_LIST;
+                list = Collections.emptyList();
             }
             if (log().isDebugEnabled()) {
                 log().debug(list.size() + " elements parsed");

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java Fri Nov  8 21:08:30 2013
@@ -62,7 +62,7 @@ public final class BigDecimalConverter e
      * @since 1.8.0
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<BigDecimal> getDefaultType() {
         return BigDecimal.class;
     }
 

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java Fri Nov  8 21:08:30 2013
@@ -62,7 +62,7 @@ public final class BigIntegerConverter e
      * @since 1.8.0
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<BigInteger> getDefaultType() {
         return BigInteger.class;
     }
 

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BooleanConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BooleanConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BooleanConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/BooleanConverter.java Fri Nov  8 21:08:30 2013
@@ -178,7 +178,7 @@ public final class BooleanConverter exte
      * @since 1.8.0
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<Boolean> getDefaultType() {
         return Boolean.class;
     }
 
@@ -202,27 +202,29 @@ public final class BooleanConverter exte
      * @since 1.8.0
      */
     @Override
-    protected Object convertToType(Class type, Object value) throws Throwable {
+    protected <T> T convertToType(Class<T> type, Object value) throws Throwable {
 
-        // All the values in the trueStrings and falseStrings arrays are
-        // guaranteed to be lower-case. By converting the input value
-        // to lowercase too, we can use the efficient String.equals method
-        // instead of the less-efficient String.equalsIgnoreCase method.
-        String stringValue = value.toString().toLowerCase();
-
-        for(int i=0; i<trueStrings.length; ++i) {
-            if (trueStrings[i].equals(stringValue)) {
-                return Boolean.TRUE;
+        if (Boolean.class.equals(type) || Boolean.TYPE.equals(type)) {
+            // All the values in the trueStrings and falseStrings arrays are
+            // guaranteed to be lower-case. By converting the input value
+            // to lowercase too, we can use the efficient String.equals method
+            // instead of the less-efficient String.equalsIgnoreCase method.
+            String stringValue = value.toString().toLowerCase();
+
+            for (int i = 0; i < trueStrings.length; ++i) {
+                if (trueStrings[i].equals(stringValue)) {
+                    return type.cast(Boolean.TRUE);
+                }
             }
-        }
 
-        for(int i=0; i<falseStrings.length; ++i) {
-            if (falseStrings[i].equals(stringValue)) {
-                return Boolean.FALSE;
+            for (int i = 0; i < falseStrings.length; ++i) {
+                if (falseStrings[i].equals(stringValue)) {
+                    return type.cast(Boolean.FALSE);
+                }
             }
         }
 
-        throw new ConversionException("Can't convert value '" + value + "' to a Boolean");
+        throw conversionException(type, value);
     }
 
     /**

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ByteConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ByteConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ByteConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ByteConverter.java Fri Nov  8 21:08:30 2013
@@ -60,7 +60,7 @@ public final class ByteConverter extends
      * @since 1.8.0
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<Byte> getDefaultType() {
         return Byte.class;
     }
 

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/CalendarConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/CalendarConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/CalendarConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/CalendarConverter.java Fri Nov  8 21:08:30 2013
@@ -61,7 +61,7 @@ public final class CalendarConverter ext
      * @return The default type this <code>Converter</code> handles.
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<?> getDefaultType() {
         return Calendar.class;
     }
 

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/CharacterConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/CharacterConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/CharacterConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/CharacterConverter.java Fri Nov  8 21:08:30 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.beanutils.converters;
 
+
 /**
  * {@link org.apache.commons.beanutils.Converter} implementaion that handles conversion
  * to and from <b>java.lang.Character</b> objects.
@@ -55,7 +56,7 @@ public final class CharacterConverter ex
      * @since 1.8.0
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<?> getDefaultType() {
         return Character.class;
     }
 
@@ -82,8 +83,12 @@ public final class CharacterConverter ex
      * @since 1.8.0
      */
     @Override
-    protected Object convertToType(Class type, Object value) throws Exception {
-        return new Character(value.toString().charAt(0));
+    protected <T> T convertToType(Class<T> type, Object value) throws Exception {
+        if (Character.class.equals(type) || Character.TYPE.equals(type)) {
+            return type.cast(new Character(value.toString().charAt(0)));
+        }
+
+        throw conversionException(type, value);
     }
 
 }

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ClassConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ClassConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ClassConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ClassConverter.java Fri Nov  8 21:08:30 2013
@@ -59,7 +59,7 @@ public final class ClassConverter extend
      * @since 1.8.0
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<?> getDefaultType() {
         return Class.class;
     }
 
@@ -72,7 +72,7 @@ public final class ClassConverter extend
      */
     @Override
     protected String convertToString(Object value) {
-        return (value instanceof Class) ? ((Class)value).getName() : value.toString();
+        return (value instanceof Class) ? ((Class<?>)value).getName() : value.toString();
     }
 
     /**
@@ -85,21 +85,25 @@ public final class ClassConverter extend
      * @since 1.8.0
      */
     @Override
-    protected Object convertToType(Class type, Object value) throws Throwable {
-        ClassLoader classLoader =
-            Thread.currentThread().getContextClassLoader();
-        if (classLoader != null) {
-            try {
-                return (classLoader.loadClass(value.toString()));
-            } catch (ClassNotFoundException ex) {
-                // Don't fail, carry on and try this class's class loader
-                // (see issue# BEANUTILS-263)
+    protected <T> T convertToType(Class<T> type, Object value) throws Throwable {
+        if (Class.class.equals(type)) {
+            ClassLoader classLoader = Thread.currentThread()
+                    .getContextClassLoader();
+            if (classLoader != null) {
+                try {
+                    return type.cast(classLoader.loadClass(value.toString()));
+                } catch (ClassNotFoundException ex) {
+                    // Don't fail, carry on and try this class's class loader
+                    // (see issue# BEANUTILS-263)
+                }
             }
+
+            // Try this class's class loader
+            classLoader = ClassConverter.class.getClassLoader();
+            return type.cast(classLoader.loadClass(value.toString()));
         }
 
-        // Try this class's class loader
-        classLoader = ClassConverter.class.getClassLoader();
-        return (classLoader.loadClass(value.toString()));
+        throw conversionException(type, value);
     }
 
 }

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ConverterFacade.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ConverterFacade.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ConverterFacade.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/ConverterFacade.java Fri Nov  8 21:08:30 2013
@@ -52,11 +52,12 @@ public final class ConverterFacade imple
      * specified type by delegating to the underlying {@link Converter}
      * implementation.
      *
+     * @param <T> The result type of the conversion
      * @param type Data type to which this value should be converted
      * @param value The input value to be converted
      * @return The converted value.
      */
-    public Object convert(Class type, Object value) {
+    public <T> T convert(Class<T> type, Object value) {
         return converter.convert(type, value);
     }
 

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DateConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DateConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DateConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DateConverter.java Fri Nov  8 21:08:30 2013
@@ -61,7 +61,7 @@ public final class DateConverter extends
      * @return The default type this <code>Converter</code> handles.
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<?> getDefaultType() {
         return Date.class;
     }
 

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DateTimeConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DateTimeConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DateTimeConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DateTimeConverter.java Fri Nov  8 21:08:30 2013
@@ -16,13 +16,14 @@
  */
 package org.apache.commons.beanutils.converters;
 
+import java.text.DateFormat;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.Locale;
-import java.util.Calendar;
 import java.util.TimeZone;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.text.ParsePosition;
+
 import org.apache.commons.beanutils.ConversionException;
 
 /**
@@ -277,15 +278,16 @@ public abstract class DateTimeConverter 
      * Otherwise the default <code>DateFormat</code> for the default locale
      * (and <i>style</i> if configured) will be used.
      *
+     * @param <T> The desired target type of the conversion.
      * @param targetType Data type to which this value should be converted.
      * @param value The input value to be converted.
      * @return The converted value.
      * @throws Exception if conversion cannot be performed successfully
      */
     @Override
-    protected Object convertToType(Class targetType, Object value) throws Exception {
+    protected <T> T convertToType(Class<T> targetType, Object value) throws Exception {
 
-        Class sourceType = value.getClass();
+        Class<?> sourceType = value.getClass();
 
         // Handle java.sql.Timestamp
         if (value instanceof java.sql.Timestamp) {
@@ -335,7 +337,7 @@ public abstract class DateTimeConverter 
                 calendar = parse(sourceType, targetType, stringValue, format);
             }
             if (Calendar.class.isAssignableFrom(targetType)) {
-                return calendar;
+                return targetType.cast(calendar);
             } else {
                 return toDate(targetType, calendar.getTime().getTime());
             }
@@ -360,30 +362,31 @@ public abstract class DateTimeConverter 
      *     <li><code>java.sql.Timestamp</code></li>
      * </ul>
      *
+     * @param <T> The target type
      * @param type The Date type to convert to
      * @param value The long value to convert.
      * @return The converted date value.
      */
-    private Object toDate(Class type, long value) {
+    private <T> T toDate(Class<T> type, long value) {
 
         // java.util.Date
         if (type.equals(Date.class)) {
-            return new Date(value);
+            return type.cast(new Date(value));
         }
 
         // java.sql.Date
         if (type.equals(java.sql.Date.class)) {
-            return new java.sql.Date(value);
+            return type.cast(new java.sql.Date(value));
         }
 
         // java.sql.Time
         if (type.equals(java.sql.Time.class)) {
-            return new java.sql.Time(value);
+            return type.cast(new java.sql.Time(value));
         }
 
         // java.sql.Timestamp
         if (type.equals(java.sql.Timestamp.class)) {
-            return new java.sql.Timestamp(value);
+            return type.cast(new java.sql.Timestamp(value));
         }
 
         // java.util.Calendar
@@ -400,7 +403,7 @@ public abstract class DateTimeConverter 
             }
             calendar.setTime(new Date(value));
             calendar.setLenient(false);
-            return calendar;
+            return type.cast(calendar);
         }
 
         String msg = toString(getClass()) + " cannot handle conversion to '"
@@ -425,15 +428,16 @@ public abstract class DateTimeConverter 
      * mechanism is provided for <code>java.util.Date</code>
      * and <code>java.util.Calendar</code> type.
      *
-     * @param type The Number type to convert to
+     * @param <T> The target type
+     * @param type The date type to convert to
      * @param value The String value to convert.
      * @return The converted Number value.
      */
-    private Object toDate(Class type, String value) {
+    private <T> T toDate(Class<T> type, String value) {
         // java.sql.Date
         if (type.equals(java.sql.Date.class)) {
             try {
-                return java.sql.Date.valueOf(value);
+                return type.cast(java.sql.Date.valueOf(value));
             } catch (IllegalArgumentException e) {
                 throw new ConversionException(
                         "String must be in JDBC format [yyyy-MM-dd] to create a java.sql.Date");
@@ -443,7 +447,7 @@ public abstract class DateTimeConverter 
         // java.sql.Time
         if (type.equals(java.sql.Time.class)) {
             try {
-                return java.sql.Time.valueOf(value);
+                return type.cast(java.sql.Time.valueOf(value));
             } catch (IllegalArgumentException e) {
                 throw new ConversionException(
                         "String must be in JDBC format [HH:mm:ss] to create a java.sql.Time");
@@ -453,7 +457,7 @@ public abstract class DateTimeConverter 
         // java.sql.Timestamp
         if (type.equals(java.sql.Timestamp.class)) {
             try {
-                return java.sql.Timestamp.valueOf(value);
+                return type.cast(java.sql.Timestamp.valueOf(value));
             } catch (IllegalArgumentException e) {
                 throw new ConversionException(
                         "String must be in JDBC format [yyyy-MM-dd HH:mm:ss.fffffffff] " +
@@ -514,7 +518,7 @@ public abstract class DateTimeConverter 
      * @return The converted Date object.
      * @throws Exception if an error occurs parsing the date.
      */
-    private Calendar parse(Class sourceType, Class targetType, String value) throws Exception {
+    private Calendar parse(Class<?> sourceType, Class<?> targetType, String value) throws Exception {
         Exception firstEx = null;
         for (int i = 0; i < patterns.length; i++) {
             try {
@@ -547,7 +551,7 @@ public abstract class DateTimeConverter 
      * @return The converted Calendar object.
      * @throws ConversionException if the String cannot be converted.
      */
-    private Calendar parse(Class sourceType, Class targetType, String value, DateFormat format) {
+    private Calendar parse(Class<?> sourceType, Class<?> targetType, String value, DateFormat format) {
         logFormat("Parsing", format);
         format.setLenient(false);
         ParsePosition pos = new ParsePosition(0);

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DoubleConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DoubleConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DoubleConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/DoubleConverter.java Fri Nov  8 21:08:30 2013
@@ -60,7 +60,7 @@ public final class DoubleConverter exten
      * @since 1.8.0
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<Double> getDefaultType() {
         return Double.class;
     }
 

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/FileConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/FileConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/FileConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/FileConverter.java Fri Nov  8 21:08:30 2013
@@ -57,13 +57,14 @@ public final class FileConverter extends
      * @since 1.8.0
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<?> getDefaultType() {
         return File.class;
     }
 
     /**
      * <p>Convert the input object into a java.io.File.</p>
      *
+     * @param <T> The target type of the conversion.
      * @param type Data type to which this value should be converted.
      * @param value The input value to be converted.
      * @return The converted value.
@@ -71,7 +72,11 @@ public final class FileConverter extends
      * @since 1.8.0
      */
     @Override
-    protected Object convertToType(Class type, Object value) throws Throwable {
-        return new File(value.toString());
+    protected <T> T convertToType(Class<T> type, Object value) throws Throwable {
+        if (File.class.equals(type)) {
+            return type.cast(new File(value.toString()));
+        }
+
+        throw conversionException(type, value);
     }
 }

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/FloatConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/FloatConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/FloatConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/FloatConverter.java Fri Nov  8 21:08:30 2013
@@ -60,7 +60,7 @@ public final class FloatConverter extend
      * @since 1.8.0
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<Float> getDefaultType() {
         return Float.class;
     }
 

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/IntegerConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/IntegerConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/IntegerConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/IntegerConverter.java Fri Nov  8 21:08:30 2013
@@ -60,7 +60,7 @@ public final class IntegerConverter exte
      * @since 1.8.0
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<Integer> getDefaultType() {
         return Integer.class;
     }
 

Modified: commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/LongConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/LongConverter.java?rev=1540186&r1=1540185&r2=1540186&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/LongConverter.java (original)
+++ commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/LongConverter.java Fri Nov  8 21:08:30 2013
@@ -60,7 +60,7 @@ public final class LongConverter extends
      * @since 1.8.0
      */
     @Override
-    protected Class getDefaultType() {
+    protected Class<Long> getDefaultType() {
         return Long.class;
     }