svn commit: r225487 - in /jakarta/commons/proper/configuration/trunk: conf/test.properties src/java/org/apache/commons/configuration/PropertiesConfiguration.java src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java xdocs/changes.xml

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r225487 - in /jakarta/commons/proper/configuration/trunk: conf/test.properties src/java/org/apache/commons/configuration/PropertiesConfiguration.java src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java xdocs/changes.xml

Emmanuel Bourg-3
Author: ebourg
Date: Wed Jul 27 03:01:31 2005
New Revision: 225487

URL: http://svn.apache.org/viewcvs?rev=225487&view=rev
Log:
Add '!' as a comment marker for PropertiesConfiguration (Bug 35888)

Modified:
    jakarta/commons/proper/configuration/trunk/conf/test.properties
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
    jakarta/commons/proper/configuration/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/configuration/trunk/conf/test.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/conf/test.properties?rev=225487&r1=225486&r2=225487&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/conf/test.properties (original)
+++ jakarta/commons/proper/configuration/trunk/conf/test.properties Wed Jul 27 03:01:31 2005
@@ -74,3 +74,7 @@
 test.path = C:\\path2\\
 test.path = C:\\path3\\\
 complex\\test\\
+
+
+#comment = this is not a property but a comment line starting with '#'
+!comment = this is not a property but a comment line starting with '!'

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=225487&r1=225486&r2=225487&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 Wed Jul 27 03:01:31 2005
@@ -16,14 +16,14 @@
 
 package org.apache.commons.configuration;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FilterWriter;
 import java.io.IOException;
 import java.io.LineNumberReader;
 import java.io.Reader;
-import java.io.Writer;
 import java.io.StringReader;
-import java.io.BufferedReader;
+import java.io.Writer;
 import java.net.URL;
 import java.util.Date;
 import java.util.Iterator;
@@ -68,7 +68,7 @@
  *   like if they were on the same line separated with commas.
  *  </li>
  *  <li>
- *   Blank lines and lines starting with character '#' are skipped.
+ *   Blank lines and lines starting with character '#' or '!' are skipped.
  *  </li>
  *  <li>
  *   If a property is named "include" (or whatever is defined by
@@ -414,7 +414,7 @@
         /**
          * Read a property. Returns null if Stream is
          * at EOF. Concatenates lines ending with "\".
-         * Skips lines beginning with "#" and empty lines.
+         * Skips lines beginning with "#" or "!" and empty lines.
          *
          * @return A string containing a property value or null
          *
@@ -436,7 +436,7 @@
                 line = line.trim();
 
                 // skip comments and empty lines
-                if (StringUtils.isEmpty(line) || (line.charAt(0) == '#'))
+                if (StringUtils.isEmpty(line) || (line.charAt(0) == '#') || (line.charAt(0) == '!'))
                 {
                     continue;
                 }

Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java?rev=225487&r1=225486&r2=225487&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java Wed Jul 27 03:01:31 2005
@@ -19,6 +19,13 @@
 import java.io.File;
 import java.io.FileWriter;
 import java.io.PrintWriter;
+import java.io.PipedOutputStream;
+import java.io.PipedInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.FileInputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -347,7 +354,7 @@
         assertEquals("C:\\path2\\", list.get(1));
         assertEquals("C:\\path3\\complex\\test\\", list.get(2));
     }
-    
+
     /**
      * Tests if included files are loaded when the source lies in the class path.
      */
@@ -355,5 +362,13 @@
     {
         conf = new PropertiesConfiguration("test.properties");
         assertEquals("true", conf.getString("include.loaded"));
+    }
+
+    /**
+     * Test if the lines starting with # or ! are properly ignored.
+     */
+    public void testComment() {
+        assertFalse("comment line starting with '#' parsed as a property", conf.containsKey("#comment"));
+        assertFalse("comment line starting with '!' parsed as a property", conf.containsKey("!comment"));
     }
 }

Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?rev=225487&r1=225486&r2=225487&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Wed Jul 27 03:01:31 2005
@@ -23,6 +23,9 @@
   <body>
 
     <release version="1.2-dev" date="in SVN">
+      <action dev="ebourg" type="update" issue="35888">
+        Comment lines for PropertiesConfiguration can start with the '!' char (compatibility with java.util.Properties)
+      </action>
       <action dev="oheger" type="update" issue="35772">
         Because ConfigurationUtils.copy() does not fully support hierarchical
         configurations a clone() method was added to HierarchicalConfiguration



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]