commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r629478 - in /commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2: DataConfiguration.java PropertyConverter.java
Date Wed, 20 Feb 2008 14:35:56 GMT
Author: ebourg
Date: Wed Feb 20 06:35:54 2008
New Revision: 629478

URL: http://svn.apache.org/viewvc?rev=629478&view=rev
Log:
Minor simplifications to use varargs methods
Changed PropertyConverter.toLocale() to use the JDK split method

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DataConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertyConverter.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DataConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DataConfiguration.java?rev=629478&r1=629477&r2=629478&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DataConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DataConfiguration.java
Wed Feb 20 06:35:54 2008
@@ -223,11 +223,11 @@
             {
                 if (Date.class.equals(cls) || Calendar.class.equals(cls))
                 {
-                    return PropertyConverter.to(cls, interpolate(value), new String[] {getDefaultDateFormat()});
+                    return PropertyConverter.to(cls, interpolate(value), getDefaultDateFormat());
                 }
                 else
                 {
-                    return PropertyConverter.to(cls, interpolate(value), null);
+                    return PropertyConverter.to(cls, interpolate(value));
                 }
             }
             catch (ConversionException e)
@@ -471,7 +471,7 @@
                 int i = 0;
                 for (Object o : values)
                 {
-                    Array.set(array, i++, PropertyConverter.to(ClassUtils.primitiveToWrapper(cls),
interpolate(o), null));
+                    Array.set(array, i++, PropertyConverter.to(ClassUtils.primitiveToWrapper(cls),
interpolate(o)));
                 }
             }
             else
@@ -479,7 +479,7 @@
                 try
                 {
                     // attempt to convert a single value
-                    Object convertedValue = PropertyConverter.to(ClassUtils.primitiveToWrapper(cls),
interpolate(value), null);
+                    Object convertedValue = PropertyConverter.to(ClassUtils.primitiveToWrapper(cls),
interpolate(value));
 
                     // create an array of one element
                     array = Array.newInstance(cls, 1);

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertyConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertyConverter.java?rev=629478&r1=629477&r2=629478&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertyConverter.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertyConverter.java
Wed Feb 20 06:35:54 2008
@@ -62,9 +62,6 @@
     /** Constant for the radix of hex numbers.*/
     private static final int HEX_RADIX = 16;
 
-    /** Constant for the argument classes of the Number constructor that takes a String.
*/
-    private static final Class<?>[] CONSTR_ARGS = {String.class};
-
     /** The fully qualified name of {@link javax.mail.internet.InternetAddress} */
     private static final String INTERNET_ADDRESS_CLASSNAME = "javax.mail.internet.InternetAddress";
 
@@ -408,7 +405,7 @@
 
             try
             {
-                Constructor<? extends Number> constr = targetClass.getConstructor(CONSTR_ARGS);
+                Constructor<? extends Number> constr = targetClass.getConstructor(String.class);
                 return (Number) constr.newInstance(str);
             }
             catch (InvocationTargetException itex)
@@ -472,14 +469,14 @@
         }
         else if (value instanceof String)
         {
-            List<String> elements = split((String) value, '_');
-            int size = elements.size();
+            String[] elements = ((String) value).split("_");
+            int size = elements.length;
 
-            if (size >= 1 && ((elements.get(0)).length() == 2 || (elements.get(0)).length()
== 0))
+            if (size >= 1 && ((elements[0]).length() == 2 || (elements[0]).length()
== 0))
             {
-                String language = elements.get(0);
-                String country = (size >= 2) ? elements.get(1) : "";
-                String variant = (size >= 3) ? elements.get(2) : "";
+                String language = elements[0];
+                String country = (size >= 2) ? elements[1] : "";
+                String variant = (size >= 3) ? elements[2] : "";
 
                 return new Locale(language, country, variant);
             }



Mime
View raw message