commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r354018 - /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java
Date Mon, 05 Dec 2005 08:23:03 GMT
Author: ebourg
Date: Mon Dec  5 00:23:00 2005
New Revision: 354018

URL: http://svn.apache.org/viewcvs?rev=354018&view=rev
Log:
Reduced the usage of 'magic numbers' for checkstyle

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

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java?rev=354018&r1=354017&r2=354018&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java
Mon Dec  5 00:23:00 2005
@@ -538,18 +538,20 @@
                     color = color.substring(1);
                 }
 
-                int red = Integer.parseInt(color.substring(0, 2), 16);
-                int green = Integer.parseInt(color.substring(2, 4), 16);
-                int blue = Integer.parseInt(color.substring(4, 6), 16);
+                int[] components = new int[3];
+                for (int i = 0; i < components.length; i++) {
+                    components[i] = Integer.parseInt(color.substring(i, i + 2), HEX_RADIX);
+                }
+
                 int alpha = 255;
 
                 // parse the transparency
                 if (color.length() >= 8)
                 {
-                    alpha = Integer.parseInt(color.substring(6, 8), 16);
+                    alpha = Integer.parseInt(color.substring(6, 8), HEX_RADIX);
                 }
 
-                return new Color(red, green, blue, alpha);
+                return new Color(components[0], components[1], components[2], alpha);
             }
             catch (Exception e)
             {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message