commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r354264 - in /jakarta/commons/proper/configuration/trunk: ./ conf/ src/java/org/apache/commons/configuration/ src/java/org/apache/commons/configuration/plist/
Date Tue, 06 Dec 2005 03:10:37 GMT
Author: ebourg
Date: Mon Dec  5 19:10:27 2005
New Revision: 354264

URL: http://svn.apache.org/viewcvs?rev=354264&view=rev
Log:
Fixed the remaining legitimate checkstyle and PMD issues

Modified:
    jakarta/commons/proper/configuration/trunk/conf/checkstyle-suppressions.xml
    jakarta/commons/proper/configuration/trunk/project.properties
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationMap.java
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java

Modified: jakarta/commons/proper/configuration/trunk/conf/checkstyle-suppressions.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/conf/checkstyle-suppressions.xml?rev=354264&r1=354263&r2=354264&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/conf/checkstyle-suppressions.xml (original)
+++ jakarta/commons/proper/configuration/trunk/conf/checkstyle-suppressions.xml Mon Dec  5
19:10:27 2005
@@ -16,5 +16,7 @@
     <suppress checks=".*" files="SimpleCharStream.java"/>
     <suppress checks=".*" files="Token.java"/>
     <suppress checks=".*" files="TokenMgrError.java"/>
+    
+    <suppress checks="MissingSwitchDefault" files="PropertiesConfiguration.java"/>
 
 </suppressions>

Modified: jakarta/commons/proper/configuration/trunk/project.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/project.properties?rev=354264&r1=354263&r2=354264&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/project.properties (original)
+++ jakarta/commons/proper/configuration/trunk/project.properties Mon Dec  5 19:10:27 2005
@@ -19,6 +19,7 @@
 compile.deprecation = off
 
 maven.checkstyle.properties=conf/checkstyle.xml
+maven.pmd.excludes=**/*PropertyListParser*
 
 maven.junit.fork=true
 maven.test.failure.ignore=false

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java?rev=354264&r1=354263&r2=354264&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java
Mon Dec  5 19:10:27 2005
@@ -48,7 +48,7 @@
     protected static final String END_TOKEN = "}";
 
     /** The property delimiter used while parsing (a comma). */
-    private static char DELIMITER = ',';
+    private static char delimiter = ',';
 
     /**
      * Whether the configuration should throw NoSuchElementExceptions or simply
@@ -64,7 +64,7 @@
      */
     public static void setDelimiter(char delimiter)
     {
-        AbstractConfiguration.DELIMITER = delimiter;
+        AbstractConfiguration.delimiter = delimiter;
     }
 
     /**
@@ -74,7 +74,7 @@
      */
     public static char getDelimiter()
     {
-        return AbstractConfiguration.DELIMITER;
+        return AbstractConfiguration.delimiter;
     }
 
     /**
@@ -108,7 +108,7 @@
      */
     public void addProperty(String key, Object value)
     {
-        Iterator it = PropertyConverter.toIterator(value, DELIMITER);
+        Iterator it = PropertyConverter.toIterator(value, getDelimiter());
         while (it.hasNext())
         {
             addPropertyDirect(key, it.next());

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationMap.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationMap.java?rev=354264&r1=354263&r2=354264&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationMap.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationMap.java
Mon Dec  5 19:10:27 2005
@@ -91,12 +91,20 @@
         return configuration.getProperty(String.valueOf(key));
     }
 
+    /**
+     * Set of entries in the map.
+     */
     static class ConfigurationSet extends AbstractSet
     {
+        /** The configuration mapped to this entry set. */
         private Configuration configuration;
 
-        private class Entry implements Map.Entry
+        /**
+         * A Map entry in the ConfigurationMap.
+         */
+        private final class Entry implements Map.Entry
         {
+            /** The key of the map entry. */
             private Object key;
 
             private Entry(Object key)
@@ -120,11 +128,14 @@
                 configuration.setProperty((String) key, value);
                 return old;
             }
-
         }
 
-        private class ConfigurationSetIterator implements Iterator
+        /**
+         * Iterator over the entries in the ConfigurationMap.
+         */
+        private final class ConfigurationSetIterator implements Iterator
         {
+            /** An iterator over the keys in the configuration. */
             private Iterator keys;
 
             private ConfigurationSetIterator()
@@ -146,7 +157,6 @@
             {
                 keys.remove();
             }
-
         }
 
         ConfigurationSet(Configuration configuration)

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java?rev=354264&r1=354263&r2=354264&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
Mon Dec  5 19:10:27 2005
@@ -154,6 +154,12 @@
  */
 public class PropertiesConfiguration extends AbstractFileConfiguration
 {
+    /**
+     * This is the name of the property that can point to other
+     * properties file for including other properties files.
+     */
+    private static String include = "include";
+
     /** The list of possible key/value separators */
     private static final char[] SEPARATORS = new char[] {'=', ':'};
 
@@ -175,12 +181,6 @@
     /** Constant for the length of a unicode literal.*/
     private static final int UNICODE_LEN = 4;
 
-    /**
-     * This is the name of the property that can point to other
-     * properties file for including other properties files.
-     */
-    static String include = "include";
-
     /** Allow file inclusion or not */
     private boolean includesAllowed;
 
@@ -546,6 +546,7 @@
          *
          * @param key the key of the property
          * @param value the value of the property
+         *
          * @throws IOException if an I/O error occurs
          */
         public void writeProperty(String key, Object value) throws IOException
@@ -567,6 +568,8 @@
          *
          * @param key The key of the property
          * @param values The array of values of the property
+         *
+         * @throws IOException if an I/O error occurs
          */
         public void writeProperty(String key, List values) throws IOException
         {
@@ -830,6 +833,7 @@
                     if (ArrayUtils.contains(WHITE_SPACE, c))
                     {
                         // do nothing, eat all white spaces
+                        state = 2;
                     }
                     else if (ArrayUtils.contains(SEPARATORS, c))
                     {

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=354264&r1=354263&r2=354264&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 19:10:27 2005
@@ -56,6 +56,14 @@
     private static final int HEX_RADIX = 16;
 
     /**
+     * Private constructor prevents instances from being created.
+     */
+    private PropertyConverter()
+    {
+        // to prevent instanciation...
+    }
+
+    /**
      * Convert the specified object into a Boolean.
      *
      * @param value the value to convert
@@ -526,29 +534,42 @@
         {
             return (Color) value;
         }
-        else if (value instanceof String && !StringUtils.isBlank((String) value)
&& ((String) value).length() >= 6)
+        else if (value instanceof String && !StringUtils.isBlank((String) value))
         {
-            try
+            String color = ((String) value).trim();
+
+            int[] components = new int[3];
+
+            // check the size of the string
+            int minlength = components.length * 2;
+            if (color.length() < minlength)
             {
-                String color = ((String) value).trim();
+                throw new ConversionException("The value " + value + " can't be converted
to a Color");
+            }
 
-                // remove the leading #
-                if (color.startsWith("#"))
-                {
-                    color = color.substring(1);
-                }
+            // remove the leading #
+            if (color.startsWith("#"))
+            {
+                color = color.substring(1);
+            }
 
-                int[] components = new int[3];
-                for (int i = 0; i < components.length; i++) {
+            try
+            {
+                // parse the components
+                for (int i = 0; i < components.length; i++)
+                {
                     components[i] = Integer.parseInt(color.substring(2 * i, 2 * i + 2), HEX_RADIX);
                 }
 
-                int alpha = 255;
-
                 // parse the transparency
-                if (color.length() >= 8)
+                int alpha;
+                if (color.length() >= minlength + 2)
+                {
+                    alpha = Integer.parseInt(color.substring(minlength, minlength + 2), HEX_RADIX);
+                }
+                else
                 {
-                    alpha = Integer.parseInt(color.substring(6, 8), HEX_RADIX);
+                    alpha = Color.black.getAlpha();
                 }
 
                 return new Color(components[0], components[1], components[2], alpha);

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java?rev=354264&r1=354263&r2=354264&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java
Mon Dec  5 19:10:27 2005
@@ -66,6 +66,7 @@
  */
 public class PropertyListConfiguration extends AbstractHierarchicalFileConfiguration
 {
+    /** Size of the indentation for the generated file. */
     private static final int INDENT_SIZE = 4;
 
     /**
@@ -73,7 +74,9 @@
      * used to synthesize a new plist file by adding values and
      * then saving().
      */
-    public PropertyListConfiguration() { }
+    public PropertyListConfiguration()
+    {
+    }
 
     /**
      * Creates and loads the property list from the specified file.

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java?rev=354264&r1=354263&r2=354264&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java
Mon Dec  5 19:10:27 2005
@@ -115,6 +115,7 @@
  */
 public class XMLPropertyListConfiguration extends AbstractHierarchicalFileConfiguration
 {
+    /** Size of the indentation for the generated file. */
     private static final int INDENT_SIZE = 4;
 
     /**
@@ -122,7 +123,9 @@
      * used to synthesize a new plist file by adding values and
      * then saving().
      */
-    public XMLPropertyListConfiguration() { }
+    public XMLPropertyListConfiguration()
+    {
+    }
 
     /**
      * Creates and loads the property list from the specified file.
@@ -424,18 +427,17 @@
      */
     public static class PListNode extends Node
     {
+        /** The standard format of dates in plist files. */
         private static DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
 
-        public void addChild(Node child)
-        {
-            super.addChild(child);
-        }
-
-        public void setName(String string)
-        {
-            super.setName(string);
-        }
-
+        /**
+         * Update the value of the node. If the existing value is null, it's
+         * replaced with the new value. If the existing value is a list, the
+         * specified value is appended to the list. If the existing value is
+         * not null, a list with the two values is built.
+         *
+         * @param value the value to be added
+         */
         public void addValue(Object value)
         {
             if (getValue() == null)
@@ -456,6 +458,11 @@
             }
         }
 
+        /**
+         * Parse the specified string as a date and add it to the values of the node.
+         *
+         * @param value the value to be added
+         */
         public void addDateValue(String value)
         {
             try
@@ -468,31 +475,58 @@
             }
         }
 
+        /**
+         * Parse the specified string as a byte array in base 64 format
+         * and add it to the values of the node.
+         *
+         * @param value the value to be added
+         */
         public void addDataValue(String value)
         {
             addValue(Base64.decodeBase64(value.getBytes()));
         }
 
+        /**
+         * Parse the specified string as an Interger and add it to the values of the node.
+         *
+         * @param value the value to be added
+         */
         public void addIntegerValue(String value)
         {
             addValue(new Integer(value));
         }
 
+        /**
+         * Parse the specified string as a Double and add it to the values of the node.
+         *
+         * @param value the value to be added
+         */
         public void addRealValue(String value)
         {
             addValue(new Double(value));
         }
 
+        /**
+         * Add a boolean value 'true' to the values of the node.
+         */
         public void addTrueValue()
         {
             addValue(Boolean.TRUE);
         }
 
+        /**
+         * Add a boolean value 'false' to the values of the node.
+         */
         public void addFalseValue()
         {
             addValue(Boolean.FALSE);
         }
 
+        /**
+         * Add a sublist to the values of the node.
+         *
+         * @param node the node whose value will be added to the current node value
+         */
         public void addList(ArrayNode node)
         {
             addValue(node.getValue());
@@ -506,13 +540,24 @@
      */
     public static class ArrayNode extends PListNode
     {
+        /** The list of values in the array. */
         private List list = new ArrayList();
 
+        /**
+         * Add an object to the array.
+         *
+         * @param value the value to be added
+         */
         public void addValue(Object value)
         {
             list.add(value);
         }
 
+        /**
+         * Return the list of values in the array.
+         *
+         * @return the {@link List} of values
+         */
         public Object getValue()
         {
             return list;



---------------------------------------------------------------------
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