commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1516583 - /commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/PropertyConverter.java
Date Thu, 22 Aug 2013 20:03:32 GMT
Author: oheger
Date: Thu Aug 22 20:03:32 2013
New Revision: 1516583

URL: http://svn.apache.org/r1516583
Log:
Removed obsolete method and made PropertyConverter package protected.

The PropertyConverter class is now only accessed by DefaultConversionHandler.
For other components, there is no need to call low-level conversion methods
directly.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/PropertyConverter.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/PropertyConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/PropertyConverter.java?rev=1516583&r1=1516582&r2=1516583&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/PropertyConverter.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/PropertyConverter.java
Thu Aug 22 20:03:32 2013
@@ -42,7 +42,7 @@ import org.apache.commons.lang3.StringUt
  * @version $Id$
  * @since 1.1
  */
-public final class PropertyConverter
+final class PropertyConverter
 {
     /** Constant for the list delimiter as char.*/
     static final char LIST_ESC_CHAR = '\\';
@@ -77,110 +77,6 @@ public final class PropertyConverter
     }
 
     /**
-     * Converts the specified value to the target class. If the class is a
-     * primitive type (Integer.TYPE, Boolean.TYPE, etc) the value returned
-     * will use the wrapper type (Integer.class, Boolean.class, etc).
-     *
-     * @param cls   the target class of the converted value
-     * @param value the value to convert
-     * @param params optional parameters used for the conversion
-     * @return the converted value
-     * @throws ConversionException if the value is not compatible with the requested type
-     *
-     * @since 1.5
-     */
-    public static Object to(Class<?> cls, Object value, Object[] params) throws ConversionException
-    {
-        if (cls.isInstance(value))
-        {
-            return value; // no conversion needed
-        }
-
-        if (String.class.equals(cls))
-        {
-            return String.valueOf(value);
-        }
-        if (Boolean.class.equals(cls) || Boolean.TYPE.equals(cls))
-        {
-            return toBoolean(value);
-        }
-        else if (Character.class.equals(cls) || Character.TYPE.equals(cls))
-        {
-            return toCharacter(value);
-        }
-        else if (Number.class.isAssignableFrom(cls) || cls.isPrimitive())
-        {
-            if (Integer.class.equals(cls) || Integer.TYPE.equals(cls))
-            {
-                return toInteger(value);
-            }
-            else if (Long.class.equals(cls) || Long.TYPE.equals(cls))
-            {
-                return toLong(value);
-            }
-            else if (Byte.class.equals(cls) || Byte.TYPE.equals(cls))
-            {
-                return toByte(value);
-            }
-            else if (Short.class.equals(cls) || Short.TYPE.equals(cls))
-            {
-                return toShort(value);
-            }
-            else if (Float.class.equals(cls) || Float.TYPE.equals(cls))
-            {
-                return toFloat(value);
-            }
-            else if (Double.class.equals(cls) || Double.TYPE.equals(cls))
-            {
-                return toDouble(value);
-            }
-            else if (BigInteger.class.equals(cls))
-            {
-                return toBigInteger(value);
-            }
-            else if (BigDecimal.class.equals(cls))
-            {
-                return toBigDecimal(value);
-            }
-        }
-        else if (Date.class.equals(cls))
-        {
-            return toDate(value, (String) params[0]);
-        }
-        else if (Calendar.class.equals(cls))
-        {
-            return toCalendar(value, (String) params[0]);
-        }
-        else if (URL.class.equals(cls))
-        {
-            return toURL(value);
-        }
-        else if (Locale.class.equals(cls))
-        {
-            return toLocale(value);
-        }
-        else if (isEnum(cls))
-        {
-            return convertToEnum(cls, value);
-        }
-        else if (Color.class.equals(cls))
-        {
-            return toColor(value);
-        }
-        else if (cls.getName().equals(INTERNET_ADDRESS_CLASSNAME))
-        {
-            return toInternetAddress(value);
-        }
-        else if (InetAddress.class.isAssignableFrom(cls))
-        {
-            return toInetAddress(value);
-        }
-
-        throw new ConversionException("The value '" + value + "' (" + value.getClass() +
")"
-                + " can't be converted to a " + cls.getName() + " object");
-    }
-
-    /**
      * Performs a data type conversion from the specified value object to the
      * given target data class. If additional information is required for this
      * conversion, it is obtained from the passed in



Mime
View raw message