commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r755741 - /commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
Date Wed, 18 Mar 2009 21:34:46 GMT
Author: oheger
Date: Wed Mar 18 21:34:46 2009
New Revision: 755741

URL: http://svn.apache.org/viewvc?rev=755741&view=rev
Log:
CONFIGURATION-370: Added some protected methods to the API of PropertiesReader so that it
can be easier extended.

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

Modified: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java?rev=755741&r1=755740&r2=755741&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
Wed Mar 18 21:34:46 2009
@@ -698,9 +698,7 @@
             }
 
             // parse the line
-            String[] property = parseProperty(line);
-            propertyName = StringEscapeUtils.unescapeJava(property[0]);
-            propertyValue = unescapeJava(property[1], delimiter);
+            parseProperty(line);
             return true;
         }
 
@@ -743,6 +741,51 @@
         }
 
         /**
+         * Parses a line read from the properties file. This method is called
+         * for each non-comment line read from the source file. Its task is to
+         * split the passed in line into the property key and its value. The
+         * results of the parse operation can be stored by calling the
+         * <code>initPropertyXXX()</code> methods.
+         *
+         * @param line the line read from the properties file
+         * @since 1.7
+         */
+        protected void parseProperty(String line)
+        {
+            String[] property = doParseProperty(line);
+            initPropertyName(property[0]);
+            initPropertyValue(property[1]);
+        }
+
+        /**
+         * Sets the name of the current property. This method can be called by
+         * <code>parseProperty()</code> for storing the results of the parse
+         * operation. It also ensures that the property key is correctly
+         * escaped.
+         *
+         * @param name the name of the current property
+         * @since 1.7
+         */
+        protected void initPropertyName(String name)
+        {
+            propertyName = StringEscapeUtils.unescapeJava(name);
+        }
+
+        /**
+         * Sets the value of the current property. This method can be called by
+         * <code>parseProperty()</code> for storing the results of the parse
+         * operation. It also ensures that the property value is correctly
+         * escaped.
+         *
+         * @param value the value of the current property
+         * @since 1.7
+         */
+        protected void initPropertyValue(String value)
+        {
+            propertyValue = unescapeJava(value, delimiter);
+        }
+
+        /**
          * Checks if the passed in line should be combined with the following.
          * This is true, if the line ends with an odd number of backslashes.
          *
@@ -765,9 +808,8 @@
          *
          * @param line the line to parse
          * @return an array with the property's key and value
-         * @since 1.2
          */
-        private static String[] parseProperty(String line)
+        private static String[] doParseProperty(String line)
         {
             // sorry for this spaghetti code, please replace it as soon as
             // possible with a regexp when the Java 1.3 requirement is dropped



Mime
View raw message