svn commit: r541270 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/ src/test/org/apache/commons/configuration/ xdocs/
Author: ebourg Date: Thu May 24 04:31:25 2007 New Revision: 541270 URL: http://svn.apache.org/viewvc?view=revrev=541270 Log: Fixed PropertiesConfiguration.save() to avoid escaping the list delimiter if it has been disabled (CONFIGURATION-269) Added: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/ConfigurationAssert.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfigurationLayout.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/src/java/org/apache/commons/configuration/PropertiesConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java?view=diffrev=541270r1=541269r2=541270 == --- 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 Thu May 24 04:31:25 2007 @@ -930,9 +930,12 @@ */ private String escapeValue(Object value) { -String v = StringEscapeUtils.escapeJava(String.valueOf(value)); -return StringUtils.replace(v, String.valueOf(delimiter), \\ -+ delimiter); +String escapedValue = StringEscapeUtils.escapeJava(String.valueOf(value)); +if (delimiter != 0) +{ +escapedValue = StringUtils.replace(escapedValue, String.valueOf(delimiter), \\ + delimiter); +} +return escapedValue; } /** Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfigurationLayout.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfigurationLayout.java?view=diffrev=541270r1=541269r2=541270 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfigurationLayout.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfigurationLayout.java Thu May 24 04:31:25 2007 @@ -348,7 +348,8 @@ * Sets the quot;force single linequot; flag. If this flag is set, all * properties with multiple values are written on single lines. This mode * provides more compatibility with codejava.lang.Properties/code, - * which cannot deal with multiple definitions of a single property. + * which cannot deal with multiple definitions of a single property. This + * mode has no effect if the list delimiter parsing is disabled. * * @param f the force single line flag */ @@ -442,8 +443,8 @@ { try { -PropertiesConfiguration.PropertiesWriter writer = new PropertiesConfiguration.PropertiesWriter( -out, getConfiguration().getListDelimiter()); +char delimiter = getConfiguration().isDelimiterParsingDisabled() ? 0 : getConfiguration().getListDelimiter(); +PropertiesConfiguration.PropertiesWriter writer = new PropertiesConfiguration.PropertiesWriter(out, delimiter); if (headerComment != null) { writer.writeln(getCanonicalHeaderComment(true)); @@ -469,8 +470,8 @@ } // Output the property and its value -writer.writeProperty(key, getConfiguration().getProperty( -key), isForceSingleLine() || isSingleLine(key)); +boolean singleLine = (isForceSingleLine() || isSingleLine(key)) !getConfiguration().isDelimiterParsingDisabled(); +writer.writeProperty(key, getConfiguration().getProperty(key), singleLine); } } writer.flush(); Added: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/ConfigurationAssert.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/ConfigurationAssert.java?view=autorev=541270 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/ConfigurationAssert.java (added) +++ jakarta/commons/proper/configuration/trunk/src
svn commit: r540529 - in /jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration: FileURLStreamHandler.java TestPropertiesConfiguration.java
Author: ebourg Date: Tue May 22 03:49:26 2007 New Revision: 540529 URL: http://svn.apache.org/viewvc?view=revrev=540529 Log: Added a test case for loading and saving configurations to non standard URLs using a custom URLStreamHandler (CONFIGURATION-249) Added: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/FileURLStreamHandler.java Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java Added: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/FileURLStreamHandler.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/FileURLStreamHandler.java?view=autorev=540529 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/FileURLStreamHandler.java (added) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/FileURLStreamHandler.java Tue May 22 03:49:26 2007 @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the License); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.configuration; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; + +/** + * A custom URLStreamHandler to test loading and saving configurations to non + * standard URLs. This handler acts like a file handler with write support. + * + * @author Emmanuel Bourg + * @version $Revision$, $Date$ + */ +public class FileURLStreamHandler extends URLStreamHandler +{ +protected URLConnection openConnection(URL u) throws IOException +{ +final File file = new File(u.getFile()); + +return new URLConnection(u) { + +public void connect() throws IOException +{ +} + +public InputStream getInputStream() throws IOException +{ +return new FileInputStream(file); +} + +public OutputStream getOutputStream() throws IOException +{ +return new FileOutputStream(file); +} +}; +} +} Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java?view=diffrev=540529r1=540528r2=540529 == --- 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 Tue May 22 03:49:26 2007 @@ -24,6 +24,7 @@ import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; +import java.net.URL; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -158,6 +159,17 @@ // Save it again, verifing a save with a filename works. checkConfig.save(); +} + +public void testSaveToCustomURL() throws Exception +{ +// save the configuration to a custom URL +URL url = new URL(foo, , 0, ./target/testsave-custom-url.properties, new FileURLStreamHandler()); +conf.save(url); + +// reload the configuration +Configuration config2 = new PropertiesConfiguration(url); +assertEquals(true, config2.getString(configuration.loaded)); } public void testInMemoryCreatedSave() throws Exception - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r540562 - in /jakarta/commons/proper/configuration/trunk: project.xml src/java/org/apache/commons/configuration/AbstractFileConfiguration.java src/test/org/apache/commons/configuration/Tes
Author: ebourg Date: Tue May 22 05:37:13 2007 New Revision: 540562 URL: http://svn.apache.org/viewvc?view=revrev=540562 Log: Added a test case for saving a configuration to a web server using a PUT request (CONFIGURATION-249) Minor code simplification in AbstractFileConfiguration Modified: jakarta/commons/proper/configuration/trunk/project.xml jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/project.xml URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/project.xml?view=diffrev=540562r1=540561r2=540562 == --- jakarta/commons/proper/configuration/trunk/project.xml (original) +++ jakarta/commons/proper/configuration/trunk/project.xml Tue May 22 05:37:13 2007 @@ -418,6 +418,26 @@ /dependency dependency + groupIdjetty/groupId + artifactIdjetty/artifactId + version6.0.2/version + properties +scopetest/scope + /properties +/dependency + +dependency + groupIdjetty/groupId + artifactIdjetty-util/artifactId + version6.0.2/version + properties +scopetest/scope + /properties +/dependency + +!-- Plugins -- + +dependency groupIdmaven-plugins/groupId artifactIdmaven-tasks-plugin/artifactId version1.1.0/version Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java?view=diffrev=540562r1=540561r2=540562 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java Tue May 22 05:37:13 2007 @@ -621,16 +621,13 @@ { return null; } +else if (sourceURL != null) +{ +return ConfigurationUtils.fileFromURL(sourceURL); +} else { -if (sourceURL != null) -{ -return ConfigurationUtils.fileFromURL(sourceURL); -} -else -{ -return ConfigurationUtils.getFile(getBasePath(), getFileName()); -} +return ConfigurationUtils.getFile(getBasePath(), getFileName()); } } Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java?view=diffrev=540562r1=540561r2=540562 == --- 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 Tue May 22 05:37:13 2007 @@ -18,6 +18,8 @@ package org.apache.commons.configuration; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; @@ -28,10 +30,18 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy; import junit.framework.TestCase; +import org.mortbay.jetty.Handler; +import org.mortbay.jetty.Request; +import org.mortbay.jetty.Server; +import org.mortbay.jetty.handler.AbstractHandler; +import org.mortbay.util.IO; /** * Test for loading and saving properties files. @@ -172,6 +182,66 @@ assertEquals(true, config2.getString(configuration.loaded)); } +public void testSaveToHTTPServer() throws Exception +{ +// set up the web server +Handler handler = new AbstractHandler() +{ +public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException +{ +File file = new File(. + target); + +if (GET.equals(request.getMethod())) { +if (file.exists() file.isFile
svn commit: r540786 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/INIConfiguration.java src/test/org/apache/commons/configuration/TestINIConfiguration.jav
Author: ebourg Date: Tue May 22 16:09:45 2007 New Revision: 540786 URL: http://svn.apache.org/viewvc?view=revrev=540786 Log: Fixed INIConfiguration.save() to handle collection values and interpolated variables (CONFIGURATION-270) Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java?view=diffrev=540786r1=540785r2=540786 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java Tue May 22 16:09:45 2007 @@ -24,6 +24,7 @@ import java.io.Reader; import java.io.Writer; import java.net.URL; +import java.util.Collection; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; @@ -57,7 +58,7 @@ * /code * * p - * The format of ini files is fairly straight forward and is comosed of three + * The format of ini files is fairly straight forward and is composed of three * components:br * ul * libSections:/b Ini files are split into sections, each section @@ -223,32 +224,44 @@ */ public void save(Writer writer) throws ConfigurationException { -PrintWriter pw = new PrintWriter(writer); +PrintWriter out = new PrintWriter(writer); Iterator it = getSections().iterator(); while (it.hasNext()) { String section = (String) it.next(); -pw.print([); -pw.print(section); -pw.print(]); -pw.println(); +out.print([); +out.print(section); +out.print(]); +out.println(); -Configuration values = subset(section); -Iterator keys = values.getKeys(); +Configuration subset = subset(section); +Iterator keys = subset.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); -String value = values.getString(key); -pw.print(key); -pw.print( = ); -pw.print(formatValue(value)); -pw.println(); +Object value = subset.getProperty(key); +if (value instanceof Collection) { +Iterator values = ((Collection) value).iterator(); +while (values.hasNext()) +{ +value = (Object) values.next(); +out.print(key); +out.print( = ); +out.print(formatValue(value.toString())); +out.println(); +} +} else { +out.print(key); +out.print( = ); +out.print(formatValue(value.toString())); +out.println(); +} } -pw.println(); +out.println(); } -pw.flush(); +out.flush(); } /** Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java?view=diffrev=540786r1=540785r2=540786 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java Tue May 22 16:09:45 2007 @@ -42,14 +42,17 @@ [section1] + LINE_SEPARATOR + var1 = foo + LINE_SEPARATOR + var2 = 451 + LINE_SEPARATOR - + LINE_SEPARATOR ++ LINE_SEPARATOR + [section2] + LINE_SEPARATOR + var1 = 123.45 + LINE_SEPARATOR + var2 = bar + LINE_SEPARATOR - + LINE_SEPARATOR ++ LINE_SEPARATOR + [section3] + LINE_SEPARATOR + var1 = true + LINE_SEPARATOR - + LINE_SEPARATOR; ++ interpolated = ${section3.var1} + LINE_SEPARATOR ++ multi = foo + LINE_SEPARATOR ++ multi = bar + LINE_SEPARATOR ++ LINE_SEPARATOR; private
svn commit: r532326 - /jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java
Author: ebourg Date: Wed Apr 25 04:48:00 2007 New Revision: 532326 URL: http://svn.apache.org/viewvc?view=revrev=532326 Log: Fixed the failing test case for INIConfiguration on non Windows systems Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java?view=diffrev=532326r1=532325r2=532326 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java Wed Apr 25 04:48:00 2007 @@ -30,33 +30,34 @@ /** * Test class for INIConfiguration. * - * @author trevor.miller - * @version $Id: TestHierarchicalConfiguration.java 439648 2006-09-02 20:42:10Z - * oheger $ + * @author Trevor Miller + * @version $Id$ */ public class TestINIConfiguration extends TestCase { - /** Constant for the content of an ini file. */ +private static String LINE_SEPARATOR = System.getProperty(line.separator); + +/** Constant for the content of an ini file. */ private static final String INI_DATA = -[section1]\r\n -+ var1 = foo\r\n -+ var2 = 451\r\n -+ \r\n -+ [section2]\r\n -+ var1 = 123.45\r\n -+ var2 = bar\r\n -+ \r\n -+ [section3]\r\n -+ var1 = true\r\n -+ \r\n; +[section1] + LINE_SEPARATOR ++ var1 = foo + LINE_SEPARATOR ++ var2 = 451 + LINE_SEPARATOR + + LINE_SEPARATOR ++ [section2] + LINE_SEPARATOR ++ var1 = 123.45 + LINE_SEPARATOR ++ var2 = bar + LINE_SEPARATOR + + LINE_SEPARATOR ++ [section3] + LINE_SEPARATOR ++ var1 = true + LINE_SEPARATOR + + LINE_SEPARATOR; private static final String INI_DATA2 = -[section4]\r\n -+ var1 = \quoted value\\r\n -+ var2 = \quoted value\\nwith \\\quotes\r\n -+ var3 = 123 ; comment\r\n -+ var4 = \1;2;3\ ; comment\r\n -+ var5 = '\\'quoted\\' \value\' ; comment\r\n; +[section4] + LINE_SEPARATOR ++ var1 = \quoted value\ + LINE_SEPARATOR ++ var2 = \quoted value\\nwith \\\quotes + LINE_SEPARATOR ++ var3 = 123 ; comment + LINE_SEPARATOR ++ var4 = \1;2;3\ ; comment + LINE_SEPARATOR ++ var5 = '\\'quoted\\' \value\' ; comment; /** * Test of save method, of class [EMAIL PROTECTED] INIConfiguration}. @@ -71,7 +72,8 @@ instance.addProperty(section2.var2, bar); instance.addProperty(section3.var1, true); instance.save(writer); - assertEquals(Wrong content of ini file, INI_DATA, writer.toString()); + +assertEquals(Wrong content of ini file, INI_DATA, writer.toString()); } /** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r532336 - in /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration: ./ event/ interpol/ plist/
Author: ebourg Date: Wed Apr 25 05:23:01 2007 New Revision: 532336 URL: http://svn.apache.org/viewvc?view=revrev=532336 Log: Fixed several checkstyle warnings Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationBuilder.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.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/event/EventSource.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/interpol/ConfigurationInterpolator.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/src/java/org/apache/commons/configuration/ConfigurationBuilder.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationBuilder.java?view=diffrev=532336r1=532335r2=532336 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationBuilder.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationBuilder.java Wed Apr 25 05:23:01 2007 @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.commons.configuration; /** @@ -28,9 +29,7 @@ * configuration constructed by this builder. * /p * - * @author a - * href=http://jakarta.apache.org/commons/configuration/team-list.html;Commons - * Configuration team/a + * @author a href=http://jakarta.apache.org/commons/configuration/team-list.html;Commons Configuration team/a * @version $Id$ */ public interface ConfigurationBuilder Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java?view=diffrev=532336r1=532335r2=532336 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java Wed Apr 25 05:23:01 2007 @@ -223,7 +223,7 @@ { if (Date.class.equals(cls) || Calendar.class.equals(cls)) { -return PropertyConverter.to(cls, interpolate(value), new String[] { getDefaultDateFormat() }); +return PropertyConverter.to(cls, interpolate(value), new String[] {getDefaultDateFormat()}); } else { @@ -289,7 +289,7 @@ Object[] params = null; if (cls.equals(Date.class) || cls.equals(Calendar.class)) { -params = new Object[] { getDefaultDateFormat() }; +params = new Object[] {getDefaultDateFormat()}; } try @@ -300,7 +300,8 @@ Class arrayType = valueClass.getComponentType(); int length = Array.getLength(value); -if (arrayType.equals(cls) || (arrayType.isPrimitive() cls.equals(ClassUtils.primitiveToWrapper(arrayType +if (arrayType.equals(cls) +|| (arrayType.isPrimitive() cls.equals(ClassUtils.primitiveToWrapper(arrayType { // the value is an array of the specified type, or an array // of the primitive type derived from the specified type @@ -381,7 +382,8 @@ // check the type of the default value if (defaultValue != null (!defaultValue.getClass().isArray() || !cls.isAssignableFrom(defaultValue.getClass().getComponentType( { -throw new IllegalArgumentException(The type of the default value ( + defaultValue.getClass() + ) is not an array of the specified class ( + cls + )); +throw new IllegalArgumentException(The type of the default value ( + defaultValue.getClass
svn commit: r532554 - /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java
Author: ebourg Date: Wed Apr 25 17:40:17 2007 New Revision: 532554 URL: http://svn.apache.org/viewvc?view=revrev=532554 Log: Code simplification in ConfigurationDynaBean ConfigurationDynaBean.set(String, Object) supports Collection values Fixed a potential ClassCastException in ConfigurationDynaBean(String, int, Object) for arrays of primitives Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java?view=diffrev=532554r1=532553r2=532554 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java Wed Apr 25 17:40:17 2007 @@ -17,6 +17,8 @@ package org.apache.commons.configuration.beanutils; +import java.lang.reflect.Array; +import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -26,7 +28,6 @@ import org.apache.commons.configuration.ConfigurationMap; import org.apache.commons.configuration.ConversionException; import org.apache.commons.configuration.SubsetConfiguration; -import org.apache.commons.lang.BooleanUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -65,6 +66,7 @@ /** * Creates a new instance of codeConfigurationDynaBean/code and sets * the configuration this bean is associated with. + * * @param configuration the configuration */ public ConfigurationDynaBean(Configuration configuration) @@ -88,85 +90,21 @@ throw new NullPointerException(Error trying to set property to null.); } -if (value instanceof List) +if (value instanceof Collection) { -List list = (List) value; -Iterator iterator = list.iterator(); +Collection collection = (Collection) value; +Iterator iterator = collection.iterator(); while (iterator.hasNext()) { getConfiguration().addProperty(name, iterator.next()); } } -else if (value instanceof int[]) +else if (value.getClass().isArray()) { -int[] array = (int[]) value; -for (int i = 0; i array.length; i++) +int length = Array.getLength(value); +for (int i = 0; i length; i++) { -getConfiguration().addProperty(name, new Integer(array[i])); -} -} -else if (value instanceof boolean[]) -{ -boolean[] array = (boolean[]) value; -for (int i = 0; i array.length; i++) -{ -getConfiguration().addProperty(name, BooleanUtils.toBooleanObject(array[i])); -} -} -else if (value instanceof char[]) -{ -char[] array = (char[]) value; -for (int i = 0; i array.length; i++) -{ -getConfiguration().addProperty(name, new Character(array[i])); -} -} -else if (value instanceof byte[]) -{ -byte[] array = (byte[]) value; -for (int i = 0; i array.length; i++) -{ -getConfiguration().addProperty(name, new Byte(array[i])); -} -} -else if (value instanceof short[]) -{ -short[] array = (short[]) value; -for (int i = 0; i array.length; i++) -{ -getConfiguration().addProperty(name, new Short(array[i])); -} -} -else if (value instanceof long[]) -{ -long[] array = (long[]) value; -for (int i = 0; i array.length; i++) -{ -getConfiguration().addProperty(name, new Long(array[i])); -} -} -else if (value instanceof float[]) -{ -float[] array = (float[]) value; -for (int i = 0; i array.length; i++) -{ -getConfiguration().addProperty(name, new Float(array[i])); -} -} -else if (value instanceof double[]) -{ -double[] array = (double[]) value; -for (int i = 0; i array.length; i++) -{ -getConfiguration().addProperty(name, new Double(array[i])); -} -} -else if (value instanceof Object[]) -{ -Object[] array = (Object[]) value; -for (int
svn commit: r531399 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/INIConfiguration.java xdocs/changes.xml
Author: ebourg Date: Mon Apr 23 02:39:29 2007 New Revision: 531399 URL: http://svn.apache.org/viewvc?view=revrev=531399 Log: Output flushing in INIConfiguration (CONFIGURATION-267) OS specific line separator in INIConfiguration Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java?view=diffrev=531399r1=531398r2=531399 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java Mon Apr 23 02:39:29 2007 @@ -173,9 +173,6 @@ */ protected static final String SEPARATOR_CHARS = =:; -/** Constant for the used line separator.*/ -private static final String LINE_SEPARATOR = \r\n; - /** * Create a new empty INI Configuration. */ @@ -227,29 +224,31 @@ public void save(Writer writer) throws ConfigurationException { PrintWriter pw = new PrintWriter(writer); -Iterator iter = this.getSections().iterator(); -while (iter.hasNext()) +Iterator it = getSections().iterator(); +while (it.hasNext()) { -String section = (String) iter.next(); +String section = (String) it.next(); pw.print([); pw.print(section); pw.print(]); -pw.print(LINE_SEPARATOR); +pw.println(); -Configuration values = this.subset(section); -Iterator iterator = values.getKeys(); -while (iterator.hasNext()) +Configuration values = subset(section); +Iterator keys = values.getKeys(); +while (keys.hasNext()) { -String key = (String) iterator.next(); +String key = (String) keys.next(); String value = values.getString(key); pw.print(key); pw.print( = ); pw.print(formatValue(value)); -pw.print(LINE_SEPARATOR); +pw.println(); } -pw.print(LINE_SEPARATOR); +pw.println(); } + +pw.flush(); } /** Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?view=diffrev=531399r1=531398r2=531399 == --- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original) +++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Mon Apr 23 02:39:29 2007 @@ -23,6 +23,13 @@ body release version=1.5-SNAPSHOT date=in SVN description= + action dev=ebourg type=update +INIConfiguration uses the platform's specific line separator instead +of the Windows line separator. + /action + action dev=ebourg type=fix issue=CONFIGURATION-267 +INIConfiguration flushes the output at the end of a save operation. + /action action dev=oheger type=update issue=CONFIGURATION-265 For hierarchical file-based configurations the auto-save mechanism is now also triggered if a subnode configuration is changed. In such a case - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r531435 - in /jakarta/commons/proper/configuration/trunk/src: java/org/apache/commons/configuration/INIConfiguration.java test/org/apache/commons/configuration/TestINIConfiguration.java
Author: ebourg Date: Mon Apr 23 04:18:22 2007 New Revision: 531435 URL: http://svn.apache.org/viewvc?view=revrev=531435 Log: INIConfiguration now supports values surrounded with single quotes Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java?view=diffrev=531435r1=531434r2=531435 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java Mon Apr 23 04:18:22 2007 @@ -157,7 +157,7 @@ * codegetSections/code method. * /p * - * @author trevor.miller + * @author Trevor Miller * @version $Id$ * @since 1.4 */ @@ -299,7 +299,7 @@ key = section + line; } } -this.addProperty(key.trim(), value); +addProperty(key.trim(), value); } } line = bufferedReader.readLine(); @@ -315,7 +315,9 @@ * Parse the value to remove the quotes and ignoring the comment. * Example: * - * codevalue ; comment - value/code + * prevalue ; comment - value/pre + * + * pre'value' ; comment - value/pre * * @param value */ @@ -323,10 +325,12 @@ { value = value.trim(); -boolean quoted = value.startsWith(\); +boolean quoted = value.startsWith(\) || value.startsWith('); boolean stop = false; boolean escape = false; +char quote = quoted ? value.charAt(0) : 0; + int i = quoted ? 1 : 0; StringBuffer result = new StringBuffer(); @@ -340,11 +344,11 @@ { escape = true; } -else if (!escape '' == c) +else if (!escape quote == c) { stop = true; } -else if (escape '' == c) +else if (escape quote == c) { escape = false; result.append(c); @@ -407,33 +411,33 @@ /** * Determine if the given line is a comment line. * - * @param s The line to check. + * @param line The line to check. * @return true if the line is empty or starts with one of the comment * characters */ -protected boolean isCommentLine(String s) +protected boolean isCommentLine(String line) { -if (s == null) +if (line == null) { return false; } // blank lines are also treated as comment lines -return s.length() 1 || COMMENT_CHARS.indexOf(s.charAt(0)) = 0; +return line.length() 1 || COMMENT_CHARS.indexOf(line.charAt(0)) = 0; } /** * Determine if the given line is a section. * - * @param s The line to check. + * @param line The line to check. * @return true if the line contains a secion */ -protected boolean isSectionLine(String s) +protected boolean isSectionLine(String line) { -if (s == null) +if (line == null) { return false; } -return s.startsWith([) s.endsWith(]); +return line.startsWith([) line.endsWith(]); } /** @@ -445,16 +449,18 @@ public Set getSections() { Set sections = new TreeSet(); -Iterator iter = this.getKeys(); -while (iter.hasNext()) + +Iterator keys = getKeys(); +while (keys.hasNext()) { -String key = (String) iter.next(); +String key = (String) keys.next(); int index = key.indexOf(.); if (index = 0) { sections.add(key.substring(0, index)); } } + return sections; } } Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java?view=diffrev=531435r1=531434r2=531435 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java (original) +++ jakarta/commons/proper
svn commit: r531294 - /jakarta/commons/proper/configuration/trunk/project.xml
Author: ebourg Date: Sun Apr 22 15:38:40 2007 New Revision: 531294 URL: http://svn.apache.org/viewvc?view=revrev=531294 Log: Applied the change suggested by Phil Steitz to fix the nightly build Modified: jakarta/commons/proper/configuration/trunk/project.xml Modified: jakarta/commons/proper/configuration/trunk/project.xml URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/project.xml?view=diffrev=531294r1=531293r2=531294 == --- jakarta/commons/proper/configuration/trunk/project.xml (original) +++ jakarta/commons/proper/configuration/trunk/project.xml Sun Apr 22 15:38:40 2007 @@ -503,6 +503,19 @@ /properties /dependency +dependency + groupIdmaven/groupId + artifactIdmaven-javadoc-plugin/artifactId + version1.8/version + urlhttp://maven.apache.org/maven-1.x/plugins/javadoc//url + typeplugin/type + properties + comment + lt;stronggt;Site Onlylt;/stronggt; - v1.8 (minimum) + /comment + /properties +/dependency + /dependencies build - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r530508 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/ src/java/org/apache/commons/configuration/plist/ src/test/org/apache/commons/configurat
Author: ebourg Date: Thu Apr 19 11:29:47 2007 New Revision: 530508 URL: http://svn.apache.org/viewvc?view=revrev=530508 Log: Fixed the storage of byte[] properties in the plist configurations Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.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 jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java?view=diffrev=530508r1=530507r2=530508 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java Thu Apr 19 11:29:47 2007 @@ -552,6 +552,7 @@ { fireEvent(EVENT_SET_PROPERTY, key, value, true); +// Update the existing nodes for this property Iterator itNodes = fetchNodeList(key).iterator(); Iterator itValues; if (!isDelimiterParsingDisabled()) @@ -562,6 +563,7 @@ { itValues = new SingletonIterator(value); } + while (itNodes.hasNext() itValues.hasNext()) { ((ConfigurationNode) itNodes.next()).setValue(itValues.next()); Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java?view=diffrev=530508r1=530507r2=530508 == --- 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 Thu Apr 19 11:29:47 2007 @@ -141,6 +141,20 @@ super(url); } +public void setProperty(String key, Object value) +{ +// special case for byte arrays, they must be stored as is in the configuration +if (value instanceof byte[]) +{ +clearProperty(key); +addPropertyDirect(key, value); +} +else +{ +super.setProperty(key, value); +} +} + public void load(Reader in) throws ConfigurationException { PropertyListParser parser = new PropertyListParser(in); Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java?view=diffrev=530508r1=530507r2=530508 == --- 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 Thu Apr 19 11:29:47 2007 @@ -181,6 +181,20 @@ super(url); } +public void setProperty(String key, Object value) +{ +// special case for byte arrays, they must be stored as is in the configuration +if (value instanceof byte[]) +{ +clearProperty(key); +addPropertyDirect(key, value); +} +else +{ +super.setProperty(key, value); +} +} + public void load(Reader in) throws ConfigurationException { // set up the DTD validation Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java?view=diffrev=530508r1=530507r2=530508
svn commit: r530583 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/ src/test/org/apache/commons/configuration/ xdocs/
Author: ebourg Date: Thu Apr 19 15:48:29 2007 New Revision: 530583 URL: http://svn.apache.org/viewvc?view=revrev=530583 Log: DataConfiguration now supports the Java 5 enumeration types Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertyConverter.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java?view=diffrev=530583r1=530582r2=530583 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java Thu Apr 19 15:48:29 2007 @@ -46,6 +46,7 @@ * li[EMAIL PROTECTED] java.awt.Color}/li * li[EMAIL PROTECTED] java.net.InetAddress}/li * li[EMAIL PROTECTED] javax.mail.internet.InternetAddress} (requires Javamail in the classpath)/li + * li[EMAIL PROTECTED] java.lang.Enum} (Java 5 enumeration types)/li * /ul * * Lists and arrays are available for all types. Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java?view=diffrev=530583r1=530582r2=530583 == --- 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 Thu Apr 19 15:48:29 2007 @@ -18,8 +18,10 @@ package org.apache.commons.configuration; import java.awt.Color; +import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.math.BigDecimal; import java.math.BigInteger; import java.net.InetAddress; @@ -41,6 +43,7 @@ import org.apache.commons.collections.iterators.SingletonIterator; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.SystemUtils; /** * A utility class to convert the configuration properties into any type. @@ -90,70 +93,74 @@ { if (Boolean.class.equals(cls) || Boolean.TYPE.equals(cls)) { -return PropertyConverter.toBoolean(value); +return toBoolean(value); } else if (Number.class.isAssignableFrom(cls) || cls.isPrimitive()) { if (Integer.class.equals(cls) || Integer.TYPE.equals(cls)) { -return PropertyConverter.toInteger(value); +return toInteger(value); } else if (Long.class.equals(cls) || Long.TYPE.equals(cls)) { -return PropertyConverter.toLong(value); +return toLong(value); } else if (Byte.class.equals(cls) || Byte.TYPE.equals(cls)) { -return PropertyConverter.toByte(value); +return toByte(value); } else if (Short.class.equals(cls) || Short.TYPE.equals(cls)) { -return PropertyConverter.toShort(value); +return toShort(value); } else if (Float.class.equals(cls) || Float.TYPE.equals(cls)) { -return PropertyConverter.toFloat(value); +return toFloat(value); } else if (Double.class.equals(cls) || Double.TYPE.equals(cls)) { -return PropertyConverter.toDouble(value); +return toDouble(value); } else if (BigInteger.class.equals(cls)) { -return PropertyConverter.toBigInteger(value); +return toBigInteger(value); } else if (BigDecimal.class.equals(cls)) { -return PropertyConverter.toBigDecimal(value); +return toBigDecimal(value); } } else if (Date.class.equals(cls)) { -return PropertyConverter.toDate(value, (String) params[0]); +return toDate(value, (String) params[0]); } else
svn commit: r530587 - in /jakarta/commons/proper/configuration/trunk/src: java/org/apache/commons/configuration/plist/ test/org/apache/commons/configuration/plist/
Author: ebourg Date: Thu Apr 19 16:08:36 2007 New Revision: 530587 URL: http://svn.apache.org/viewvc?view=revrev=530587 Log: Fixed the storage of byte[] properties in the plist configurations (addProperty() case) Modified: 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 jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java?view=diffrev=530587r1=530586r2=530587 == --- 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 Thu Apr 19 16:08:36 2007 @@ -155,6 +155,20 @@ } } +public void addProperty(String key, Object value) +{ +if (value instanceof byte[]) +{ +fireEvent(EVENT_ADD_PROPERTY, key, value, true); +addPropertyDirect(key, value); +fireEvent(EVENT_ADD_PROPERTY, key, value, false); +} +else +{ +super.setProperty(key, value); +} +} + public void load(Reader in) throws ConfigurationException { PropertyListParser parser = new PropertyListParser(in); Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java?view=diffrev=530587r1=530586r2=530587 == --- 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 Thu Apr 19 16:08:36 2007 @@ -195,6 +195,20 @@ } } +public void addProperty(String key, Object value) +{ +if (value instanceof byte[]) +{ +fireEvent(EVENT_ADD_PROPERTY, key, value, true); +addPropertyDirect(key, value); +fireEvent(EVENT_ADD_PROPERTY, key, value, false); +} +else +{ +super.setProperty(key, value); +} +} + public void load(Reader in) throws ConfigurationException { // set up the DTD validation Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java?view=diffrev=530587r1=530586r2=530587 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java Thu Apr 19 16:08:36 2007 @@ -274,6 +274,24 @@ ArrayAssert.assertEquals(expected, (byte[]) array); } +/** + * Ensure that addProperty doesn't alter an array of byte + */ +public void testAddDataProperty() throws Exception +{ +byte[] expected = new byte[]{1, 2, 3, 4}; +PropertyListConfiguration config = new PropertyListConfiguration(); +config.addProperty(foo, expected); +config.save(target/testdata.plist); + +PropertyListConfiguration config2 = new PropertyListConfiguration(target/testdata.plist); +Object array = config2.getProperty(foo); + +assertNotNull(data not found, array); +assertEquals(property type, byte[].class, array.getClass()); +ArrayAssert.assertEquals(expected, (byte[]) array); +} + public void testInitCopy() { PropertyListConfiguration copy = new PropertyListConfiguration(config); Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist
svn commit: r530591 - /jakarta/commons/proper/configuration/trunk/doap_configuration.rdf
Author: ebourg Date: Thu Apr 19 16:56:31 2007 New Revision: 530591 URL: http://svn.apache.org/viewvc?view=revrev=530591 Log: Fixed/updated the release info in the doap file Modified: jakarta/commons/proper/configuration/trunk/doap_configuration.rdf Modified: jakarta/commons/proper/configuration/trunk/doap_configuration.rdf URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/doap_configuration.rdf?view=diffrev=530591r1=530590r2=530591 == --- jakarta/commons/proper/configuration/trunk/doap_configuration.rdf (original) +++ jakarta/commons/proper/configuration/trunk/doap_configuration.rdf Thu Apr 19 16:56:31 2007 @@ -10,23 +10,54 @@ download-page rdf:resource=http://jakarta.apache.org/site/downloads/downloads_commons-configuration.cgi/ asfext:pmc rdf:resource=http://jakarta.apache.org// shortdesc xml:lang=enCommon Configuration/shortdesc + description xml:lang=en -Tools to assist in the reading of configuration/preferences files in -various formats - /description + Library to use configuration/preferences of various sources and formats. +/description + repository SVNRepository browse rdf:resource=http://svn.apache.org/repos/asf/jakarta/commons/proper/configuration/trunk/ location rdf:resource=http://svn.apache.org/repos/asf/jakarta/commons/proper/configuration/ /SVNRepository /repository + release - revision -namecommons-configuration/name + Version +nameCommons Configuration 1.2/name +created2004-10-12/created +revision1.2/revision + /Version +/release +release + Version +nameCommons Configuration 1.1/name +created2005-04-04/created +revision1.1/revision + /Version +/release +release + Version +nameCommons Configuration 1.2/name created2005-12-17/created -version1.2/version - /revision +revision1.2/revision + /Version +/release +release + Version +nameCommons Configuration 1.3/name +created2006-09-24/created +revision1.3/revision + /Version +/release +release + Version +nameCommons Configuration 1.4/name +created2007-04-08/created +revision1.4/revision + /Version /release + mailing-list rdf:resource=http://jakarta.apache.org/site/mail2.html#Commons/ /Project /rdf:RDF - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r529919 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/ src/test/org/apache/commons/configuration/ xdocs/
Author: ebourg Date: Wed Apr 18 01:45:48 2007 New Revision: 529919 URL: http://svn.apache.org/viewvc?view=revrev=529919 Log: DataConfiguration now supports the InetAddress type Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java?view=diffrev=529919r1=529918r2=529919 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java Wed Apr 18 01:45:48 2007 @@ -37,8 +37,8 @@ /** * Decorator providing additional getters for any Configuration. This extended - * Configuration supports more types: URL, Locale, Date, Calendar, Color, as - * well as lists and arrays for all types. + * Configuration supports more types: URL, Locale, Date, Calendar, Color, + * InetAddress, as well as lists and arrays for all types. * * h4Example/h4 * @@ -46,6 +46,7 @@ * pre * title.color = #FF * default.locales = fr,en,de + * remote.host = 192.168.0.53 * /pre * * Usage: @@ -58,6 +59,7 @@ * * // retrieve a property using a generic getter * Locale[] locales = (Locale[]) config.getArray(Locale.class, default.locales); + * InetAddress host = (InetAddress) config.get(InetAddress.class, remote.host); * /pre * * h4Dates/h4 Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java?view=diffrev=529919r1=529918r2=529919 == --- 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 Wed Apr 18 01:45:48 2007 @@ -20,10 +20,13 @@ import java.awt.Color; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.math.BigDecimal; import java.math.BigInteger; import java.net.MalformedURLException; import java.net.URL; +import java.net.InetAddress; +import java.net.UnknownHostException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -39,6 +42,7 @@ import org.apache.commons.collections.iterators.SingletonIterator; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.SystemUtils; /** * A utility class to convert the configuration properties into any type. @@ -145,6 +149,10 @@ { return PropertyConverter.toColor(value); } +else if (InetAddress.class.isAssignableFrom(cls)) +{ +return PropertyConverter.toInetAddress(value); +} throw new ConversionException(The value ' + value + ' ( + value.getClass() + ) can't be converted to a + cls.getName() + object); } @@ -608,6 +616,38 @@ else { throw new ConversionException(The value + value + can't be converted to a Color); +} +} + +/** + * Convert the specified value into an internet address. + * + * @param value the value to convert + * @return the converted value + * @throws ConversionException thrown if the value cannot be converted to a InetAddress + * + * @since 1.5 + */ +static InetAddress toInetAddress(Object value) throws ConversionException +{ +if (value instanceof InetAddress) +{ +return (InetAddress) value; +} +else if (value instanceof String) +{ +try +{ +return InetAddress.getByName((String) value); +} +catch (UnknownHostException e) +{ +throw new ConversionException(The value + value + can't be converted to a InetAddress, e); +} +} +else +{ +throw new ConversionException(The value + value + can't be converted to a InetAddress); } } Modified
svn commit: r529948 - in /jakarta/commons/proper/configuration/trunk: ./ src/java/org/apache/commons/configuration/ src/test/org/apache/commons/configuration/ xdocs/
Author: ebourg Date: Wed Apr 18 03:09:35 2007 New Revision: 529948 URL: http://svn.apache.org/viewvc?view=revrev=529948 Log: DataConfiguration now supports the javax.mail.internet.InternetAddress type for email adresses Modified: jakarta/commons/proper/configuration/trunk/project.xml jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/project.xml URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/project.xml?view=diffrev=529948r1=529947r2=529948 == --- jakarta/commons/proper/configuration/trunk/project.xml (original) +++ jakarta/commons/proper/configuration/trunk/project.xml Wed Apr 18 03:09:35 2007 @@ -333,6 +333,16 @@ /properties /dependency +dependency + groupIdjavax.mail/groupId + artifactIdmail/artifactId + version1.4/version + urlhttp://java.sun.com/products/javamail//url + properties +optionaltrue/optional + /properties +/dependency + !-- Needed for testing -- dependency Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java?view=diffrev=529948r1=529947r2=529948 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java Wed Apr 18 03:09:35 2007 @@ -37,16 +37,27 @@ /** * Decorator providing additional getters for any Configuration. This extended - * Configuration supports more types: URL, Locale, Date, Calendar, Color, - * InetAddress, as well as lists and arrays for all types. + * Configuration supports more types: + * ul + * li[EMAIL PROTECTED] java.net.URL}/li + * li[EMAIL PROTECTED] java.util.Locale}/li + * li[EMAIL PROTECTED] java.util.Date}/li + * li[EMAIL PROTECTED] java.util.Calendar}/li + * li[EMAIL PROTECTED] java.awt.Color}/li + * li[EMAIL PROTECTED] java.net.InetAddress}/li + * li[EMAIL PROTECTED] javax.mail.internet.InternetAddress} (requires Javamail in the classpath)/li + * /ul + * + * Lists and arrays are available for all types. * * h4Example/h4 * * Configuration file ttconfig.properties/tt: * pre * title.color = #FF - * default.locales = fr,en,de * remote.host = 192.168.0.53 + * default.locales = fr,en,de + * email.contact = [EMAIL PROTECTED], [EMAIL PROTECTED] * /pre * * Usage: @@ -58,8 +69,9 @@ * Color color = config.getColor(title.color); * * // retrieve a property using a generic getter - * Locale[] locales = (Locale[]) config.getArray(Locale.class, default.locales); * InetAddress host = (InetAddress) config.get(InetAddress.class, remote.host); + * Locale[] locales = (Locale[]) config.getArray(Locale.class, default.locales); + * List contacts = config.getList(InternetAddress.class, email.contact); * /pre * * h4Dates/h4 Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java?view=diffrev=529948r1=529947r2=529948 == --- 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 Wed Apr 18 03:09:35 2007 @@ -20,12 +20,11 @@ import java.awt.Color; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.math.BigDecimal; import java.math.BigInteger; +import java.net.InetAddress; import java.net.MalformedURLException; import java.net.URL; -import java.net.InetAddress; import java.net.UnknownHostException; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -42,7 +41,6 @@ import org.apache.commons.collections.iterators.SingletonIterator; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.SystemUtils; /** * A utility class to convert the configuration
svn commit: r529984 - /jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java
Author: ebourg Date: Wed Apr 18 04:22:53 2007 New Revision: 529984 URL: http://svn.apache.org/viewvc?view=revrev=529984 Log: Fixed the test case for DataConfiguration Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java?view=diffrev=529984r1=529983r2=529984 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java Wed Apr 18 04:22:53 2007 @@ -1678,7 +1678,7 @@ // interpolated value assertEquals(expected, conf.get(InetAddress.class, ip.string.interpolated)); -conf.setProperty(ip.unknownhost, 123); +conf.setProperty(ip.unknownhost, foo); try { conf.get(InetAddress.class, ip.unknownhost); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r530205 - /jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java
Author: ebourg Date: Wed Apr 18 16:46:34 2007 New Revision: 530205 URL: http://svn.apache.org/viewvc?view=revrev=530205 Log: Changed TestDataConfiguration to make it compile and run on Java 1.3 Conversion to InternetAddress is no longer tested on Java 1.3 Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java?view=diffrev=530205r1=530204r2=530205 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java Wed Apr 18 16:46:34 2007 @@ -31,7 +31,8 @@ import java.util.List; import java.util.Locale; import java.util.NoSuchElementException; -import javax.mail.internet.InternetAddress; + +import org.apache.commons.lang.SystemUtils; import junit.framework.TestCase; import junitx.framework.ArrayAssert; @@ -297,10 +298,10 @@ conf.addProperty(ip.string.interpolated, ${ip.string}); conf.addProperty(ip.object, InetAddress.getByName(127.0.0.1)); -// email address +// email address (tested on Java 1.4+) conf.addProperty(email.string, [EMAIL PROTECTED]); conf.addProperty(email.string.interpolated, ${email.string}); -conf.addProperty(email.object, new InternetAddress([EMAIL PROTECTED])); +conf.addProperty(email.object, [EMAIL PROTECTED]); } public void testGetConfiguration() @@ -1692,21 +1693,27 @@ public void testGetInternetAddress() throws Exception { -InternetAddress expected = new InternetAddress([EMAIL PROTECTED]); +if (!SystemUtils.isJavaVersionAtLeast(1.4f)) +{ +// skip the test on Java 1.3 +return; +} + +Object expected = createInternetAddress([EMAIL PROTECTED]); // address as string -assertEquals(expected, conf.get(InternetAddress.class, email.string)); +assertEquals(expected, conf.get(expected.getClass(), email.string)); // address object -assertEquals(expected, conf.get(InternetAddress.class, email.object)); +assertEquals(expected, conf.get(expected.getClass(), email.object)); // interpolated value -assertEquals(expected, conf.get(InternetAddress.class, email.string.interpolated)); +assertEquals(expected, conf.get(expected.getClass(), email.string.interpolated)); conf.setProperty(email.invalid, [EMAIL PROTECTED]@org); try { -conf.get(InternetAddress.class, email.invalid); +conf.get(expected.getClass(), email.invalid); fail(ConversionException should be thrown for invalid emails); } catch (ConversionException e) @@ -1715,7 +1722,18 @@ } } -public void testConversionException() +/** + * Create an instance of InternetAddress. This trick is necessary to + * compile and run the test with Java 1.3 and the javamail-1.4 which + * is not compatible with Java 1.3 + */ +private Object createInternetAddress(String email) throws Exception +{ +Class cls = Class.forName(javax.mail.internet.InternetAddress); +return cls.getConstructor(new Class[]{String.class}).newInstance(new Object[]{email}); +} + +public void testConversionException() throws Exception { conf.addProperty(key1, new Object()); conf.addProperty(key2, xx); @@ -2330,14 +2348,18 @@ // expected } -try -{ -conf.get(InternetAddress.class, key1); -fail(getInternetAddress didn't throw a ConversionException); -} -catch (ConversionException e) +if (SystemUtils.isJavaVersionAtLeast(1.4f)) { -// expected +// skip the test on Java 1.3 +try +{ +conf.get(Class.forName(javax.mail.internet.InternetAddress), key1); +fail(getInternetAddress didn't throw a ConversionException); +} +catch (ConversionException e) +{ +// expected +} } } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r530207 - /jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java
Author: ebourg Date: Wed Apr 18 16:53:50 2007 New Revision: 530207 URL: http://svn.apache.org/viewvc?view=revrev=530207 Log: Follow up on TestDataConfiguration fix Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java?view=diffrev=530207r1=530206r2=530207 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java Wed Apr 18 16:53:50 2007 @@ -299,9 +299,12 @@ conf.addProperty(ip.object, InetAddress.getByName(127.0.0.1)); // email address (tested on Java 1.4+) -conf.addProperty(email.string, [EMAIL PROTECTED]); -conf.addProperty(email.string.interpolated, ${email.string}); -conf.addProperty(email.object, [EMAIL PROTECTED]); +if (SystemUtils.isJavaVersionAtLeast(1.4f)) +{ +conf.addProperty(email.string, [EMAIL PROTECTED]); +conf.addProperty(email.string.interpolated, ${email.string}); +conf.addProperty(email.object, createInternetAddress([EMAIL PROTECTED])); +} } public void testGetConfiguration() - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r529523 - in /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration: AbstractConfiguration.java DatabaseConfiguration.java
Author: ebourg Date: Tue Apr 17 01:31:58 2007 New Revision: 529523 URL: http://svn.apache.org/viewvc?view=revrev=529523 Log: Simplification of the method resolveContainerStore() in AbstractConfiguration Deprecated getConnection() in DatabaseConfiguration Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java?view=diffrev=529523r1=529522r2=529523 == --- 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 Tue Apr 17 01:31:58 2007 @@ -17,6 +17,7 @@ package org.apache.commons.configuration; +import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; @@ -624,6 +625,8 @@ return props; } + + /** * [EMAIL PROTECTED] * @see PropertyConverter#toBoolean(Object) @@ -1227,45 +1230,9 @@ List list = (List) value; value = list.isEmpty() ? null : list.get(0); } -else if (value instanceof Object[]) -{ -Object[] array = (Object[]) value; -value = array.length == 0 ? null : array[0]; -} -else if (value instanceof boolean[]) -{ -boolean[] array = (boolean[]) value; -value = array.length == 0 ? null : array[0] ? Boolean.TRUE : Boolean.FALSE; -} -else if (value instanceof byte[]) -{ -byte[] array = (byte[]) value; -value = array.length == 0 ? null : new Byte(array[0]); -} -else if (value instanceof short[]) -{ -short[] array = (short[]) value; -value = array.length == 0 ? null : new Short(array[0]); -} -else if (value instanceof int[]) -{ -int[] array = (int[]) value; -value = array.length == 0 ? null : new Integer(array[0]); -} -else if (value instanceof long[]) -{ -long[] array = (long[]) value; -value = array.length == 0 ? null : new Long(array[0]); -} -else if (value instanceof float[]) -{ -float[] array = (float[]) value; -value = array.length == 0 ? null : new Float(array[0]); -} -else if (value instanceof double[]) +else if (value.getClass().isArray() Array.getLength(value) 0) { -double[] array = (double[]) value; -value = array.length == 0 ? null : new Double(array[0]); +value = Array.get(value, 0); } } Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java?view=diffrev=529523r1=529522r2=529523 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java Tue Apr 17 01:31:58 2007 @@ -560,8 +560,9 @@ * @return the codeConnection/code object to be used * @throws SQLException if an error occurs * @since 1.4 + * @deprecated Use a custom datasource to change the connection used by the class. To be removed in Commons Configuration 2.0 */ -Connection getConnection() throws SQLException +protected Connection getConnection() throws SQLException { return getDatasource().getConnection(); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r529531 - in /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration: AbstractConfiguration.java BaseConfiguration.java CompositeConfiguration.java SubsetConf
Author: ebourg Date: Tue Apr 17 01:52:41 2007 New Revision: 529531 URL: http://svn.apache.org/viewvc?view=revrev=529531 Log: Removed the useless @inheritDoc tags (when no info is added to the javadoc of the super class) Removed the abstract methods in AbstractConfiguration declared in the Configuration interface and implemented in a subclass Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/SubsetConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java?view=diffrev=529531r1=529530r2=529531 == --- 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 Tue Apr 17 01:52:41 2007 @@ -376,9 +376,6 @@ }); } -/** - * [EMAIL PROTECTED] - */ public void addProperty(String key, Object value) { fireEvent(EVENT_ADD_PROPERTY, key, value, true); @@ -454,27 +451,11 @@ return base; // just a dummy implementation } -/** - * [EMAIL PROTECTED] - */ public Configuration subset(String prefix) { return new SubsetConfiguration(this, prefix, .); } -/** - * [EMAIL PROTECTED] - */ -public abstract boolean isEmpty(); - -/** - * [EMAIL PROTECTED] - */ -public abstract boolean containsKey(String key); - -/** - * [EMAIL PROTECTED] - */ public void setProperty(String key, Object value) { fireEvent(EVENT_SET_PROPERTY, key, value, true); @@ -518,9 +499,6 @@ // override in sub classes } -/** - * [EMAIL PROTECTED] - */ public void clear() { fireEvent(EVENT_CLEAR, null, null, true); @@ -547,14 +525,6 @@ fireEvent(EVENT_CLEAR, null, null, false); } -/** - * [EMAIL PROTECTED] - */ -public abstract Iterator getKeys(); - -/** - * [EMAIL PROTECTED] - */ public Iterator getKeys(final String prefix) { return new FilterIterator(getKeys(), new Predicate() @@ -567,9 +537,6 @@ }); } -/** - * [EMAIL PROTECTED] - */ public Properties getProperties(String key) { return getProperties(key, null); @@ -625,8 +592,6 @@ return props; } - - /** * [EMAIL PROTECTED] * @see PropertyConverter#toBoolean(Object) @@ -686,9 +651,6 @@ } } -/** - * [EMAIL PROTECTED] - */ public byte getByte(String key) { Byte b = getByte(key, null); @@ -702,17 +664,11 @@ } } -/** - * [EMAIL PROTECTED] - */ public byte getByte(String key, byte defaultValue) { return getByte(key, new Byte(defaultValue)).byteValue(); } -/** - * [EMAIL PROTECTED] - */ public Byte getByte(String key, Byte defaultValue) { Object value = resolveContainerStore(key); @@ -734,9 +690,6 @@ } } -/** - * [EMAIL PROTECTED] - */ public double getDouble(String key) { Double d = getDouble(key, null); @@ -750,17 +703,11 @@ } } -/** - * [EMAIL PROTECTED] - */ public double getDouble(String key, double defaultValue) { return getDouble(key, new Double(defaultValue)).doubleValue(); } -/** - * [EMAIL PROTECTED] - */ public Double getDouble(String key, Double defaultValue) { Object value = resolveContainerStore(key); @@ -782,9 +729,6 @@ } } -/** - * [EMAIL PROTECTED] - */ public float getFloat(String key) { Float f = getFloat(key, null); @@ -798,17 +742,11 @@ } } -/** - * [EMAIL PROTECTED] - */ public float getFloat(String key, float defaultValue) { return getFloat(key, new Float(defaultValue)).floatValue(); } -/** - * [EMAIL PROTECTED] - */ public Float getFloat(String key, Float defaultValue) { Object value = resolveContainerStore(key); @@ -830,9 +768,6 @@ } } -/** - * [EMAIL PROTECTED] - */ public int getInt(String key) { Integer i = getInteger(key, null
svn commit: r529550 - in /jakarta/commons/proper/configuration/trunk/src: java/org/apache/commons/configuration/DataConfiguration.java test/org/apache/commons/configuration/TestDataConfiguration.java
Author: ebourg Date: Tue Apr 17 03:42:41 2007 New Revision: 529550 URL: http://svn.apache.org/viewvc?view=revrev=529550 Log: Improved the test coverage for DataConfiguration by storing directly the arrays in the configuration Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java?view=diffrev=529550r1=529549r2=529550 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java Tue Apr 17 03:42:41 2007 @@ -91,7 +91,14 @@ protected void addPropertyDirect(String key, Object obj) { -configuration.addProperty(key, obj); +if (configuration instanceof AbstractConfiguration) +{ +((AbstractConfiguration) configuration).addPropertyDirect(key, obj); +} +else +{ +configuration.addProperty(key, obj); +} } public boolean isEmpty() Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java?view=diffrev=529550r1=529549r2=529550 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java Tue Apr 17 03:42:41 2007 @@ -54,8 +54,8 @@ conf.addProperty(boolean.list2, true, false); conf.addProperty(boolean.list3, Boolean.TRUE); conf.addProperty(boolean.list3, Boolean.FALSE); -conf.addProperty(boolean.list4, new Boolean[] { Boolean.TRUE, Boolean.FALSE }); -conf.addProperty(boolean.list5, new boolean[] { true, false }); +conf.addPropertyDirect(boolean.list4, new Boolean[] { Boolean.TRUE, Boolean.FALSE }); +conf.addPropertyDirect(boolean.list5, new boolean[] { true, false }); List booleans = new ArrayList(); booleans.add(Boolean.TRUE); booleans.add(Boolean.FALSE); @@ -70,8 +70,8 @@ conf.addProperty(byte.list2, 1, 2); conf.addProperty(byte.list3, new Byte(1)); conf.addProperty(byte.list3, new Byte(2)); -conf.addProperty(byte.list4, new Byte[] { new Byte(1), new Byte(2) }); -conf.addProperty(byte.list5, new byte[] { 1, 2 }); +conf.addPropertyDirect(byte.list4, new Byte[] { new Byte(1), new Byte(2) }); +conf.addPropertyDirect(byte.list5, new byte[] { 1, 2 }); List bytes = new ArrayList(); bytes.add(new Byte(1)); bytes.add(new Byte(2)); @@ -86,8 +86,8 @@ conf.addProperty(short.list2, 1, 2); conf.addProperty(short.list3, new Short(1)); conf.addProperty(short.list3, new Short(2)); -conf.addProperty(short.list4, new Short[] { new Short(1), new Short(2) }); -conf.addProperty(short.list5, new short[] { 1, 2 }); +conf.addPropertyDirect(short.list4, new Short[] { new Short(1), new Short(2) }); +conf.addPropertyDirect(short.list5, new short[] { 1, 2 }); List shorts = new ArrayList(); shorts.add(new Short(1)); shorts.add(new Short(2)); @@ -102,8 +102,8 @@ conf.addProperty(integer.list2, 1, 2); conf.addProperty(integer.list3, new Integer(1)); conf.addProperty(integer.list3, new Integer(2)); -conf.addProperty(integer.list4, new Integer[] { new Integer(1), new Integer(2) }); -conf.addProperty(integer.list5, new int[] { 1, 2 }); +conf.addPropertyDirect(integer.list4, new Integer[] { new Integer(1), new Integer(2) }); +conf.addPropertyDirect(integer.list5, new int[] { 1, 2 }); List integers = new ArrayList(); integers.add(new Integer(1)); integers.add(new Integer(2)); @@ -118,8 +118,8 @@ conf.addProperty(long.list2, 1, 2); conf.addProperty(long.list3, new Long(1)); conf.addProperty(long.list3, new Long(2)); -conf.addProperty(long.list4, new Long[] { new Long(1), new Long(2) }); -conf.addProperty(long.list5, new long[] { 1, 2 }); +conf.addPropertyDirect(long.list4, new Long[] { new Long(1
svn commit: r529564 - in /jakarta/commons/proper/configuration/trunk/src: java/org/apache/commons/configuration/AbstractConfiguration.java test/org/apache/commons/configuration/TestBaseConfiguration.j
Author: ebourg Date: Tue Apr 17 04:09:43 2007 New Revision: 529564 URL: http://svn.apache.org/viewvc?view=revrev=529564 Log: Changed resolveContainerStore() in AbstractConfiguration to return the first element of a collection Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java?view=diffrev=529564r1=529563r2=529564 == --- 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 Tue Apr 17 04:09:43 2007 @@ -21,6 +21,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; @@ -1112,21 +1113,21 @@ /** * Returns an object from the store described by the key. If the value is a - * List object, replace it with the first object in the list. + * Collection object, replace it with the first object in the collection. * * @param key The property key. * - * @return value Value, transparently resolving a possible List dependency. + * @return value Value, transparently resolving a possible collection dependency. */ protected Object resolveContainerStore(String key) { Object value = getProperty(key); if (value != null) { -if (value instanceof List) +if (value instanceof Collection) { -List list = (List) value; -value = list.isEmpty() ? null : list.get(0); +Collection collection = (Collection) value; +value = collection.isEmpty() ? null : collection.iterator().next(); } else if (value.getClass().isArray() Array.getLength(value) 0) { Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java?view=diffrev=529564r1=529563r2=529564 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java Tue Apr 17 04:09:43 2007 @@ -26,8 +26,10 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.Properties; +import java.util.Set; import java.util.StringTokenizer; +import org.apache.commons.collections.set.ListOrderedSet; import org.apache.commons.configuration.event.ConfigurationEvent; import org.apache.commons.configuration.event.ConfigurationListener; import org.apache.commons.configuration.interpol.ConfigurationInterpolator; @@ -781,6 +783,14 @@ config.addPropertyDirect(list, list); assertEquals(first element of the 'list' property, foo, config.resolveContainerStore(list)); + +// set of objects +Set set = new ListOrderedSet(); +set.add(foo); +set.add(bar); +config.addPropertyDirect(set, set); + +assertEquals(first element of the 'set' property, foo, config.resolveContainerStore(set)); // arrays of primitives config.addPropertyDirect(array.boolean, new boolean[] { true, false }); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r529598 - /jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java
Author: ebourg Date: Tue Apr 17 06:43:38 2007 New Revision: 529598 URL: http://svn.apache.org/viewvc?view=revrev=529598 Log: More test coverage for DataConfiguration Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java?view=diffrev=529598r1=529597r2=529598 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java Tue Apr 17 06:43:38 2007 @@ -17,7 +17,7 @@ package org.apache.commons.configuration; -import java.awt.*; +import java.awt.Color; import java.math.BigDecimal; import java.math.BigInteger; import java.net.URL; @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -285,6 +286,51 @@ calendars.add(date2); conf.addProperty(calendar.list6, calendars); conf.addProperty(calendar.list.interpolated, ${calendar.string},2004-12-31); +} + +public void testGetConfiguration() +{ +Configuration baseconf = new BaseConfiguration(); +DataConfiguration conf = new DataConfiguration(baseconf); + +assertEquals(base configuration, baseconf, conf.getConfiguration()); +} + +public void testIsEmpty() +{ +Configuration baseconf = new BaseConfiguration(); +DataConfiguration conf = new DataConfiguration(baseconf); + +assertTrue(not empty, conf.isEmpty()); + +baseconf.setProperty(foo, bar); + +assertFalse(empty, conf.isEmpty()); +} + +public void testContainsKey() +{ +Configuration baseconf = new BaseConfiguration(); +DataConfiguration conf = new DataConfiguration(baseconf); + +assertFalse(conf.containsKey(foo)); + +baseconf.setProperty(foo, bar); + +assertTrue(conf.containsKey(foo)); +} + +public void testGetKeys() +{ +Configuration baseconf = new BaseConfiguration(); +DataConfiguration conf = new DataConfiguration(baseconf); + +baseconf.setProperty(foo, bar); + +Iterator it = conf.getKeys(); +assertTrue(the iterator is empty, it.hasNext()); +assertEquals(unique key, foo, it.next()); +assertFalse(the iterator is not exhausted, it.hasNext()); } public void testGetBooleanArray() - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r529194 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/ src/java/org/apache/commons/configuration/plist/ src/test/org/apache/commons/configurat
Author: ebourg Date: Mon Apr 16 03:40:42 2007 New Revision: 529194 URL: http://svn.apache.org/viewvc?view=revrev=529194 Log: AbstractFileConfiguration now supports saving to non file URLs (CONFIGURATION-249) Fixed a typo on the overview page Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/FileConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestFileConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml jakarta/commons/proper/configuration/trunk/xdocs/overview.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java?view=diffrev=529194r1=529193r2=529194 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java Mon Apr 16 03:40:42 2007 @@ -27,8 +27,10 @@ import java.io.Reader; import java.io.UnsupportedEncodingException; import java.io.Writer; +import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; +import java.net.URLConnection; import java.util.Iterator; import org.apache.commons.configuration.reloading.InvariantReloadingStrategy; @@ -409,7 +411,7 @@ } /** - * Save the configuration to the specified URL if it's a file URL. + * Save the configuration to the specified URL. * This doesn't change the source of the configuration, use setURL() * if you need it. * @@ -419,6 +421,8 @@ */ public void save(URL url) throws ConfigurationException { +// file URLs have to be converted to Files since FileURLConnection is +// read only (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4191800) File file = ConfigurationUtils.fileFromURL(url); if (file != null) { @@ -426,7 +430,35 @@ } else { -throw new ConfigurationException(Could not save to URL + url); +// for non file URLs save through an URLConnection +try +{ +URLConnection connection = url.openConnection(); +connection.setDoOutput(true); + +// use the PUT method for http URLs +if (connection instanceof HttpURLConnection) +{ +HttpURLConnection conn = (HttpURLConnection) connection; +conn.setRequestMethod(PUT); +} + +save(connection.getOutputStream()); + +// check the response code for http URLs and throw an exception if an error occured +if (connection instanceof HttpURLConnection) +{ +HttpURLConnection conn = (HttpURLConnection) connection; +if (conn.getResponseCode() = HttpURLConnection.HTTP_BAD_REQUEST) +{ +throw new IOException(HTTP Error + conn.getResponseCode() + + conn.getResponseMessage()); +} +} +} +catch (IOException e) +{ +throw new ConfigurationException(Could not save to URL + url + : + e.getMessage()); +} } } @@ -647,8 +679,7 @@ { try { -path = ConfigurationUtils.getURL(getBasePath(), -getFileName()).getPath(); +path = ConfigurationUtils.getURL(getBasePath(), getFileName()).getPath(); } catch (MalformedURLException e) { @@ -877,8 +908,7 @@ * @param propValue the value of the property * @param before the before update flag */ -protected void fireEvent(int type, String propName, Object propValue, -boolean before) +protected void fireEvent(int type, String propName, Object propValue, boolean before) { enterNoReload(); try @@ -959,8 +989,7 @@ */ public Object clone() { -AbstractFileConfiguration copy = (AbstractFileConfiguration) super -.clone(); +AbstractFileConfiguration copy = (AbstractFileConfiguration) super.clone(); copy.setBasePath(null); copy.setFileName
svn commit: r529210 - in /jakarta/commons/proper/configuration/trunk/src: java/org/apache/commons/configuration/DatabaseConfiguration.java test/org/apache/commons/configuration/TestDatabaseConfigurati
Author: ebourg Date: Mon Apr 16 04:54:11 2007 New Revision: 529210 URL: http://svn.apache.org/viewvc?view=revrev=529210 Log: Improved the javadoc for DatabaseConfiguration Made getConnection() package private since it's only used for testing Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java?view=diffrev=529210r1=529209r2=529210 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java Mon Apr 16 04:54:11 2007 @@ -33,11 +33,51 @@ import org.apache.commons.logging.LogFactory; /** - * Configuration stored in a database. + * Configuration stored in a database. The properties are retrieved from a + * table containing at least one column for the keys, and one column for the + * values. It's possible to store several configurations in the same table by + * adding a column containing the name of the configuration. The name of the + * table and the columns is specified in the constructor. + * + * h4Example 1 - One configuration per table/h4 + * + * pre + * CREATE TABLE myconfig ( + * `key` VARCHAR NOT NULL PRIMARY KEY, + * `value` VARCHAR + * ); + * + * INSERT INTO myconfig (key, value) VALUES ('foo', 'bar'); + * + * + * Configuration config = new DatabaseConfiguration(datasource, myconfig, key, value); + * String value = config.getString(foo); + * /pre + * + * h4Example 2 - Multiple configurations per table/h4 + * + * pre + * CREATE TABLE myconfigs ( + * `name` VARCHAR NOT NULL, + * `key` VARCHAR NOT NULL, + * `value` VARCHAR, + * CONSTRAINT sys_pk_myconfigs PRIMARY KEY (`name`, `key`) + * ); + * + * INSERT INTO myconfigs (name, key, value) VALUES ('config1', 'key1', 'value1'); + * INSERT INTO myconfigs (name, key, value) VALUES ('config2', 'key2', 'value2'); + * + * + * Configuration config1 = new DatabaseConfiguration(datasource, myconfigs, name, key, value, config1); + * String value1 = conf.getString(key1); + * + * Configuration config2 = new DatabaseConfiguration(datasource, myconfigs, name, key, value, config2); + * String value2 = conf.getString(key2); + * /pre * * @since 1.0 * - * @author Emmanuel Bourg + * @author a href=mailto:[EMAIL PROTECTED]Emmanuel Bourg/a * @version $Revision$, $Date$ */ public class DatabaseConfiguration extends AbstractConfiguration @@ -521,7 +561,7 @@ * @throws SQLException if an error occurs * @since 1.4 */ -protected Connection getConnection() throws SQLException +Connection getConnection() throws SQLException { return getDatasource().getConnection(); } Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java?view=diffrev=529210r1=529209r2=529210 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java Mon Apr 16 04:54:11 2007 @@ -133,8 +133,7 @@ */ private PotentialErrorDatabaseConfiguration setUpConfig() { -return new PotentialErrorDatabaseConfiguration(datasource, TABLE, -COL_KEY, COL_VALUE); +return new PotentialErrorDatabaseConfiguration(datasource, TABLE, COL_KEY, COL_VALUE); } /** @@ -145,8 +144,7 @@ */ private DatabaseConfiguration setUpMultiConfig() { -return new DatabaseConfiguration(datasource, TABLE_MULTI, COL_NAME, -COL_KEY, COL_VALUE, CONFIG_NAME); +return new DatabaseConfiguration(datasource, TABLE_MULTI, COL_NAME, COL_KEY, COL_VALUE, CONFIG_NAME); } /** @@ -157,8 +155,7 @@ private void setUpErrorListener(PotentialErrorDatabaseConfiguration config) { // remove log listener to avoid exception longs -config.removeErrorListener((ConfigurationErrorListener) config -.getErrorListeners().iterator().next()); +config.removeErrorListener((ConfigurationErrorListener) config.getErrorListeners
svn commit: r528458 - in /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist: PropertyListParser.java PropertyListParser.jj
Author: ebourg Date: Fri Apr 13 05:23:22 2007 New Revision: 528458 URL: http://svn.apache.org/viewvc?view=revrev=528458 Log: Fixed the compilation error with Java 1.3 Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java?view=diffrev=528458r1=528457r2=528458 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java Fri Apr 13 05:23:22 2007 @@ -75,7 +75,7 @@ } catch (Exception e) { -throw (ParseException) new ParseException(Unable to parse the byte[]).initCause(e); +throw (ParseException) new ParseException(Unable to parse the byte[] : + e.getMessage()); } } @@ -93,7 +93,7 @@ } catch (Exception e) { -throw (ParseException) new ParseException(Unable to parse the date ' + s + ').initCause(e); +throw (ParseException) new ParseException(Unable to parse the date ' + s + ' : + e.getMessage()); } } Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj?view=diffrev=528458r1=528457r2=528458 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj Fri Apr 13 05:23:22 2007 @@ -98,7 +98,7 @@ } catch (Exception e) { -throw (ParseException) new ParseException(Unable to parse the byte[]).initCause(e); +throw (ParseException) new ParseException(Unable to parse the byte[] : + e.getMessage()); } } @@ -116,7 +116,7 @@ } catch (Exception e) { -throw (ParseException) new ParseException(Unable to parse the date ' + s + ').initCause(e); +throw (ParseException) new ParseException(Unable to parse the date ' + s + ' : + e.getMessage()); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r528563 [2/2] - in /jakarta/commons/proper/configuration/trunk: ./ xdocs/ xdocs/userguide-1.2/ xdocs/userguide/
Added: jakarta/commons/proper/configuration/trunk/xdocs/userguide-1.2/overview.xml URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/xdocs/userguide-1.2/overview.xml?view=autorev=528563 == --- jakarta/commons/proper/configuration/trunk/xdocs/userguide-1.2/overview.xml (added) +++ jakarta/commons/proper/configuration/trunk/xdocs/userguide-1.2/overview.xml Fri Apr 13 10:31:15 2007 @@ -0,0 +1,198 @@ +?xml version=1.0? +!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the License); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an AS IS BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +-- + +document + properties +titleConfiguration Overview/title +author email=[EMAIL PROTECTED]Eric Pugh/author +author email=[EMAIL PROTECTED]Emmanuel Bourg/author + /properties + body + +section name=Using Configuration + p +One of the strength of Commons Configuration is its ability to mix configurations +from heterogeneous sources, this section will introduce you to the different configurations +available and will show you how to combine them. + /p + + subsection name=Configuration Sources + p +Currently there are quite a number of different sources of Configuration objects. But, +by just using a Configuration object versus a specific type like XMLConfiguration or +JNDIConfiguration, you are sheltered from the mechanics of actually retrieving the +configuration values. These various sources include: +ul + li + strongPropertiesConfiguration/strong + Loads configuration values from a properties file. + /li + li + strongXMLConfiguration/strong + Takes values from an XML document. + /li + li + strongPropertyListConfiguration/strong + Loads values from an OpenStep .plist file. XMLPropertyListConfiguration is also + available to read the XML variant used by Mac OSX. + /li + li + strongJNDIConfiguration/strong + Using a key in the JNDI tree, can retrieve values as configuration properties. + /li + li + strongBaseConfiguration/strong + An in-memory method of populating a Configuration object. + /li + li + strongSystemConfiguration/strong + A configuration using the system properties + /li + li + strongConfigurationConverter/strong + Takes a java.util.Properties or an o.a.c.collections.ExtendedProperties + and converts it to a Configuration object. + /li + /ul + + /p + /subsection + + subsection name=Mixing Configuration Sources + p +Often you want to provide a base set of configuration values, but allow the user to easily +override them for their specific environment. Well one way is to hard code the default +values into your code, and have then provide a property file that overrides this. However, +this is a very rigid way of doing things. Instead, with the codeCompositeConfiguration/code +you can provide many different ways of setting up a configuration. You can either do it +manually: + /p + +source +CompositeConfiguration config = new CompositeConfiguration(); +config.addConfiguration(new SystemConfiguration()); +config.addConfiguration(new PropertiesConfiguration(application.properties)); +/source + + por via the codeConfigurationFactory/code class:/p + +source +ConfigurationFactory factory = new ConfigurationFactory(config.xml); +Configuration config = factory.getConfiguration(); +/source + + p +The codeconfig.xml/code file used in the example above is a configuration descriptor, +it specifies the Configuration objects to load. Here is an example of descriptor: + /p + +source![CDATA[ +?xml version=1.0 encoding=ISO-8859-1 ? + +configuration + system/ + properties fileName=application.properties/ +/configuration +]]/source + + p +What this says is that we are loading up all system properties, as well as the properties +
svn commit: r528676 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/DatabaseConfiguration.java xdocs/changes.xml
Author: ebourg Date: Fri Apr 13 14:30:08 2007 New Revision: 528676 URL: http://svn.apache.org/viewvc?view=revrev=528676 Log: Fixed DatabaseConfiguration to ensure the connection is properly closed Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java?view=diffrev=528676r1=528675r2=528676 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DatabaseConfiguration.java Fri Apr 13 14:30:08 2007 @@ -139,16 +139,15 @@ List results = new ArrayList(); while (rs.next()) { -Object val = rs.getObject(valueColumn); +Object value = rs.getObject(valueColumn); if (isDelimiterParsingDisabled()) { -results.add(val); +results.add(value); } else { // Split value if it containts the list delimiter -CollectionUtils.addAll(results, PropertyConverter -.toIterator(val, getListDelimiter())); +CollectionUtils.addAll(results, PropertyConverter.toIterator(value, getListDelimiter())); } } @@ -163,7 +162,7 @@ } finally { -closeQuietly(conn, pstmt); +close(conn, pstmt); } return result; @@ -218,7 +217,7 @@ finally { // clean up -closeQuietly(conn, pstmt); +close(conn, pstmt); } } @@ -299,7 +298,7 @@ finally { // clean up -closeQuietly(conn, pstmt); +close(conn, pstmt); } return empty; @@ -352,7 +351,7 @@ finally { // clean up -closeQuietly(conn, pstmt); +close(conn, pstmt); } return found; @@ -400,7 +399,7 @@ finally { // clean up -closeQuietly(conn, pstmt); +close(conn, pstmt); } } @@ -443,7 +442,7 @@ finally { // clean up -closeQuietly(conn, pstmt); +close(conn, pstmt); } } @@ -496,7 +495,7 @@ finally { // clean up -closeQuietly(conn, pstmt); +close(conn, pstmt); } return keys.iterator(); @@ -534,7 +533,7 @@ * @param conn The database connection to close * @param stmt The statement to close */ -private void closeQuietly(Connection conn, Statement stmt) +private void close(Connection conn, Statement stmt) { try { @@ -542,6 +541,14 @@ { stmt.close(); } +} +catch (SQLException e) +{ +getLogger().error(An error occured on closing the statement, e); +} + +try +{ if (conn != null) { conn.close(); @@ -549,7 +556,7 @@ } catch (SQLException e) { -getLogger().error(e.getMessage(), e); +getLogger().error(An error occured on closing the connection, e); } } } Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?view=diffrev=528676r1=528675r2=528676 == --- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original) +++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Fri Apr 13 14:30:08 2007 @@ -23,6 +23,10 @@ body release version=1.5-SNAPSHOT date=in SVN description= + action dev=ebourg type=fix issue=CONFIGURATION-180 +Fixed a potential issue in DatabaseConfiguration where an error on +closing a statement would prevent the connection from being closed. + /action action dev=ebourg type=add issue=CONFIGURATION-261 Date objects are now supported in ASCII plist files. /action - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r526941 - in /jakarta/commons/proper/configuration/trunk: pom.xml project.xml src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java xdocs/changes.xml xdocs/depe
Author: ebourg Date: Mon Apr 9 15:43:59 2007 New Revision: 526941 URL: http://svn.apache.org/viewvc?view=revrev=526941 Log: Implemented the load() method of XMLPropertyListConfiguration in pure SAX, thus dropping the dependency on Digester and BeanUtils for this class Added the INIConfiguration on the main page Updated my personal info Modified: jakarta/commons/proper/configuration/trunk/pom.xml jakarta/commons/proper/configuration/trunk/project.xml jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml jakarta/commons/proper/configuration/trunk/xdocs/dependencies.xml jakarta/commons/proper/configuration/trunk/xdocs/index.xml Modified: jakarta/commons/proper/configuration/trunk/pom.xml URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/pom.xml?view=diffrev=526941r1=526940r2=526941 == --- jakarta/commons/proper/configuration/trunk/pom.xml (original) +++ jakarta/commons/proper/configuration/trunk/pom.xml Mon Apr 9 15:43:59 2007 @@ -127,7 +127,9 @@ developer nameEmmanuel Bourg/name idebourg/id - email[EMAIL PROTECTED]/email + email[EMAIL PROTECTED]/email + organizationAriane Software/organization + timezone+1/timezone roles roleJava Developer/role /roles @@ -180,7 +182,7 @@ contributor nameNicolas De Loof/name email[EMAIL PROTECTED]/email - organizationcapgemini/organization + organizationCap Gemini/organization /contributor /contributors Modified: jakarta/commons/proper/configuration/trunk/project.xml URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/project.xml?view=diffrev=526941r1=526940r2=526941 == --- jakarta/commons/proper/configuration/trunk/project.xml (original) +++ jakarta/commons/proper/configuration/trunk/project.xml Mon Apr 9 15:43:59 2007 @@ -171,7 +171,9 @@ developer nameEmmanuel Bourg/name idebourg/id - email[EMAIL PROTECTED]/email + email[EMAIL PROTECTED]/email + organizationAriane Software/organization + timezone+1/timezone /developer developer @@ -220,7 +222,7 @@ contributor nameNicolas De Loof/name email[EMAIL PROTECTED]/email - organizationcapgemini/organization + organizationCap Gemini/organization /contributor /contributors Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java?view=diffrev=526941r1=526940r2=526941 == --- 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 Apr 9 15:43:59 2007 @@ -32,6 +32,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; import org.apache.commons.codec.binary.Base64; import org.apache.commons.configuration.AbstractHierarchicalFileConfiguration; @@ -39,15 +41,14 @@ import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.HierarchicalConfiguration; import org.apache.commons.configuration.MapConfiguration; -import org.apache.commons.digester.AbstractObjectCreationFactory; -import org.apache.commons.digester.Digester; -import org.apache.commons.digester.ObjectCreateRule; -import org.apache.commons.digester.SetNextRule; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; + import org.xml.sax.Attributes; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; /** * Mac OS X configuration file (http://www.apple.com/DTDs/PropertyList-1.0.dtd). @@ -137,12 +138,12 @@ * Creates a new instance of codeXMLPropertyListConfiguration/code and * copies the content of the specified configuration into this object. * - * @param c the configuration to copy + * @param configuration the configuration to copy * @since 1.4 */ -public XMLPropertyListConfiguration(HierarchicalConfiguration c) +public XMLPropertyListConfiguration(HierarchicalConfiguration configuration
svn commit: r526587 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/INIConfiguration.java src/test/org/apache/commons/configuration/TestINIConfiguration.jav
Author: ebourg Date: Sun Apr 8 11:05:17 2007 New Revision: 526587 URL: http://svn.apache.org/viewvc?view=revrev=526587 Log: Fixed INIConfiguration to handle the quoted values and the lines containing a value and a comment. Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestINIConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java?view=diffrev=526587r1=526586r2=526587 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/INIConfiguration.java Sun Apr 8 11:05:17 2007 @@ -28,6 +28,8 @@ import java.util.Set; import java.util.TreeSet; +import org.apache.commons.lang.StringUtils; + /** * p * An initialization or ini file is a configuration file tpically found on @@ -242,7 +244,7 @@ String value = values.getString(key); pw.print(key); pw.print( = ); -pw.print(value); +pw.print(formatValue(value)); pw.print(LINE_SEPARATOR); } @@ -283,7 +285,7 @@ if (index = 0) { key = section + line.substring(0, index); -value = line.substring(index + 1); +value = parseValue(line.substring(index + 1)); } else { @@ -291,14 +293,14 @@ if (index = 0) { key = section + line.substring(0, index); -value = line.substring(index + 1); +value = parseValue(line.substring(index + 1)); } else { key = section + line; } } -this.addProperty(key.trim(), value.trim()); +this.addProperty(key.trim(), value); } } line = bufferedReader.readLine(); @@ -307,6 +309,99 @@ catch (IOException ioe) { throw new ConfigurationException(ioe.getMessage()); +} +} + +/** + * Parse the value to remove the quotes and ignoring the comment. + * Example: + * + * codevalue ; comment - value/code + * + * @param value + */ +private String parseValue(String value) +{ +value = value.trim(); + +boolean quoted = value.startsWith(\); +boolean stop = false; +boolean escape = false; + +int i = quoted ? 1 : 0; + +StringBuffer result = new StringBuffer(); +while (i value.length() !stop) +{ +char c = value.charAt(i); + +if (quoted) +{ +if ('\\' == c !escape) +{ +escape = true; +} +else if (!escape '' == c) +{ +stop = true; +} +else if (escape '' == c) +{ +escape = false; +result.append(c); +} +else +{ +if (escape) +{ +escape = false; +result.append('\\'); +} + +result.append(c); +} +} +else +{ +if (COMMENT_CHARS.indexOf(c) == -1) +{ +result.append(c); +} +else +{ +stop = true; +} +} + +i++; +} + +return result.toString().trim(); +} + +/** + * Add quotes around the specified value if it contains a comment character. + */ +private String formatValue(String value) +{ +boolean quoted = false; + +for (int i = 0; i COMMENT_CHARS.length() !quoted; i++) +{ +char c = COMMENT_CHARS.charAt(i); +if (value.indexOf(c) != -1) +{ +quoted = true
svn commit: r388560 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/CompositeConfiguration.java src/test/org/apache/commons/configuration/TestCompositeConfi
Author: ebourg Date: Fri Mar 24 07:18:22 2006 New Revision: 388560 URL: http://svn.apache.org/viewcvs?rev=388560view=rev Log: Added two new constructors in CompositeConfiguration accepting a collection of configurations as a parameter. (Bug 39068) Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java?rev=388560r1=388559r2=388560view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java Fri Mar 24 07:18:22 2006 @@ -17,6 +17,7 @@ package org.apache.commons.configuration; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -53,7 +54,7 @@ } /** - * Creates an CompositeConfiguration object with a specified InMemory + * Creates a CompositeConfiguration object with a specified in memory * configuration. This configuration will store any changes made to * the CompositeConfiguration. * @@ -64,6 +65,38 @@ configList.clear(); this.inMemoryConfiguration = inMemoryConfiguration; configList.add(inMemoryConfiguration); +} + +/** + * Create a CompositeConfiguration with an empty in memory configuration + * and adds the collection of configurations specified. + * + * @param configurations the collection of configurations to add + */ +public CompositeConfiguration(Collection configurations) +{ +this(new BaseConfiguration(), configurations); +} + +/** + * Creates a CompositeConfiguration with a specified in memory + * configuration, and then adds the given collection of configurations. + * + * @param inMemoryConfiguration the in memory configuration to use + * @param configurationsthe collection of configurations to add + */ +public CompositeConfiguration(Configuration inMemoryConfiguration, Collection configurations) +{ +this(inMemoryConfiguration); + +if (configurations != null) +{ +Iterator it = configurations.iterator(); +while (it.hasNext()) +{ +addConfiguration((Configuration) it.next()); +} +} } /** Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java?rev=388560r1=388559r2=388560view=diff == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java Fri Mar 24 07:18:22 2006 @@ -21,6 +21,7 @@ import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; +import java.util.Collection; import junit.framework.TestCase; @@ -61,15 +62,15 @@ public void testAddRemoveConfigurations() throws Exception { cc.addConfiguration(conf1); -assertEquals(2, cc.getNumberOfConfigurations()); +assertEquals(Number of configurations, 2, cc.getNumberOfConfigurations()); cc.addConfiguration(conf1); -assertEquals(2, cc.getNumberOfConfigurations()); +assertEquals(Number of configurations, 2, cc.getNumberOfConfigurations()); cc.addConfiguration(conf2); -assertEquals(3, cc.getNumberOfConfigurations()); +assertEquals(Number of configurations, 3, cc.getNumberOfConfigurations()); cc.removeConfiguration(conf1); -assertEquals(2, cc.getNumberOfConfigurations()); +assertEquals(Number of configurations, 2, cc.getNumberOfConfigurations()); cc.clear(); -assertEquals(1, cc.getNumberOfConfigurations()); +assertEquals(Number of configurations, 1, cc.getNumberOfConfigurations()); } public void testGetPropertyWIncludes() throws Exception @@ -222,8 +223,7 @@ cc.addConfiguration(conf1); cc.addConfiguration
svn commit: r358268 - /jakarta/commons/proper/dbutils/trunk/xdocs/changes.xml
Author: ebourg Date: Wed Dec 21 03:20:29 2005 New Revision: 358268 URL: http://svn.apache.org/viewcvs?rev=358268view=rev Log: Moved the bug ids into the 'issue' attribute of the 'action' element. Modified: jakarta/commons/proper/dbutils/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/dbutils/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/dbutils/trunk/xdocs/changes.xml?rev=358268r1=358267r2=358268view=diff == --- jakarta/commons/proper/dbutils/trunk/xdocs/changes.xml (original) +++ jakarta/commons/proper/dbutils/trunk/xdocs/changes.xml Wed Dec 21 03:20:29 2005 @@ -39,23 +39,23 @@ body release version=1.1-dev date=in CVS - action dev=dgraham type=add + action dev=dgraham type=add issue=32120 Added protected ResultSetIterator.rethrow() method to wrap SQLExceptions in -RuntimeExceptions. PR: 32120 +RuntimeExceptions. /action - action dev=dgraham type=update -Added SQLState and error code to rethrown SQLExceptions. PR: 33614 + action dev=dgraham type=update issue=33614 +Added SQLState and error code to rethrown SQLExceptions. /action - action dev=dgraham type=add -Added KeyedHandler to create a Map of Maps from a ResultSet. PR: 31446 + action dev=dgraham type=add issue=31446 +Added KeyedHandler to create a Map of Maps from a ResultSet. /action - action dev=dgraham type=update + action dev=dgraham type=update issue=31169 Use current class' ClassLoader instead of QueryLoader's ClassLoader -in loadQueries(). PR: 31169 +in loadQueries(). /action - action dev=dgraham type=update + action dev=dgraham type=update issue=31460 Made QueryLoader.loadQueries() protected so subclasses can use query -repositories other than properties files. PR: 31460 +repositories other than properties files. /action action dev=dgraham type=update QueryRunner now calls getDataSource() internally any time it needs access @@ -64,39 +64,34 @@ action dev=dgraham type=add Added DbUtils.rollbackAndClose() and DbUtils.rollbackAndCloseQuietly(). /action - action dev=dgraham type=update + action dev=dgraham type=update issue=30749 Call ResultSet.getTimestamp() in BeanProcessor.processColumn() if the bean property is a java.sql.Timestamp. Oracle's getObject() implementation returns its own incompatible Timestamp class. -PR: 30749 /action - action dev=dgraham type=update + action dev=dgraham type=update issue=29212 Changed QueryRunner.fillStatement() null handling to use Types.VARCHAR instead of Types.OTHER. This works for the following tested drivers: Firebird 1.5/firebirdsql 1.5RC3, Oracle 9/ Thin driver, MySQL 4.0/Msql Connecttor 3.0 and mm.mysql 2.0.4 MaxDB 7.5, HSQLDB 1.7.1, and MS Access/ODBC Bridge. -PR# 29212 /action - action dev=dgraham type=add + action dev=dgraham type=add issue=30032 Added a protected QueryRunner.prepareConnection() method to allow subclasses to customize the Connections retrieved from the DataSource before they're used. -PR# 30032 /action action dev=dgraham type=add Refactored bean handling from BasicRowProcessor into new BeanProcessor class. This also fixes the common problem with Oracle NUMERIC fields not being set into bean properties. /action - action dev=dgraham type=add + action dev=dgraham type=add issue=27530 Added QueryRunner.batch() methods for batch updates. -PR# 27530 /action - action dev=dgraham type=add + action dev=dgraham type=add issue=27377 Added new ResultSetHandler implementation, ColumnListHandler, that -converts one ResultSet column into a List of Objects. -PR# 27377 +converts one ResultSet column into a List of Objects. /action /release - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r358269 - /jakarta/commons/proper/dbutils/trunk/project.xml
Author: ebourg Date: Wed Dec 21 03:27:34 2005 New Revision: 358269 URL: http://svn.apache.org/viewcvs?rev=358269view=rev Log: Added a dependency on the xdoc 1.9.2 plugin to make the site buildable with the latest commons-build Modified: jakarta/commons/proper/dbutils/trunk/project.xml Modified: jakarta/commons/proper/dbutils/trunk/project.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/dbutils/trunk/project.xml?rev=358269r1=358268r2=358269view=diff == --- jakarta/commons/proper/dbutils/trunk/project.xml (original) +++ jakarta/commons/proper/dbutils/trunk/project.xml Wed Dec 21 03:27:34 2005 @@ -187,6 +187,14 @@ version3.8.1/version urlhttp://www.junit.org//url /dependency + +dependency + groupIdmaven/groupId + artifactIdmaven-xdoc-plugin/artifactId + version1.9.2/version + urlhttp://maven.apache.org/reference/plugins/xdoc/url + typeplugin/type +/dependency /dependencies build - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r356789 - /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java
Author: ebourg Date: Wed Dec 14 07:20:30 2005 New Revision: 356789 URL: http://svn.apache.org/viewcvs?rev=356789view=rev Log: Added a reference to ConfigurationConverter in ConfigurationUtils Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java?rev=356789r1=356788r2=356789view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java Wed Dec 14 07:20:30 2005 @@ -34,6 +34,8 @@ /** * Miscellaneous utility methods for configurations. * + * @see ConfigurationConverter Utility methods to convert configurations. + * * @author a href=mailto:[EMAIL PROTECTED]Herve Quiroz/a * @author a href=mailto:[EMAIL PROTECTED]Oliver Heger/a * @author Emmanuel Bourg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r354016 - /jakarta/commons/proper/configuration/trunk/project.properties
Author: ebourg Date: Mon Dec 5 00:16:22 2005 New Revision: 354016 URL: http://svn.apache.org/viewcvs?rev=354016view=rev Log: Added the maven.compile.source to compile with the JDK 1.5 Modified: jakarta/commons/proper/configuration/trunk/project.properties Modified: jakarta/commons/proper/configuration/trunk/project.properties URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/project.properties?rev=354016r1=354015r2=354016view=diff == --- jakarta/commons/proper/configuration/trunk/project.properties (original) +++ jakarta/commons/proper/configuration/trunk/project.properties Mon Dec 5 00:16:22 2005 @@ -34,5 +34,6 @@ maven.jar.resources=conf/resources.jar maven.compile.target = 1.3 +maven.compile.source = 1.3 maven.javacc.javacc.grammar=src/java/org/apache/commons/configuration/plist/PropertyListParser.jj - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r354017 - in /jakarta/commons/proper/configuration/trunk/conf: checkstyle-suppressions.xml checkstyle.xml
Author: ebourg Date: Mon Dec 5 00:21:58 2005 New Revision: 354017 URL: http://svn.apache.org/viewcvs?rev=354017view=rev Log: The classes generated by JavaCC are no longer checked by CheckStyke Removed the FileLength check, it should not take the javadoc into consideration Allowed the declaration of unchecked exceptions Added '3' as a magic number Javadoc is now mandatory for public methods only Added: jakarta/commons/proper/configuration/trunk/conf/checkstyle-suppressions.xml Modified: jakarta/commons/proper/configuration/trunk/conf/checkstyle.xml Added: 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=354017view=auto == --- jakarta/commons/proper/configuration/trunk/conf/checkstyle-suppressions.xml (added) +++ jakarta/commons/proper/configuration/trunk/conf/checkstyle-suppressions.xml Mon Dec 5 00:21:58 2005 @@ -0,0 +1,20 @@ +?xml version=1.0? + +!DOCTYPE suppressions PUBLIC +-//Puppy Crawl//DTD Suppressions 1.0//EN +http://www.puppycrawl.com/dtds/suppressions_1_0.dtd; + +!-- Exceptions for Checkstyle -- + +suppressions + +!-- Disable the warnings for the generated classes -- +suppress checks=.* files=ParseException.java/ +suppress checks=.* files=PropertyListParser.java/ +suppress checks=.* files=PropertyListParserConstants.java/ +suppress checks=.* files=PropertyListParserTokenManager.java/ +suppress checks=.* files=SimpleCharStream.java/ +suppress checks=.* files=Token.java/ +suppress checks=.* files=TokenMgrError.java/ + +/suppressions Modified: jakarta/commons/proper/configuration/trunk/conf/checkstyle.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/conf/checkstyle.xml?rev=354017r1=354016r2=354017view=diff == --- jakarta/commons/proper/configuration/trunk/conf/checkstyle.xml (original) +++ jakarta/commons/proper/configuration/trunk/conf/checkstyle.xml Mon Dec 5 00:21:58 2005 @@ -20,6 +20,10 @@ !-- See http://checkstyle.sf.net/config_misc.html#Translation -- module name=Translation/ +!-- Exceptions -- +module name=SuppressionFilter +property name=file value=conf/checkstyle-suppressions.xml/ +/module module name=TreeWalker @@ -28,6 +32,7 @@ !-- Checks for Javadoc comments. -- !-- See http://checkstyle.sf.net/config_javadoc.html -- module name=JavadocMethod +property name=scope value=public/ property name=allowUndeclaredRTE value=true/ /module module name=JavadocType @@ -70,7 +75,7 @@ !-- Checks for Size Violations.-- !-- See http://checkstyle.sf.net/config_sizes.html -- -module name=FileLength/ +!--module name=FileLength/-- module name=LineLength property name=max value=120/ /module @@ -117,9 +122,13 @@ module name=EqualsHashCode/ module name=IllegalInstantiation/ module name=InnerAssignment/ -module name=MagicNumber/ +module name=MagicNumber +property name=ignoreNumbers value=-1,0,1,2,3/ +/module module name=MissingSwitchDefault/ -module name=RedundantThrows/ +module name=RedundantThrows +property name=allowUnchecked value=true/ +/module module name=SimplifyBooleanExpression/ module name=SimplifyBooleanReturn/ module name=StringLiteralEquality/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r354018 - /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java
Author: ebourg Date: Mon Dec 5 00:23:00 2005 New Revision: 354018 URL: http://svn.apache.org/viewcvs?rev=354018view=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=354018r1=354017r2=354018view=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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r354019 - in /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration: ConfigurationMap.java PropertiesConfiguration.java beanutils/ConfigurationDynaClass.java
Author: ebourg Date: Mon Dec 5 00:23:53 2005 New Revision: 354019 URL: http://svn.apache.org/viewcvs?rev=354019view=rev Log: Checkstyle changes (private properties, declaration order, white spaces) Modified: 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/beanutils/ConfigurationDynaClass.java 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=354019r1=354018r2=354019view=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 00:23:53 2005 @@ -39,18 +39,7 @@ /** * The codeConfiguration/code wrapped by this class. */ -Configuration configuration; - -/** - * Returns the wrapped codeConfiguration/code object. - * - * @return the wrapped configuration - * @since 1.2 - */ -public Configuration getConfiguration() -{ -return configuration; -} +private Configuration configuration; /** * Creates a new instance of a codeConfigurationMap/code @@ -62,6 +51,17 @@ public ConfigurationMap(Configuration configuration) { this.configuration = configuration; +} + +/** + * Returns the wrapped codeConfiguration/code object. + * + * @return the wrapped configuration + * @since 1.2 + */ +public Configuration getConfiguration() +{ +return 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=354019r1=354018r2=354019view=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 00:23:53 2005 @@ -155,10 +155,10 @@ public class PropertiesConfiguration extends AbstractFileConfiguration { /** The list of possible key/value separators */ -private static final char[] SEPARATORS = new char[] { '=', ':' }; +private static final char[] SEPARATORS = new char[] {'=', ':'}; /** The white space characters used as key/value separators. */ -private static final char[] WHITE_SPACE = new char[] { ' ', '\t', '\f' }; +private static final char[] WHITE_SPACE = new char[]{' ', '\t', '\f'}; /** * The default encoding (ISO-8859-1 as specified by Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaClass.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaClass.java?rev=354019r1=354018r2=354019view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaClass.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaClass.java Mon Dec 5 00:23:53 2005 @@ -42,7 +42,7 @@ private static Log log = LogFactory.getLog(ConfigurationDynaClass.class); /** Stores the associated configuration.*/ -Configuration configuration; +private Configuration configuration; /** * Construct an instance of a codeConfigurationDynaClass/code - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r354251 - /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertyConverter.java
Author: ebourg Date: Mon Dec 5 17:13:13 2005 New Revision: 354251 URL: http://svn.apache.org/viewcvs?rev=354251view=rev Log: Fixed the error introduced with the new loop parsing the color components 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=354251r1=354250r2=354251view=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 17:13:13 2005 @@ -540,7 +540,7 @@ int[] components = new int[3]; for (int i = 0; i components.length; i++) { -components[i] = Integer.parseInt(color.substring(i, i + 2), HEX_RADIX); +components[i] = Integer.parseInt(color.substring(2 * i, 2 * i + 2), HEX_RADIX); } int alpha = 255; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r354264 - in /jakarta/commons/proper/configuration/trunk: ./ conf/ src/java/org/apache/commons/configuration/ src/java/org/apache/commons/configuration/plist/
Author: ebourg Date: Mon Dec 5 19:10:27 2005 New Revision: 354264 URL: http://svn.apache.org/viewcvs?rev=354264view=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=354264r1=354263r2=354264view=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=354264r1=354263r2=354264view=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=354264r1=354263r2=354264view=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=354264r1=354263r2=354264view=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
svn commit: r312690 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/PropertiesConfiguration.java src/test/org/apache/commons/configuration/TestPropertiesCon
Author: ebourg Date: Mon Oct 10 10:22:05 2005 New Revision: 312690 URL: http://svn.apache.org/viewcvs?rev=312690view=rev Log: PropertiesConfiguration now translates properly the escaped unicode characters (like \u1234) used in the property keys (Bug 36991) Modified: 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/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=312690r1=312689r2=312690view=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 Oct 10 10:22:05 2005 @@ -347,7 +347,7 @@ } else { -addProperty(key, unescapeJava(value, getDelimiter())); +addProperty(StringEscapeUtils.unescapeJava(key), unescapeJava(value, getDelimiter())); } } 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=312690r1=312689r2=312690view=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 Mon Oct 10 10:22:05 2005 @@ -1,5 +1,3 @@ -package org.apache.commons.configuration; - /* * Copyright 2001-2005 The Apache Software Foundation. * @@ -16,16 +14,12 @@ * limitations under the License. */ +package org.apache.commons.configuration; + 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.io.StringReader; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -309,6 +303,14 @@ public void testUnescapeJava() { assertEquals(test\\,test, PropertiesConfiguration.unescapeJava(test\\,test, ',')); +} + +public void testEscapedKey() throws Exception +{ +PropertiesConfiguration conf = new PropertiesConfiguration(); +conf.load(new StringReader(\\u0066\\u006f\\u006f=bar)); + +assertEquals(value of the 'foo' property, bar, conf.getString(foo)); } public void testMixedArray() Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?rev=312690r1=312689r2=312690view=diff == --- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original) +++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Mon Oct 10 10:22:05 2005 @@ -23,6 +23,11 @@ body release version=1.2-dev date=in SVN + action dev=ebourg type=update issue=36991 +PropertiesConfiguration now translates properly the escaped unicode +characters (like \u1234) used in the property keys. This complies with +the specification of java.util.Properties. + /action action dev=ebourg type=update issue=36784 ConfigurationConverter.getProperties() now uses the delimiter of the specified configuration to convert the list properties into strings. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r292567 - in /jakarta/commons/proper/configuration/trunk: ./ src/java/org/apache/commons/configuration/plist/ src/test/org/apache/commons/configuration/plist/
Author: ebourg Date: Thu Sep 29 15:24:16 2005 New Revision: 292567 URL: http://svn.apache.org/viewcvs?rev=292567view=rev Log: Improved the test coverage on the plist package Added: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListParser.java Modified: jakarta/commons/proper/configuration/trunk/project.properties 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/PropertyListParser.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.jj jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParserTokenManager.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestPropertyListConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/project.properties URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/project.properties?rev=292567r1=292566r2=292567view=diff == --- jakarta/commons/proper/configuration/trunk/project.properties (original) +++ jakarta/commons/proper/configuration/trunk/project.properties Thu Sep 29 15:24:16 2005 @@ -35,6 +35,4 @@ maven.compile.source = 1.3 -maven.clover.license.path=src/conf/clover.license - maven.javacc.javacc.grammar=src/java/org/apache/commons/configuration/plist/PropertyListParser.jj 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=292567r1=292566r2=292567view=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 Thu Sep 29 15:24:16 2005 @@ -173,13 +173,14 @@ printNode(out, indentLevel + 1, child); // add a semi colon for elements that are not dictionaries -if (child.getValue() != null) +Object value = child.getValue(); +if (value != null !(value instanceof Map) !(value instanceof Configuration)) { out.println(;); } // skip a line after arrays and dictionaries -if (it.hasNext() (child.getValue() == null || child.getValue() instanceof List)) +if (it.hasNext() (value == null || value instanceof List)) { out.println(); } @@ -229,6 +230,7 @@ else if (value instanceof Configuration) { // display a flat Configuration as a dictionary +out.println(); out.println(padding + {); Configuration config = (Configuration) value; @@ -240,11 +242,7 @@ node.setValue(config.getProperty(key)); printNode(out, indentLevel + 1, node); - -if (it.hasNext()) -{ -out.println(); -} +out.println(;); } out.println(padding + }); } @@ -281,7 +279,7 @@ * lifoo;bar - foo;bar/li * /ul */ -private String quoteString(String s) +String quoteString(String s) { if (s == null) { Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java?rev=292567r1=292566r2=292567view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListParser.java Thu
svn commit: r291931 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/ src/test/org/apache/commons/configuration/ xdocs/
Author: ebourg Date: Tue Sep 27 06:06:23 2005 New Revision: 291931 URL: http://svn.apache.org/viewcvs?rev=291931view=rev Log: Implemented variable interpolation for all getters Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml 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=291931r1=291930r2=291931view=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 Tue Sep 27 06:06:23 2005 @@ -131,6 +131,25 @@ } /** + * Returns the interpolated value. Non String values are returned without change. + * + * @param value the value to interpolate + * + * @return returns the value with variables substituted + */ +protected Object interpolate(Object value) +{ +if (value instanceof String) +{ +return interpolate((String) value); +} +else +{ +return value; +} +} + +/** * Recursive handler for multple levels of interpolation. * * When called the first time, priorVariables should be null. @@ -388,7 +407,7 @@ { try { -return PropertyConverter.toBoolean(value); +return PropertyConverter.toBoolean(interpolate(value)); } catch (ConversionException e) { @@ -436,7 +455,7 @@ { try { -return PropertyConverter.toByte(value); +return PropertyConverter.toByte(interpolate(value)); } catch (ConversionException e) { @@ -484,7 +503,7 @@ { try { -return PropertyConverter.toDouble(value); +return PropertyConverter.toDouble(interpolate(value)); } catch (ConversionException e) { @@ -532,7 +551,7 @@ { try { -return PropertyConverter.toFloat(value); +return PropertyConverter.toFloat(interpolate(value)); } catch (ConversionException e) { @@ -587,7 +606,7 @@ { try { -return PropertyConverter.toInteger(value); +return PropertyConverter.toInteger(interpolate(value)); } catch (ConversionException e) { @@ -635,7 +654,7 @@ { try { -return PropertyConverter.toLong(value); +return PropertyConverter.toLong(interpolate(value)); } catch (ConversionException e) { @@ -683,7 +702,7 @@ { try { -return PropertyConverter.toShort(value); +return PropertyConverter.toShort(interpolate(value)); } catch (ConversionException e) { @@ -727,7 +746,7 @@ { try { -return PropertyConverter.toBigDecimal(value); +return PropertyConverter.toBigDecimal(interpolate(value)); } catch (ConversionException e) { @@ -771,7 +790,7 @@ { try { -return PropertyConverter.toBigInteger(value); +return PropertyConverter.toBigInteger(interpolate(value)); } catch (ConversionException e) { @@ -887,12 +906,7 @@ Iterator it = l.iterator(); while (it.hasNext()) { -Object element = it.next(); -if (element instanceof String) { -list.add(interpolate((String) element)); -} else { -list.add(element); -} +list.add(interpolate(it.next())); } } Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java URL: http
svn commit: r291679 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/ src/java/org/apache/commons/configuration/beanutils/ src/test/org/apache/commons/config
Author: ebourg Date: Mon Sep 26 10:15:28 2005 New Revision: 291679 URL: http://svn.apache.org/viewcvs?rev=291679view=rev Log: Interpolation for getList() Custom list delimiter for ConfigurationConverter.getProperties(); Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationConverter.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationConverter.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/beanutils/TestConfigurationDynaBean.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml 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=291679r1=291678r2=291679view=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 Sep 26 10:15:28 2005 @@ -114,9 +114,9 @@ * provide write acces to underlying Configuration store. * * @param key key to use for mapping - * @param obj object to store + * @param value object to store */ -protected abstract void addPropertyDirect(String key, Object obj); +protected abstract void addPropertyDirect(String key, Object value); /** * interpolate key names to handle ${key} stuff @@ -161,7 +161,6 @@ int begin = -1; int end = -1; int prec = 0 - END_TOKEN.length(); -String variable = null; StringBuffer result = new StringBuffer(); // FIXME: we should probably allow the escaping of the start token @@ -169,7 +168,7 @@ ((end = base.indexOf(END_TOKEN, begin)) -1)) { result.append(base.substring(prec + END_TOKEN.length(), begin)); -variable = base.substring(begin + START_TOKEN.length(), end); +String variable = base.substring(begin + START_TOKEN.length(), end); // if we've got a loop, create a useful exception message and throw if (priorVariables.contains(variable)) @@ -872,16 +871,30 @@ public List getList(String key, List defaultValue) { Object value = getProperty(key); -List list = null; +List list; if (value instanceof String) { list = new ArrayList(1); -list.add(value); +list.add(interpolate((String) value)); } else if (value instanceof List) { -list = (List) value; +list = new ArrayList(); +List l = (List) value; + +// add the interpolated elements in the new list +Iterator it = l.iterator(); +while (it.hasNext()) +{ +Object element = it.next(); +if (element instanceof String) { +list.add(interpolate((String) element)); +} else { +list.add(element); +} +} + } else if (value == null) { Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationConverter.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationConverter.java?rev=291679r1=291678r2=291679view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationConverter.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationConverter.java Mon Sep 26 10:15:28 2005 @@ -1,5 +1,5 @@ /* - * Copyright 2001-2004 The Apache Software Foundation. + * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the License) * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import java.util.Vector; import org.apache.commons.collections.ExtendedProperties; +import org.apache.commons.lang.StringUtils; /** * Configuration converter. Helper class to convert between
svn commit: r289994 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/PropertiesConfiguration.java xdocs/changes.xml
Author: ebourg Date: Sun Sep 18 15:40:39 2005 New Revision: 289994 URL: http://svn.apache.org/viewcvs?rev=289994view=rev Log: PropertiesConfiguration now uses the ISO-8859-1 encoding by default instead of the system encoding to comply with the specification of java.util.Properties (Bug 36699) Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml 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=289994r1=289993r2=289994view=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 Sun Sep 18 15:40:39 2005 @@ -166,6 +166,16 @@ private String header; /** + * The default encoding (ISO-8859-1 as specified by http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html) + */ +private static final String DEFAULT_ENCODING = ISO-8859-1; + +// initialization block to set the encoding before loading the file in the constructors +{ +setEncoding(DEFAULT_ENCODING); +} + +/** * Creates an empty PropertyConfiguration object which can be * used to synthesize a new Properties file by adding values and * then saving(). @@ -586,7 +596,7 @@ * pUnescapes any Java literals found in the codeString/code to a * codeWriter/code./p This is a slightly modified version of the * StringEscapeUtils.unescapeJava() function in commons-lang that doesn't - * drop escaped commas (i.e '\,'). + * drop escaped separators (i.e '\,'). * * @param str the codeString/code to unescape, may be null * Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?rev=289994r1=289993r2=289994view=diff == --- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original) +++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Sun Sep 18 15:40:39 2005 @@ -23,6 +23,11 @@ body release version=1.2-dev date=in SVN + action dev=ebourg type=update issue=36699 +PropertiesConfiguration now uses the ISO-8859-1 encoding by default +instead of the system encoding to comply with the specification of +java.util.Properties. + /action action dev=ebourg type=update issue=36664 JNDIConfiguration no longer logs an error when attempting to get a property that doesn't exist in the configuration. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r289181 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/JNDIConfiguration.java xdocs/changes.xml
Author: ebourg Date: Thu Sep 15 01:46:25 2005 New Revision: 289181 URL: http://svn.apache.org/viewcvs?rev=289181view=rev Log: JNDIConfiguration no longer logs an error when attempting to get a property that doesn't exist in the configuration (Bug 36664) Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/JNDIConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/JNDIConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/JNDIConfiguration.java?rev=289181r1=289180r2=289181view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/JNDIConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/JNDIConfiguration.java Thu Sep 15 01:46:25 2005 @@ -25,6 +25,7 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NameClassPair; +import javax.naming.NameNotFoundException; import javax.naming.NamingEnumeration; import javax.naming.NamingException; @@ -329,6 +330,11 @@ getBaseContext().lookup(key); return true; } +catch (NameNotFoundException e) +{ +// expected exception, no need to log it +return false; +} catch (NamingException e) { log.error(e.getMessage(), e); @@ -371,6 +377,11 @@ { key = StringUtils.replace(key, ., /); return getBaseContext().lookup(key); +} +catch (NameNotFoundException e) +{ +// expected exception, no need to log it +return null; } catch (NamingException e) { Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?rev=289181r1=289180r2=289181view=diff == --- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original) +++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Thu Sep 15 01:46:25 2005 @@ -23,6 +23,10 @@ body release version=1.2-dev date=in SVN + action dev=ebourg type=update issue=36664 +JNDIConfiguration no longer logs an error when attempting to get +a property that doesn't exist in the configuration. + /action action dev=ebourg type=update issue=36488 Attempting to load a configuration from a directory instead of a file will now throw a ConfigurationException. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r278773 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/AbstractFileConfiguration.java src/test/org/apache/commons/configuration/TestFileConfigu
Author: ebourg Date: Mon Sep 5 08:18:58 2005 New Revision: 278773 URL: http://svn.apache.org/viewcvs?rev=278773view=rev Log: Loading a configuration from a directory now throws an exception (Bug 36488) Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestFileConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java?rev=278773r1=278772r2=278773view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java Mon Sep 5 08:18:58 2005 @@ -245,13 +245,21 @@ { if (sourceURL == null) { -if(StringUtils.isEmpty(getBasePath())) +if (StringUtils.isEmpty(getBasePath())) { // ensure that we have a valid base path setBasePath(url.toString()); } sourceURL = url; } + +// throw an exception if the target URL is a directory +File file = ConfigurationUtils.fileFromURL(url); +if (file != null file.isDirectory()) +{ +throw new ConfigurationException(Cannot load a configuration from a directory); +} + InputStream in = null; try Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestFileConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestFileConfiguration.java?rev=278773r1=278772r2=278773view=diff == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestFileConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestFileConfiguration.java Mon Sep 5 08:18:58 2005 @@ -413,4 +413,52 @@ //ok } } + +/** + * Checks that loading a directory instead of a file throws an exception. + */ +public void testLoadDirectory() +{ +PropertiesConfiguration config = new PropertiesConfiguration(); + +try +{ +config.load(target); +fail(Could load config from a directory!); +} +catch (ConfigurationException e) +{ +// ok +} + +try +{ +config.load(new File(target)); +fail(Could load config from a directory!); +} +catch (ConfigurationException e) +{ +// ok +} + +try +{ +new PropertiesConfiguration(target); +fail(Could load config from a directory!); +} +catch (ConfigurationException e) +{ +// ok +} + +try +{ +new PropertiesConfiguration(new File(target)); +fail(Could load config from a directory!); +} +catch (ConfigurationException e) +{ +// ok +} +} } Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?rev=278773r1=278772r2=278773view=diff == --- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original) +++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Mon Sep 5 08:18:58 2005 @@ -23,6 +23,10 @@ body release version=1.2-dev date=in SVN + action dev=ebourg type=update issue=36488 +Attempting to load a configuration from a directory instead of a file +will now throw a ConfigurationException. + /action action dev=oheger type=update issue=36447 If a multi-valued property was involved in an interpolation operation, AbstractConfiguration created a string representation of the list of all - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r264988 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/ src/java/org/apache/commons/configuration/plist/ xdocs/
Author: ebourg Date: Wed Aug 31 02:20:41 2005 New Revision: 264988 URL: http://svn.apache.org/viewcvs?rev=264988view=rev Log: Documentation update: - minor javadoc fixes - dependencies update - introducing plist configurations in the doc Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/dependencies.xml jakarta/commons/proper/configuration/trunk/xdocs/index.xml jakarta/commons/proper/configuration/trunk/xdocs/overview.xml 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=264988r1=264987r2=264988view=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 Aug 31 02:20:41 2005 @@ -554,6 +554,8 @@ /** * Escape the separators in the key. + * + * @since 1.2 */ private String escapeKey(String key) { @@ -692,6 +694,8 @@ /** * Parse a property line and return the key and the value in an array. + * + * @since 1.2 */ private String[] parseProperty(String line) { 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=264988r1=264987r2=264988view=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 Wed Aug 31 02:20:41 2005 @@ -45,7 +45,7 @@ * * array = ( value1, value2, value3 ); * - * data = 4f3e0145ab; + * data = lt;4f3e0145ab; * * nested = * { Modified: jakarta/commons/proper/configuration/trunk/xdocs/dependencies.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/dependencies.xml?rev=264988r1=264987r2=264988view=diff == --- jakarta/commons/proper/configuration/trunk/xdocs/dependencies.xml (original) +++ jakarta/commons/proper/configuration/trunk/xdocs/dependencies.xml Wed Aug 31 02:20:41 2005 @@ -41,38 +41,46 @@ td Java 1.3br/ commons-collectionsbr/ -commons-lang +commons-langbr/ +commons-logging /td /tr tr tdConfigurationFactory/td td -commons-loggingbr/ commons-digesterbr/ +commons-beanutilsbr/ JDK 1.4 or xml-apis /td /tr tr tdDatabaseConfiguration/td -td -commons-loggingbr/ -JDBC 3.0 (Java 1.4 or jdbc2_0-stdext.jar) -/td +tdJDBC 3.0 (Java 1.4 or jdbc2_0-stdext.jar)/td /tr tr -tdXMLConfiguration, HierarchicalXMLConfiguration/td +tdXMLConfiguration/td tdJava 1.4 or (xml-apis + xerces)/td /tr tr -tdJNDIConfiguration/td -tdcommons-logging/td +tdXMLPropertiesConfiguration/td +tdJava 1.4 or (xml-apis + xerces)/td /tr tr -tdConfigurationDynaBean/td +tdPropertyListConfiguration/td +tdcommons-codec/td +/tr +tr +tdXMLPropertyListConfiguration/td td +commons-digesterbr
svn commit: r239600 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/MapConfiguration.java src/test/org/apache/commons/configuration/TestAbstractConfiguratio
Author: ebourg Date: Wed Aug 24 04:08:23 2005 New Revision: 239600 URL: http://svn.apache.org/viewcvs?rev=239600view=rev Log: Fixed MapConfiguration to store the list of values added under a same key instead of the last value added. Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/MapConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/MapConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/MapConfiguration.java?rev=239600r1=239599r2=239600view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/MapConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/MapConfiguration.java Wed Aug 24 04:08:23 2005 @@ -1,5 +1,5 @@ /* - * Copyright 2004 The Apache Software Foundation. + * Copyright 2004-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the License) * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.apache.commons.configuration; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -66,9 +67,28 @@ } } -protected void addPropertyDirect(String key, Object obj) +protected void addPropertyDirect(String key, Object value) { -map.put(key, obj); +Object previousValue = getProperty(key); + +if (previousValue == null) +{ +map.put(key, value); +} +else if (previousValue instanceof List) +{ +// the value is added to the existing list +((List) previousValue).add(value); +} +else +{ +// the previous value is replaced by a list containing the previous value and the new value +List list = new ArrayList(); +list.add(previousValue); +list.add(value); + +map.put(key, list); +} } public boolean isEmpty() Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java?rev=239600r1=239599r2=239600view=diff == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java Wed Aug 24 04:08:23 2005 @@ -70,6 +70,18 @@ AbstractConfiguration config = getConfiguration(); config.addPropertyDirect(key3, value3); assertEquals(key3, value3, config.getProperty(key3)); + +config.addPropertyDirect(key3, value4); +config.addPropertyDirect(key3, value5); +List list = config.getList(key3); +assertNotNull(no list found for the 'key3' property, list); + +List expected = new ArrayList(); +expected.add(value3); +expected.add(value4); +expected.add(value5); + +ListAssert.assertEquals(values for the 'key3' property, expected, list); } public void testIsEmpty() Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?rev=239600r1=239599r2=239600view=diff == --- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original) +++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Wed Aug 24 04:08:23 2005 @@ -23,6 +23,10 @@ body release version=1.2-dev date=in SVN + action dev=ebourg type=update issue=35945 due-to=Steve Bate +Fixed MapConfiguration to store the list of values added under a same +key instead of the last value added. + /action action dev=oheger type=update issue=35316 Fixed a bug in the handling of relative file names in ConfigurationFactory: In most cases relative file names were not resolved relative to the @@ -122,7 +126,7 @@ strategy, so no reload was performed. /action action dev=oheger type=update issue=34410 -Disabled auto save mode during PropertiesCconfiguration.load(). Prior +Disabled auto save mode during
svn commit: r239602 - /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java
Author: ebourg Date: Wed Aug 24 04:15:27 2005 New Revision: 239602 URL: http://svn.apache.org/viewcvs?rev=239602view=rev Log: Code simplification in BaseConfiguration Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java?rev=239602r1=239601r2=239602view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/BaseConfiguration.java Wed Aug 24 04:15:27 2005 @@ -1,5 +1,5 @@ /* - * Copyright 2001-2004 The Apache Software Foundation. + * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the License) * you may not use this file except in compliance with the License. @@ -16,10 +16,10 @@ package org.apache.commons.configuration; +import java.util.ArrayList; import java.util.Iterator; -import java.util.Map; import java.util.List; -import java.util.ArrayList; +import java.util.Map; import org.apache.commons.collections.map.LinkedMap; @@ -53,54 +53,33 @@ private Map store = new LinkedMap(); /** - * Empty constructor. You must add all the values to this configuration. - */ -public BaseConfiguration() -{ -super(); -} - -/** * Adds a key/value pair to the map. This routine does no magic morphing. * It ensures the keylist is maintained * * @param key key to use for mapping - * @param obj object to store + * @param value object to store */ -protected void addPropertyDirect(String key, Object obj) +protected void addPropertyDirect(String key, Object value) { -Object o = getProperty(key); -Object objAdd = null; +Object previousValue = getProperty(key); -if (o == null) +if (previousValue == null) { -objAdd = obj; +store.put(key, value); } -else +else if (previousValue instanceof List) { -if (o instanceof List) -{ -((List) o).add(obj); -} -else -{ -// The token key is not a list. -List list = new ArrayList(); - -// There is an element. Put it into the list -// at the first position -list.add(o); - -// Now gobble up the supplied object -list.add(obj); - -objAdd = list; -} +// the value is added to the existing list +((List) previousValue).add(value); } - -if (objAdd != null) +else { -store.put(key, objAdd); +// the previous value is replaced by a list containing the previous value and the new value +List list = new ArrayList(); +list.add(previousValue); +list.add(value); + +store.put(key, list); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r239611 - in /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration: ConfigurationUtils.java plist/XMLPropertyListConfiguration.java
Author: ebourg Date: Wed Aug 24 04:38:04 2005 New Revision: 239611 URL: http://svn.apache.org/viewcvs?rev=239611view=rev Log: Fixed compilation errors with the JDK 1.3 Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java?rev=239611r1=239610r2=239611view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java Wed Aug 24 04:38:04 2005 @@ -38,9 +38,6 @@ { /** Constant for the file URL protocol.*/ static final String PROTOCOL_FILE = file; - -/** Constant for the URL encoding to be used.*/ -static final String ENCODING = UTF-8; private static Log log = LogFactory.getLog(ConfigurationUtils.class); @@ -486,19 +483,11 @@ { if (PROTOCOL_FILE.equals(url.getProtocol())) { -try -{ -return new File(URLDecoder.decode(url.getPath(), ENCODING)); -} -catch (UnsupportedEncodingException uex) -{ -// should normally not happen -return null; -} +return new File(URLDecoder.decode(url.getPath())); } else { return null; } } -} \ No newline at end of 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=239611r1=239610r2=239611view=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 Wed Aug 24 04:38:04 2005 @@ -225,7 +225,7 @@ XMLPropertyListConfiguration config = new XMLPropertyListConfiguration(); // add it to the ArrayNode -ArrayNode node = (ArrayNode) digester.peek(); +ArrayNode node = (ArrayNode) getDigester().peek(); node.addValue(config); // push the root on the stack - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r227018 [2/2] - in /jakarta/commons/proper/configuration/trunk: ./ conf/ src/java/org/apache/commons/configuration/ src/java/org/apache/commons/configuration/plist/ src/test/org/apache/commons/configuration/plist/ xdocs/
Added: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java?rev=227018view=auto == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java (added) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/SimpleCharStream.java Tue Aug 2 07:43:20 2005 @@ -0,0 +1,401 @@ +/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 3.0 */ +package org.apache.commons.configuration.plist; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (without unicode processing). + */ + +class SimpleCharStream +{ + public static final boolean staticFlag = false; + int bufsize; + int available; + int tokenBegin; + public int bufpos = -1; + protected int bufline[]; + protected int bufcolumn[]; + + protected int column = 0; + protected int line = 1; + + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; + + protected java.io.Reader inputStream; + + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int inBuf = 0; + + protected void ExpandBuff(boolean wrapAround) + { + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; + + try + { +if (wrapAround) +{ + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, + bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos += (bufsize - tokenBegin)); +} +else +{ + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos -= tokenBegin); +} + } + catch (Throwable t) + { +throw new Error(t.getMessage()); + } + + + bufsize += 2048; + available = bufsize; + tokenBegin = 0; + } + + protected void FillBuff() throws java.io.IOException + { + if (maxNextCharInd == available) + { +if (available == bufsize) +{ + if (tokenBegin 2048) + { + bufpos = maxNextCharInd = 0; + available = tokenBegin; + } + else if (tokenBegin 0) + bufpos = maxNextCharInd = 0; + else + ExpandBuff(false); +} +else if (available tokenBegin) + available = bufsize; +else if ((tokenBegin - available) 2048) + ExpandBuff(true); +else + available = tokenBegin; + } + + int i; + try { +if ((i = inputStream.read(buffer, maxNextCharInd, +available - maxNextCharInd)) == -1) +{ + inputStream.close(); + throw new java.io.IOException(); +} +else + maxNextCharInd += i; +return; + } + catch(java.io.IOException e) { +--bufpos; +backup(0); +if (tokenBegin == -1) + tokenBegin = bufpos; +throw e; + } + } + + public char BeginToken() throws java.io.IOException + { + tokenBegin = -1; + char c = readChar(); + tokenBegin = bufpos; + + return c; + } + + protected void UpdateLineColumn(char c) + { + column++; + + if (prevCharIsLF) + { +prevCharIsLF = false; +line += (column = 1); + } + else if (prevCharIsCR) + { +prevCharIsCR = false; +if (c == '\n') +{ + prevCharIsLF = true; +} +else + line += (column = 1); + } + + switch (c) + { +
svn commit: r227019 - in /jakarta/commons/proper/configuration/trunk: conf/test.plist.xml src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java
Author: ebourg Date: Tue Aug 2 07:58:15 2005 New Revision: 227019 URL: http://svn.apache.org/viewcvs?rev=227019view=rev Log: Fixed the version of the property list (1.1 - 1.0) Modified: jakarta/commons/proper/configuration/trunk/conf/test.plist.xml jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java Modified: jakarta/commons/proper/configuration/trunk/conf/test.plist.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/conf/test.plist.xml?rev=227019r1=227018r2=227019view=diff == --- jakarta/commons/proper/configuration/trunk/conf/test.plist.xml (original) +++ jakarta/commons/proper/configuration/trunk/conf/test.plist.xml Tue Aug 2 07:58:15 2005 @@ -1,6 +1,6 @@ ?xml version=1.0? !DOCTYPE plist SYSTEM file://localhost/System/Library/DTDs/PropertyList.dtd -plist version=1.1 +plist version=1.0 dict keystring/key 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=227019r1=227018r2=227019view=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 Tue Aug 2 07:58:15 2005 @@ -55,7 +55,7 @@ * pre * lt;?xml version=1.0? * lt;!DOCTYPE plist SYSTEM file://localhost/System/Library/DTDs/PropertyList.dtd - * lt;plist version=1.1 + * lt;plist version=1.0 * lt;dict * lt;keystringlt;/key * lt;stringvalue1lt;/string @@ -283,7 +283,7 @@ } writer.println(!DOCTYPE plist SYSTEM \file://localhost/System/Library/DTDs/PropertyList.dtd\); -writer.println(plist version=\1.1\); +writer.println(plist version=\1.0\); printNode(writer, 1, getRoot()); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r227028 - in /jakarta/commons/proper/configuration/trunk: project.xml src/java/org/apache/commons/configuration/HierarchicalConfiguration.java src/test/org/apache/commons/configuration/TestHierarchicalConfiguration.java xdocs/changes.xml
Author: ebourg Date: Tue Aug 2 08:45:55 2005 New Revision: 227028 URL: http://svn.apache.org/viewcvs?rev=227028view=rev Log: getKeys() in HierarchicalConfiguration now returns an iterator over an ordered set, this implies an upgrade of the dependency on Commons Collections (3.0 - 3.1) (Bug 35903) New Node constructor (name/value) Removed the default constuctor from HierarchicalConfiguration Modified: jakarta/commons/proper/configuration/trunk/project.xml jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestHierarchicalConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/project.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/project.xml?rev=227028r1=227027r2=227028view=diff == --- jakarta/commons/proper/configuration/trunk/project.xml (original) +++ jakarta/commons/proper/configuration/trunk/project.xml Tue Aug 2 08:45:55 2005 @@ -198,7 +198,7 @@ dependency groupIdcommons-collections/groupId artifactIdcommons-collections/artifactId - version3.0/version + version3.1/version properties war.bundletrue/war.bundle /properties Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java?rev=227028r1=227027r2=227028view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java Tue Aug 2 08:45:55 2005 @@ -19,7 +19,6 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -27,6 +26,7 @@ import java.util.Stack; import org.apache.commons.collections.map.LinkedMap; +import org.apache.commons.collections.set.ListOrderedSet; import org.apache.commons.lang.StringUtils; /** @@ -92,8 +92,7 @@ * @version $Id: HierarchicalConfiguration.java,v 1.14 2004/12/02 22:05:52 * ebourg Exp $ */ -public class HierarchicalConfiguration extends AbstractConfiguration implements -Cloneable +public class HierarchicalConfiguration extends AbstractConfiguration implements Serializable, Cloneable { /** Constant for a new dummy key. */ private static final String NEW_KEY = newKey; @@ -102,14 +101,6 @@ private Node root = new Node(); /** - * Creates a new instance of codeHierarchicalConfiguration/code. - */ -public HierarchicalConfiguration() -{ -super(); -} - -/** * Returns the root node of this hierarchical configuration. * * @return the root node @@ -421,8 +412,8 @@ } /** - * pReturns an iterator with all keys defined in this configuration./p - * pNote that the keys returned by this method will not contain any + * Returns an iterator with all keys defined in this configuration. + * Note that the keys returned by this method will not contain any * indices. This means that some structure will be lost./p * * @return an iterator with the defined keys in this configuration @@ -431,6 +422,7 @@ { DefinedKeysVisitor visitor = new DefinedKeysVisitor(); getRoot().visit(visitor, new ConfigurationKey()); + return visitor.getKeyList().iterator(); } @@ -523,13 +515,13 @@ * * @param keyPart the configuration key iterator * @param node the actual node - * @param data here the found nodes are stored + * @param nodes here the found nodes are stored */ -protected void findPropertyNodes(ConfigurationKey.KeyIterator keyPart, Node node, Collection data) +protected void findPropertyNodes(ConfigurationKey.KeyIterator keyPart, Node node, Collection nodes) { if (!keyPart.hasNext()) { -data.add(node); +nodes.add(node); } else { @@ -540,14 +532,14 @@ if (keyPart.getIndex() children.size() keyPart.getIndex() = 0) { findPropertyNodes((ConfigurationKey.KeyIterator) keyPart.clone(), (Node) children.get(keyPart -.getIndex()), data); +.getIndex()), nodes); } } else
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
Author: ebourg Date: Wed Jul 27 03:01:31 2005 New Revision: 225487 URL: http://svn.apache.org/viewcvs?rev=225487view=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=225487r1=225486r2=225487view=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=225487r1=225486r2=225487view=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=225487r1=225486r2=225487view=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
svn commit: r225522 - in /jakarta/commons/proper/configuration/trunk: ./ conf/ src/java/org/apache/commons/configuration/ src/test/org/apache/commons/configuration/ xdocs/
Author: ebourg Date: Wed Jul 27 07:12:59 2005 New Revision: 225522 URL: http://svn.apache.org/viewcvs?rev=225522view=rev Log: PropertiesConfiguration now supports all key/value separators supported by java.util.Properties (Bug 29171) PropertiesConfiguration now supports escaped key/value separators in the keys (Bug 29192). Updated the dependency on Commons Lang (2.1 instead of 2.0) Modified: jakarta/commons/proper/configuration/trunk/conf/test.properties jakarta/commons/proper/configuration/trunk/project.xml 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=225522r1=225521r2=225522view=diff == --- jakarta/commons/proper/configuration/trunk/conf/test.properties (original) +++ jakarta/commons/proper/configuration/trunk/conf/test.properties Wed Jul 27 07:12:59 2005 @@ -75,6 +75,25 @@ test.path = C:\\path3\\\ complex\\test\\ +# +# Test for the comment lines +# #comment = this is not a property but a comment line starting with '#' !comment = this is not a property but a comment line starting with '!' + +# +# Tests for the key/value separators ('=', ':' or white space, escaped or not) +# + +test.separator\=in.key = foo +test.separator\:in.key = bar +test.separator\in.key = foo +test.separator\in.key = bar +test.separator\ in.key = foo + +test.separator.equal = foo +test.separator.colon : foo +test.separator.tab foo +test.separator.formfeedfoo +test.separator.whitespace foo Modified: jakarta/commons/proper/configuration/trunk/project.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/project.xml?rev=225522r1=225521r2=225522view=diff == --- jakarta/commons/proper/configuration/trunk/project.xml (original) +++ jakarta/commons/proper/configuration/trunk/project.xml Wed Jul 27 07:12:59 2005 @@ -209,7 +209,7 @@ dependency groupIdcommons-lang/groupId artifactIdcommons-lang/artifactId - version2.0/version + version2.1/version properties war.bundletrue/war.bundle /properties 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=225522r1=225521r2=225522view=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 07:12:59 2005 @@ -29,6 +29,7 @@ import java.util.Iterator; import java.util.List; +import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; @@ -42,14 +43,24 @@ * added and later saved. include statements are (obviously) not supported * if you don't construct a PropertyConfiguration from a file. * - * pThe properties file syntax is explained here: + * pThe properties file syntax is explained here, basically it follows + * the syntax of the stream parsed by [EMAIL PROTECTED] java.util.Properties#load} and + * adds several useful extensions: * * ul * li - * Each property has the syntax codekey = value/code + * Each property has the syntax codekey lt;separator value/code. The + * separators accepted are code'='/code, code':'/code and any white + * space character. Examples: + * pre + * key1 = value1 + * key2 : value2 + * key3 value3/pre * /li * li - * The ikey/i may use any character but the equal sign '='. + * The ikey/i may use any character, separators must be escaped: + * pre + * key\:foo = bar/pre * /li * li * ivalue/i may be separated on different lines if a backslash @@ -108,7 +119,7 @@ * tokens_on_multiple_lines = second token * * # commas may be escaped in tokens - * commas.excaped = Hi\, what'up? + * commas.escaped = Hi\, what'up? * * # properties can reference other properties * base.prop = /base @@ -116,7 +127,8 @@ * second.prop = ${first.prop}/second * /pre * - * @author a href=mailto:[EMAIL PROTECTED]Emmanuel Bourg/a + * @see java.util.Properties#load + * * @author a href=mailto:[EMAIL PROTECTED]Stefano Mazzocchi
svn commit: r225536 - in /jakarta/commons/proper/configuration/trunk: conf/ src/java/org/apache/commons/configuration/ src/test/org/apache/commons/configuration/ xdocs/
Author: ebourg Date: Wed Jul 27 08:36:40 2005 New Revision: 225536 URL: http://svn.apache.org/viewcvs?rev=225536view=rev Log: ConfigurationFactory now generates a XMLPropertyConfiguration on properties elements with a filename ending with .xml Modified: jakarta/commons/proper/configuration/trunk/conf/testDigesterConfiguration.xml jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationFactory.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationFactory.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/conf/testDigesterConfiguration.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/conf/testDigesterConfiguration.xml?rev=225536r1=225535r2=225536view=diff == --- jakarta/commons/proper/configuration/trunk/conf/testDigesterConfiguration.xml (original) +++ jakarta/commons/proper/configuration/trunk/conf/testDigesterConfiguration.xml Wed Jul 27 08:36:40 2005 @@ -2,5 +2,6 @@ configuration properties fileName=conf/test.properties/ + properties fileName=conf/test.properties.xml/ xml fileName=conf/test.xml/ /configuration Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationFactory.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationFactory.java?rev=225536r1=225535r2=225536view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationFactory.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationFactory.java Wed Jul 27 08:36:40 2005 @@ -280,7 +280,7 @@ setupDigesterInstance( digester, matchString + properties, -new FileConfigurationFactory(PropertiesConfiguration.class), +new PropertiesConfigurationFactory(), null, additional); @@ -335,16 +335,16 @@ { setupUnionRules(digester, matchString); } + digester.addFactoryCreate(matchString, factory); digester.addSetProperties(matchString); + if (method != null) { digester.addCallMethod(matchString, method); } -digester.addSetNext( -matchString, -addConfiguration, -Configuration.class.getName()); + +digester.addSetNext(matchString, addConfiguration, Configuration.class.getName()); } /** @@ -492,7 +492,7 @@ */ public Object createObject(Attributes attributes) throws Exception { -FileConfiguration conf = (FileConfiguration) super.createObject(attributes); +FileConfiguration conf = createConfiguration(attributes); conf.setBasePath(getBasePath()); conf.setFileName(attributes.getValue(ATTR_FILENAME)); try @@ -500,9 +500,9 @@ log.info(Trying to load configuration + conf.getFileName()); conf.load(); } -catch(ConfigurationException cex) +catch (ConfigurationException cex) { -if(attributes.getValue(ATTR_OPTIONAL) != null +if (attributes.getValue(ATTR_OPTIONAL) != null PropertyConverter.toBoolean(attributes.getValue(ATTR_OPTIONAL)).booleanValue()) { log.warn(Could not load optional configuration + conf.getFileName()); @@ -513,6 +513,39 @@ } } return conf; +} + +protected FileConfiguration createConfiguration(Attributes attributes) throws Exception +{ +return (FileConfiguration) super.createObject(attributes); +} +} + +/** + * A factory that returns an XMLPropertiesConfiguration for .xml files + * and a PropertiesConfiguration for the others. + * + * @since 1.2 + */ +public class PropertiesConfigurationFactory extends FileConfigurationFactory +{ +public PropertiesConfigurationFactory() +{ +super(null); +} + +protected FileConfiguration createConfiguration(Attributes attributes) throws Exception +{ +String filename = attributes.getValue(ATTR_FILENAME); + +if (filename != null filename.toLowerCase().trim().endsWith(.xml)) +{ +return new XMLPropertiesConfiguration(); +} +else +{ +return new PropertiesConfiguration(); +} } } Modified
svn commit: r165618 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/XMLPropertiesConfiguration.java xdocs/changes.xml
Author: ebourg Date: Mon May 2 03:55:17 2005 New Revision: 165618 URL: http://svn.apache.org/viewcvs?rev=165618view=rev Log: Removed the dependency on Digester for XMLPropertiesConfiguration (contributed by Alistair Young) Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLPropertiesConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLPropertiesConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLPropertiesConfiguration.java?rev=165618r1=165617r2=165618view=diff == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLPropertiesConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLPropertiesConfiguration.java Mon May 2 03:55:17 2005 @@ -1,5 +1,5 @@ /* - * Copyright 2004 The Apache Software Foundation. + * Copyright 2004-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the License) * you may not use this file except in compliance with the License. @@ -23,12 +23,17 @@ import java.net.URL; import java.util.Iterator; import java.util.List; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; -import org.apache.commons.digester.Digester; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; + +import org.xml.sax.Attributes; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; /** * This configuration implements the XML properties format introduced in Java @@ -44,17 +49,17 @@ * lt;entry key=key2value2lt;/entry * lt;entry key=key3value3lt;/entry * lt;/properties - * lt;/pre - * + * /pre + * * The Java 5.0 runtime is not required to use this class. The default encoding * for this configuration format is UTF-8. Note that unlike * codePropertiesConfiguration/code, codeXMLPropertiesConfiguration/code * does not support includes. * - * @since 1.1 - * * @author Emmanuel Bourg + * @author Alistair Young * @version $Revision$, $Date$ + * @since 1.1 */ public class XMLPropertiesConfiguration extends PropertiesConfiguration { @@ -121,35 +126,31 @@ public void load(Reader in) throws ConfigurationException { -// todo: replace with a pure SAX implementation to reduce the dependencies - -// set up the digester -Digester digester = new Digester(); -digester.setEntityResolver(new EntityResolver(){ -public InputSource resolveEntity(String publicId, String systemId) -{ -return new InputSource(getClass().getClassLoader().getResourceAsStream(properties.dtd)); -} -}); - -digester.addCallMethod(properties/comment, setHeader, 0); - -digester.addCallMethod(properties/entry, addProperty, 2); -digester.addCallParam(properties/entry, 0, key); -digester.addCallParam(properties/entry, 1); - -// todo: support included properties ? +SAXParserFactory factory = SAXParserFactory.newInstance(); +factory.setNamespaceAware(false); +factory.setValidating(true); -// parse the file -digester.push(this); try { -digester.parse(in); +SAXParser parser = factory.newSAXParser(); + +XMLReader xmlReader = parser.getXMLReader(); +xmlReader.setEntityResolver(new EntityResolver() +{ +public InputSource resolveEntity(String publicId, String systemId) +{ +return new InputSource(getClass().getClassLoader().getResourceAsStream(properties.dtd)); +} +}); +xmlReader.setContentHandler(new XMLPropertiesHandler()); +xmlReader.parse(new InputSource(in)); } catch (Exception e) { throw new ConfigurationException(Unable to parse the configuration file, e); } + +// todo: support included properties ? } public void save(Writer out) throws ConfigurationException @@ -218,4 +219,68 @@ writeProperty(out, key, values.get(i)); } } -} + +/** + * SAX Handler to parse a XML properties file. + * + * @author Alistair Young + * @since 1.2 + */ +private class XMLPropertiesHandler extends DefaultHandler +{ +/** The key of the current entry being parsed. */ +private String key; + +/** The value of the current entry being parsed. */ +private StringBuffer value = new
svn commit: r161261 - jakarta/commons/proper/configuration/trunk/project.xml
Author: ebourg Date: Thu Apr 14 05:11:33 2005 New Revision: 161261 URL: http://svn.apache.org/viewcvs?view=revrev=161261 Log: Updated the project descriptor to use the commons-logging-api artifact instead of commons-logging and the groupId/artifactId tags instead of id (suggested by Brett Porter) Modified: jakarta/commons/proper/configuration/trunk/project.xml Modified: jakarta/commons/proper/configuration/trunk/project.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/project.xml?view=diffr1=161260r2=161261 == --- jakarta/commons/proper/configuration/trunk/project.xml (original) +++ jakarta/commons/proper/configuration/trunk/project.xml Thu Apr 14 05:11:33 2005 @@ -161,11 +161,11 @@ /developer developer - nameOliver Heger/name - idoheger/id - email[EMAIL PROTECTED]/email - organizationUniversity Marburg/organization - timezone+1/timezone + nameOliver Heger/name + idoheger/id + email[EMAIL PROTECTED]/email + organizationUniversity Marburg/organization + timezone+1/timezone /developer /developers @@ -216,7 +216,7 @@ dependency groupIdcommons-logging/groupId - artifactIdcommons-logging/artifactId + artifactIdcommons-logging-api/artifactId version1.0.4/version properties war.bundletrue/war.bundle @@ -271,7 +271,8 @@ /dependency dependency - idservletapi/id + groupIdservletapi/groupId + artifactIdservletapi/artifactId version2.3/version /dependency @@ -320,12 +321,14 @@ /dependency dependency - idmockobjects:mockobjects-core/id + groupIdmockobjects/groupId + artifactIdmockobjects-core/artifactId version0.09/version /dependency dependency - idmockobjects:mockobjects-jdk1.4-j2ee1.3/id + groupIdmockobjects/groupId + artifactIdmockobjects-jdk1.4-j2ee1.3/artifactId version0.09/version /dependency - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r161262 - jakarta/commons/proper/configuration/trunk/project.xml
Author: ebourg Date: Thu Apr 14 05:21:33 2005 New Revision: 161262 URL: http://svn.apache.org/viewcvs?view=revrev=161262 Log: Added the Maven2 property scopetest/scope on the test dependencies Modified: jakarta/commons/proper/configuration/trunk/project.xml Modified: jakarta/commons/proper/configuration/trunk/project.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/project.xml?view=diffr1=161261r2=161262 == --- jakarta/commons/proper/configuration/trunk/project.xml (original) +++ jakarta/commons/proper/configuration/trunk/project.xml Thu Apr 14 05:21:33 2005 @@ -282,60 +282,70 @@ groupIdspice/groupId artifactIdspice-jndikit/artifactId version1.1/version + scopetest/scope /dependency dependency groupIdcommons-dbcp/groupId artifactIdcommons-dbcp/artifactId version1.1/version + scopetest/scope /dependency dependency groupIdcommons-pool/groupId artifactIdcommons-pool/artifactId version1.1/version + scopetest/scope /dependency dependency groupIdhsqldb/groupId artifactIdhsqldb/artifactId version1.7.2.2/version + scopetest/scope /dependency dependency groupIddbunit/groupId artifactIddbunit/artifactId version2.1/version + scopetest/scope /dependency dependency groupIdjunit/groupId artifactIdjunit/artifactId version3.8.1/version + scopetest/scope /dependency dependency groupIdjunit-addons/groupId artifactIdjunit-addons/artifactId version1.4/version + scopetest/scope /dependency dependency groupIdmockobjects/groupId artifactIdmockobjects-core/artifactId version0.09/version + scopetest/scope /dependency dependency groupIdmockobjects/groupId artifactIdmockobjects-jdk1.4-j2ee1.3/artifactId version0.09/version + scopetest/scope /dependency !-- Fake dependency to test loading configuration files from a JAR -- dependency idresources/id version1.0/version + scopetest/scope /dependency dependency - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r160160 - in jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/XMLConfiguration.java xdocs/changes.xml
Author: ebourg Date: Tue Apr 5 04:32:14 2005 New Revision: 160160 URL: http://svn.apache.org/viewcvs?view=revrev=160160 Log: Fixed XMLConfiguration to use the delimiter set by setDelimiter() instead of the private ATTR_DELIMITER variable (thanks to Zsolt Koppany for spotting this issue) Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLConfiguration.java?view=diffr1=160159r2=160160 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLConfiguration.java Tue Apr 5 04:32:14 2005 @@ -70,9 +70,6 @@ /** Constant for the default root element name. */ private static final String DEFAULT_ROOT_NAME = configuration; -/** Delimiter character for attributes. */ -private static char ATTR_DELIMITER = ','; - private FileConfigurationDelegate delegate = new FileConfigurationDelegate(); /** The document from this configuration's data source. */ @@ -288,7 +285,7 @@ if (w3cNode instanceof Attr) { Attr attr = (Attr) w3cNode; -for (Iterator it = PropertyConverter.split(attr.getValue(), ATTR_DELIMITER).iterator(); it.hasNext();) +for (Iterator it = PropertyConverter.split(attr.getValue(), getDelimiter()).iterator(); it.hasNext();) { Node child = new XMLNode(ConfigurationKey.constructAttributeKey(attr.getName()), element); child.setValue(it.next()); @@ -365,7 +362,19 @@ public void load(InputStream in) throws ConfigurationException { -delegate.load(in); +try +{ +DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); +Document newDocument = builder.parse(new InputSource(in)); +Document oldDocument = document; +document = null; +initProperties(newDocument, oldDocument == null); +document = (oldDocument == null) ? newDocument : oldDocument; +} +catch (Exception e) +{ +throw new ConfigurationException(e.getMessage(), e); +} } public void load(InputStream in, String encoding) throws ConfigurationException @@ -782,7 +791,7 @@ { if (buf.length() 0) { -buf.append(ATTR_DELIMITER); +buf.append(getDelimiter()); } buf.append(attr.getValue()); } Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?view=diffr1=160159r2=160160 == --- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original) +++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Tue Apr 5 04:32:14 2005 @@ -22,7 +22,10 @@ body -release version=1.2-dev date=in CVS +release version=1.2-dev date=in SVN + action dev=ebourg type=update due-to=Zsolt Koppany +XMLConfiguration now uses the delimiter set by setDelimiter(char). + /action /release release version=1.1 date=2005-04-02 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r160161 - in jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/XMLConfiguration.java xdocs/changes.xml
Author: ebourg Date: Tue Apr 5 04:49:27 2005 New Revision: 160161 URL: http://svn.apache.org/viewcvs?view=revrev=160161 Log: XMLConfiguration now parse the configuration using the encoding declared in the XML header instead of the OS default encoding. Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLConfiguration.java?view=diffr1=160160r2=160161 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/XMLConfiguration.java Tue Apr 5 04:49:27 2005 @@ -840,6 +840,11 @@ private class FileConfigurationDelegate extends AbstractFileConfiguration { +public void load(InputStream in) throws ConfigurationException +{ +XMLConfiguration.this.load(in); +} + public void load(Reader in) throws ConfigurationException { XMLConfiguration.this.load(in); Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?view=diffr1=160160r2=160161 == --- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original) +++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Tue Apr 5 04:49:27 2005 @@ -23,6 +23,10 @@ body release version=1.2-dev date=in SVN + action dev=ebourg type=update due-to=Kunihara Tetsuya issue=34204 +XMLConfiguration now parse the configuration using the encoding +declared in the XML header instead of the OS default encoding. + /action action dev=ebourg type=update due-to=Zsolt Koppany XMLConfiguration now uses the delimiter set by setDelimiter(char). /action - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r158491 - in jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/AbstractConfiguration.java src/test/org/apache/commons/configuration/TestBaseConfiguration.java xdocs/changes.xml
Author: ebourg Date: Mon Mar 21 09:58:56 2005 New Revision: 158491 URL: http://svn.apache.org/viewcvs?view=revrev=158491 Log: Fix for bug 34104, resolveContainerStore now returns the first element of array properties Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml 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?view=diffr1=158490r2=158491 == --- 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 Mar 21 09:58:56 2005 @@ -906,11 +906,55 @@ protected Object resolveContainerStore(String key) { Object value = getProperty(key); -if (value != null value instanceof List) +if (value != null) { -List list = (List) value; -value = list.isEmpty() ? null : list.get(0); +if (value instanceof List) +{ +List list = (List) value; +value = list.isEmpty() ? null : list.get(0); +} +else if (value instanceof Object[]) +{ +Object[] array = (Object[]) value; +value = array.length == 0 ? null : array[0]; +} +else if (value instanceof boolean[]) +{ +boolean[] array = (boolean[]) value; +value = array.length == 0 ? null : new Boolean(array[0]); +} +else if (value instanceof byte[]) +{ +byte[] array = (byte[]) value; +value = array.length == 0 ? null : new Byte(array[0]); +} +else if (value instanceof short[]) +{ +short[] array = (short[]) value; +value = array.length == 0 ? null : new Short(array[0]); +} +else if (value instanceof int[]) +{ +int[] array = (int[]) value; +value = array.length == 0 ? null : new Integer(array[0]); +} +else if (value instanceof long[]) +{ +long[] array = (long[]) value; +value = array.length == 0 ? null : new Long(array[0]); +} +else if (value instanceof float[]) +{ +float[] array = (float[]) value; +value = array.length == 0 ? null : new Float(array[0]); +} +else if (value instanceof double[]) +{ +double[] array = (double[]) value; +value = array.length == 0 ? null : new Double(array[0]); +} } + return value; } Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java?view=diffr1=158490r2=158491 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestBaseConfiguration.java Mon Mar 21 09:58:56 2005 @@ -623,4 +623,44 @@ assertEquals(long value, 0xL, config.getBigInteger(number).longValue()); } +public void testResolveContainerStore() +{ +AbstractConfiguration config = new BaseConfiguration(); + +// array of objects +config.addPropertyDirect(array, new String[] { foo, bar }); + +assertEquals(first element of the 'array' property, foo, config.resolveContainerStore(array)); + +// list of objects +List list = new ArrayList(); +list.add(foo); +list.add(bar); +config.addPropertyDirect(list, list); + +assertEquals(first element of the 'list' property, foo, config.resolveContainerStore(list)); + +// arrays of primitives +config.addPropertyDirect(array.boolean, new boolean[] { true, false }); +assertEquals(first element of the 'array.boolean' property, true, config.getBoolean(array.boolean)); + +config.addPropertyDirect(array.byte, new byte[] { 1, 2
svn commit: r156639 - in jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/AbstractConfiguration.java src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java src/test/org/apache/commons/configuration/TestSubsetConfiguration.java xdocs/changes.xml
Author: ebourg Date: Wed Mar 9 04:50:07 2005 New Revision: 156639 URL: http://svn.apache.org/viewcvs?view=revrev=156639 Log: Fixed a ConcurrentModificationException thrown when calling clear() on a SubsetConfiguration applied to a BaseConfiguration. Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubsetConfiguration.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml 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?view=diffr1=156638r2=156639 == --- 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 Wed Mar 9 04:50:07 2005 @@ -261,7 +261,14 @@ Iterator it = getKeys(); while (it.hasNext()) { -clearProperty((String) it.next()); +String key = (String) it.next(); +it.remove(); + +if (containsKey(key)) +{ +// workaround for Iterators that do not remove the property on calling remove() +clearProperty(key); +} } } Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java?view=diffr1=156638r2=156639 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDatabaseConfiguration.java Wed Mar 9 04:50:07 2005 @@ -44,6 +44,8 @@ { public final String DATABASE_DRIVER = org.hsqldb.jdbcDriver; public final String DATABASE_URL = jdbc:hsqldb:target/test-classes/testdb; +public final String DATABASE_USERNAME = sa; +public final String DATABASE_PASSWORD = ; private static HsqlDB hsqlDB = null; @@ -67,8 +69,8 @@ BasicDataSource datasource = new BasicDataSource(); datasource.setDriverClassName(DATABASE_DRIVER); datasource.setUrl(DATABASE_URL); -datasource.setUsername(sa); -datasource.setPassword(); +datasource.setUsername(DATABASE_USERNAME); +datasource.setPassword(DATABASE_PASSWORD); this.datasource = datasource; @@ -118,7 +120,7 @@ public void testGetPropertyDirectSingle() { -DatabaseConfiguration config = new DatabaseConfiguration(datasource, configuration, key, value); +Configuration config = new DatabaseConfiguration(datasource, configuration, key, value); assertEquals(property1, value1, config.getProperty(key1)); assertEquals(property2, value2, config.getProperty(key2)); @@ -127,7 +129,7 @@ public void testGetPropertyDirectMultiple() { -DatabaseConfiguration config = new DatabaseConfiguration(datasource, configurations, name, key, value, test); +Configuration config = new DatabaseConfiguration(datasource, configurations, name, key, value, test); assertEquals(property1, value1, config.getProperty(key1)); assertEquals(property2, value2, config.getProperty(key2)); @@ -136,7 +138,7 @@ public void testClearPropertySingle() { -DatabaseConfiguration config = new DatabaseConfiguration(datasource, configuration, key, value); +Configuration config = new DatabaseConfiguration(datasource, configuration, key, value); config.clearProperty(key); assertFalse(property not cleared, config.containsKey(key)); @@ -144,7 +146,7 @@ public void testClearPropertyMultiple() { -DatabaseConfiguration config = new DatabaseConfiguration(datasource, configurations, name, key, value, test); +Configuration config = new DatabaseConfiguration(datasource, configurations, name, key, value, test); config.clearProperty(key); assertFalse(property not cleared, config.containsKey(key)); @@ -152,7 +154,7 @@ public void testClearSingle() { -DatabaseConfiguration config = new DatabaseConfiguration(datasource, configuration, key, value
svn commit: r155945 - in jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java xdocs/changes.xml
Author: ebourg Date: Wed Mar 2 11:29:39 2005 New Revision: 155945 URL: http://svn.apache.org/viewcvs?view=revrev=155945 Log: Fixed updateLastModified() in FileChangedReloadingStrategy Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java?view=diffr1=155944r2=155945 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java Wed Mar 2 11:29:39 2005 @@ -1,5 +1,5 @@ /* - * Copyright 2001-2004 The Apache Software Foundation. + * Copyright 2001-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the License) * you may not use this file except in compliance with the License. @@ -16,8 +16,6 @@ package org.apache.commons.configuration.reloading; -import java.io.File; - import org.apache.commons.configuration.FileConfiguration; /** @@ -96,13 +94,11 @@ */ protected void updateLastModified() { -File file = new File(configuration.getFileName()); -lastModified = file.lastModified(); +lastModified = configuration.getFile().lastModified(); } /** - * Check if the configuration has changed since the last - * time it was loaded. + * Check if the configuration has changed since the last time it was loaded. */ protected boolean hasChanged() { Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?view=diffr1=155944r2=155945 == --- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original) +++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Wed Mar 2 11:29:39 2005 @@ -7,7 +7,22 @@ body -release version=1.1-dev date=in CVS +release version=1.1-rc2 date=in CVS + action dev=ebourg type=update +Fixed a bug in FileChangedReloadingStrategy preventing the detection +of a file change in some cases. + /action + action dev=ebourg type=update +Changed getXXXArray() and getXXXList() in DataConfiguration to return +an empty array/list for empty values. + /action + action dev=ebourg type=update issue=33524 +Fixed getLongArray(), getFloatArray() and getDoubleArray() in DataConfiguration, +the values were cast into integers. + /action +/release + +release version=1.1-rc1 date=2004-02-13 action dev=oheger type=add issue=33475 ConfigurationFactory now always configures digester to use the context classloader. This avoids problems in application server environments, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r155770 - jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java
Author: ebourg Date: Tue Mar 1 04:04:59 2005 New Revision: 155770 URL: http://svn.apache.org/viewcvs?view=revrev=155770 Log: Improved test coverage for FileChangedReloadingStrategy Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java?view=diffr1=155769r2=155770 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java Tue Mar 1 04:04:59 2005 @@ -48,10 +48,12 @@ // load the configuration PropertiesConfiguration config = new PropertiesConfiguration(target/testReload.properties); -config.setReloadingStrategy(new FileChangedReloadingStrategy()); +FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy(); +strategy.setRefreshDelay(500); +config.setReloadingStrategy(strategy); assertEquals(Initial value, value1, config.getString(string)); -Thread.sleep(5000); +Thread.sleep(2000); // change the file out = new FileWriter(file); @@ -61,6 +63,43 @@ // test the automatic reloading assertEquals(Modified value with enabled reloading, value2, config.getString(string)); +} + +public void testNewFileReloading() throws Exception +{ +// create a new configuration +File file = new File(target/testReload.properties); + +if (file.exists()) +{ +file.delete(); +} + +PropertiesConfiguration config = new PropertiesConfiguration(); +config.setFile(file); +FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy(); +strategy.setRefreshDelay(500); +config.setReloadingStrategy(strategy); + +assertNull(Initial value, config.getString(string)); + +// change the file +FileWriter out = new FileWriter(file); +out.write(string=value1); +out.flush(); +out.close(); + +Thread.sleep(2000); + +// test the automatic reloading +assertEquals(Modified value with enabled reloading, value1, config.getString(string)); +} + +public void testGetRefreshDelay() +{ +FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy(); +strategy.setRefreshDelay(500); +assertEquals(refresh delay, 500, strategy.getRefreshDelay()); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r153757 - in jakarta/commons/proper/configuration/trunk/src: java/org/apache/commons/configuration/DataConfiguration.java test/org/apache/commons/configuration/TestDataConfiguration.java test/org/apache/commons/configuration/TestPropertyConverter.java
Author: ebourg Date: Mon Feb 14 02:03:35 2005 New Revision: 153757 URL: http://svn.apache.org/viewcvs?view=revrev=153757 Log: Fixed getLongArray(), getFloatArray() and getDoubleArray() in DataConfiguration (Bug 33524) Changed getXXXArray() and getXXXList() to return an empty array/list for empty values Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDataConfiguration.java jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertyConverter.java Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java?view=diffr1=153756r2=153757 == --- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java (original) +++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DataConfiguration.java Mon Feb 14 02:03:35 2005 @@ -30,6 +30,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; /** * Decorator providing additional getters for any Configuration. This extended @@ -41,7 +42,7 @@ * version./p * * @author a href=[EMAIL PROTECTED]Emmanuel Bourg/a - * @version $Revision: 1.2 $, $Date: 2004/12/02 22:05:52 $ + * @version $Revision: 1.2 $, $Date$ * @since 1.1 */ public class DataConfiguration extends AbstractConfiguration @@ -131,7 +132,7 @@ List list = null; -if (value == null) +if (value == null || (value instanceof String StringUtils.isEmpty((String) value))) { list = defaultValue; } @@ -207,7 +208,7 @@ boolean[] array; -if (value == null) +if (value == null || (value instanceof String StringUtils.isEmpty((String) value))) { array = defaultValue; } @@ -281,7 +282,7 @@ List list = null; -if (value == null) +if (value == null || (value instanceof String StringUtils.isEmpty((String) value))) { list = defaultValue; } @@ -356,7 +357,7 @@ byte[] array; -if (value == null) +if (value == null || (value instanceof String StringUtils.isEmpty((String) value))) { array = defaultValue; } @@ -430,7 +431,7 @@ List list = null; -if (value == null) +if (value == null || (value instanceof String StringUtils.isEmpty((String) value))) { list = defaultValue; } @@ -505,7 +506,7 @@ short[] array; -if (value == null) +if (value == null || (value instanceof String StringUtils.isEmpty((String) value))) { array = defaultValue; } @@ -580,7 +581,7 @@ List list = null; -if (value == null) +if (value == null || (value instanceof String StringUtils.isEmpty((String) value))) { list = defaultValue; } @@ -655,7 +656,7 @@ int[] array; -if (value == null) +if (value == null || (value instanceof String StringUtils.isEmpty((String) value))) { array = defaultValue; } @@ -729,7 +730,7 @@ List list = null; -if (value == null) +if (value == null || (value instanceof String StringUtils.isEmpty((String) value))) { list = defaultValue; } @@ -804,7 +805,7 @@ long[] array; -if (value == null) +if (value == null || (value instanceof String StringUtils.isEmpty((String) value))) { array = defaultValue; } @@ -825,7 +826,7 @@ Iterator it = values.iterator(); while (it.hasNext()) { -array[i++] = PropertyConverter.toLong(it.next()).intValue(); +array[i++] = PropertyConverter.toLong(it.next()).longValue(); } } else @@ -834,7 +835,7 @@ { // attempt to convert a single value array = new long[1]; -array[0] = PropertyConverter.toLong(value).intValue(); +array[0] = PropertyConverter.toLong(value).longValue(); } catch (ConversionException e) { @@ -878,7 +879,7 @@ List list = null; -if (value == null) +if (value == null || (value instanceof String StringUtils.isEmpty((String) value))) { list = defaultValue
svn commit: r153777 - jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertyConverter.java
Author: ebourg Date: Mon Feb 14 03:54:15 2005 New Revision: 153777 URL: http://svn.apache.org/viewcvs?view=revrev=153777 Log: Removed a temporary test that wasn't supposed to be commited :) Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertyConverter.java Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertyConverter.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertyConverter.java?view=diffr1=153776r2=153777 == --- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertyConverter.java (original) +++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertyConverter.java Mon Feb 14 03:54:15 2005 @@ -71,8 +71,4 @@ assertEquals(3rd element, new Integer(3), it.next()); } -public void testToLong() -{ -assertEquals(81008931800 to long, 81008931800L, PropertyConverter.toLong(81008931800).longValue()); -} } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/xdocs changes.xml
ebourg 2004/12/14 09:03:51 Modified:configuration/src/java/org/apache/commons/configuration AbstractConfiguration.java HierarchicalConfiguration.java MapConfiguration.java PropertyConverter.java configuration/src/test/org/apache/commons/configuration TestBaseConfiguration.java TestBaseNullConfiguration.java configuration/xdocs changes.xml Added: configuration/src/test/org/apache/commons/configuration TestPropertyConverter.java Removed: configuration/src/test/org/apache/commons/configuration TestPropertiesTokenizer.java Log: Replaced the PropertyTokenizer inner class in AbstractConfiguration with the split method in PropertyConverter. Also moved the method building an iterator on the elements of a composite value in PropertyConverter as toIterator(). Revision ChangesPath 1.31 +4 -144 jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java Index: AbstractConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- AbstractConfiguration.java13 Dec 2004 16:40:14 - 1.30 +++ AbstractConfiguration.java14 Dec 2004 17:03:49 - 1.31 @@ -19,18 +19,13 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; import java.util.Properties; -import java.util.StringTokenizer; -import org.apache.commons.collections.IteratorUtils; import org.apache.commons.collections.Predicate; import org.apache.commons.collections.iterators.FilterIterator; -import org.apache.commons.collections.iterators.IteratorChain; -import org.apache.commons.collections.iterators.SingletonIterator; import org.apache.commons.lang.BooleanUtils; /** @@ -55,9 +50,6 @@ /** The property delimiter used while parsing (a comma). */ private static char DELIMITER = ','; -/** how big the initial arraylist for splitting up name value pairs */ -private static final int INITIAL_LIST_SIZE = 2; - /** * Whether the configuration should throw NoSuchElementExceptions or simply * return null when a property does not exist. Defaults to return null. @@ -108,69 +100,16 @@ /** * [EMAIL PROTECTED] */ -public void addProperty(String key, Object token) +public void addProperty(String key, Object value) { -for (Iterator it = fetchInsertIterator(token); it.hasNext();) +Iterator it = PropertyConverter.toIterator(value, DELIMITER); +while (it.hasNext()) { addPropertyDirect(key, it.next()); } } /** - * Determines all properties to be added to this configuration. This method - * is called by codeaddProperty()/code and codesetProperty()/code - * to obtain all values to be inserted. The passed in token is specially - * treated depending on its type: ulliStrings are checked for - * enumeration characters and splitted if necessary./liliFor - * collections the single elements are checked./liliArrays are - * treated like collections./liliAll other types are directly - * inserted./liliRecursive combinations are supported, e.g. a - * collection containing array that contain strings./li/ul - * - * @param token the token to be checked - * @return an iterator for the values to be inserted - */ -protected Iterator fetchInsertIterator(Object token) -{ -if (token == null) -{ -return IteratorUtils.emptyIterator(); -} -if (token instanceof String) -{ -return split((String) token).iterator(); -} -else if (token instanceof Collection) -{ -return fetchInsertIterator(((Collection) token).iterator()); -} -else if (token.getClass().isArray()) -{ -return fetchInsertIterator(IteratorUtils.arrayIterator(token)); -} -else -{ -return new SingletonIterator(token); -} -} - -/** - * Recursivle fetches an insert iterator if the token itself is a composite. - * - * @param iterator the iterator to be processed - * @return a chain iterator for all elements - */ -private Iterator fetchInsertIterator(Iterator iterator
cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration CompositeConfiguration.java JNDIConfiguration.java
ebourg 2004/12/02 07:50:09 Modified:configuration/src/java/org/apache/commons/configuration CompositeConfiguration.java JNDIConfiguration.java Log: Removed getProperty() from CompositeConfiguration and JNDIConfiguration since the implementation is the same in AbstractConfiguration Revision ChangesPath 1.21 +1 -9 jakarta-commons/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java Index: CompositeConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- CompositeConfiguration.java 18 Oct 2004 21:38:45 - 1.20 +++ CompositeConfiguration.java 2 Dec 2004 15:50:09 - 1.21 @@ -235,14 +235,6 @@ /** * [EMAIL PROTECTED] */ -public Object getProperty(String key) -{ -return getPropertyDirect(key); -} - -/** - * [EMAIL PROTECTED] - */ public void setProperty(String key, Object value) { clearProperty(key); 1.21 +1 -9 jakarta-commons/configuration/src/java/org/apache/commons/configuration/JNDIConfiguration.java Index: JNDIConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/JNDIConfiguration.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- JNDIConfiguration.java21 Oct 2004 18:36:14 - 1.20 +++ JNDIConfiguration.java2 Dec 2004 15:50:09 - 1.21 @@ -318,14 +318,6 @@ } /** - * [EMAIL PROTECTED] - */ -public Object getProperty(String key) -{ -return getPropertyDirect(key); -} - -/** * pstrongThis operation is not supported and will throw an * UnsupportedOperationException./strong/p * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration CompositeConfiguration.java
ebourg 2004/12/02 09:34:18 Modified:configuration/src/java/org/apache/commons/configuration CompositeConfiguration.java Log: Removed setProperty() from CompositeConfiguration since the implementation is the same in AbstractConfiguration Revision ChangesPath 1.22 +1 -10 jakarta-commons/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java Index: CompositeConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- CompositeConfiguration.java 2 Dec 2004 15:50:09 - 1.21 +++ CompositeConfiguration.java 2 Dec 2004 17:34:18 - 1.22 @@ -235,15 +235,6 @@ /** * [EMAIL PROTECTED] */ -public void setProperty(String key, Object value) -{ -clearProperty(key); -addProperty(key, value); -} - -/** - * [EMAIL PROTECTED] - */ public void clearProperty(String key) { for (Iterator i = configList.iterator(); i.hasNext();) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestAbstractConfiguration.java TestDatabaseConfiguration.java
ebourg 2004/12/02 14:05:53 Modified:configuration/src/java/org/apache/commons/configuration AbstractConfiguration.java AbstractFileConfiguration.java BaseConfiguration.java CompositeConfiguration.java DatabaseConfiguration.java DataConfiguration.java HierarchicalConfiguration.java JNDIConfiguration.java MapConfiguration.java SubsetConfiguration.java configuration/src/java/org/apache/commons/configuration/web AppletConfiguration.java ServletConfiguration.java ServletContextConfiguration.java ServletFilterConfiguration.java ServletRequestConfiguration.java configuration/src/test/org/apache/commons/configuration TestAbstractConfiguration.java TestDatabaseConfiguration.java Log: Removed the getPropertyDirect method from AbstractConfiguration, concrete configurations now implement directly the getProperty method from the Configuration interface. Revision ChangesPath 1.29 +6 -27 jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java Index: AbstractConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- AbstractConfiguration.java18 Oct 2004 21:38:45 - 1.28 +++ AbstractConfiguration.java2 Dec 2004 22:05:52 - 1.29 @@ -130,16 +130,6 @@ } /** - * Read property. Should return codenull/code if the key doesn't - * map to an existing object. - * - * @param key key to use for mapping - * - * @return object associated with the given configuration key. - */ -protected abstract Object getPropertyDirect(String key); - -/** * Adds a key/value pair to the Configuration. Override this method to * provide write acces to underlying Configuration store. * @@ -233,7 +223,6 @@ priorVariables.add(variable); } -//QUESTION: getProperty or getPropertyDirect Object value = getProperty(variable); if (value != null) { @@ -409,8 +398,7 @@ } else { -throw new IllegalArgumentException( -'\'' + token + ' does not contain an equals sign); +throw new IllegalArgumentException('\'' + token + ' does not contain an equals sign); } } return props; @@ -419,14 +407,6 @@ /** * [EMAIL PROTECTED] */ -public Object getProperty(String key) -{ -return getPropertyDirect(key); -} - -/** - * [EMAIL PROTECTED] - */ public boolean getBoolean(String key) { Boolean b = getBoolean(key, null); @@ -436,8 +416,7 @@ } else { -throw new NoSuchElementException( -'\'' + key + ' doesn't map to an existing object); +throw new NoSuchElementException('\'' + key + ' doesn't map to an existing object); } } @@ -902,7 +881,7 @@ */ public String[] getStringArray(String key) { -Object value = getPropertyDirect(key); +Object value = getProperty(key); String[] array; @@ -946,7 +925,7 @@ */ public List getList(String key, List defaultValue) { -Object value = getPropertyDirect(key); +Object value = getProperty(key); List list = null; if (value instanceof String) @@ -985,7 +964,7 @@ */ protected Object resolveContainerStore(String key) { -Object value = getPropertyDirect(key); +Object value = getProperty(key); if (value != null value instanceof List) { List list = (List) value; 1.11 +3 -3 jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java Index: AbstractFileConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- AbstractFileConfiguration.java19 Nov 2004 13:19:50 - 1.10 +++ AbstractFileConfiguration.java2 Dec
cvs commit: jakarta-commons/configuration/xdocs changes.xml
ebourg 2004/12/02 14:06:21 Modified:configuration/xdocs changes.xml Log: Removed the getPropertyDirect method from AbstractConfiguration, concrete configurations now implement directly the getProperty method from the Configuration interface. Revision ChangesPath 1.73 +5 -0 jakarta-commons/configuration/xdocs/changes.xml Index: changes.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- changes.xml 19 Nov 2004 19:26:47 - 1.72 +++ changes.xml 2 Dec 2004 22:06:21 - 1.73 @@ -8,6 +8,11 @@ body release version=1.1-dev date=in CVS + action dev=ebourg type=remove +Removed the getPropertyDirect method from AbstractConfiguration, +concrete configurations now implement directly the getProperty method +from the Configuration interface. + /action action dev=oheger type=add issue=31130 Added implementation of a save() method for HierarchicalXMLConfiguration. /action - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/xdocs changes.xml
ebourg 2004/12/02 18:07:18 Modified:configuration/src/java/org/apache/commons/configuration JNDIConfiguration.java configuration/xdocs changes.xml Log: Removed the getProperties implementation in JNDIConfiguration, there was no reason to throw an UnsupportedOperationException here. addProperty has been removed as well since the implementation in AbstractConfiguration will call addPropertyDirect in JNDIConfiguration and result in the same exception. Revision ChangesPath 1.23 +1 -23 jakarta-commons/configuration/src/java/org/apache/commons/configuration/JNDIConfiguration.java Index: JNDIConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/JNDIConfiguration.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- JNDIConfiguration.java2 Dec 2004 22:05:52 - 1.22 +++ JNDIConfiguration.java3 Dec 2004 02:07:18 - 1.23 @@ -108,17 +108,6 @@ } /** - * pstrongThis operation is not supported and will throw an - * UnsupportedOperationException./strong/p - * - * @throws UnsupportedOperationException - */ -public void addProperty(String key, Object token) -{ -throw new UnsupportedOperationException(This operation is not supported); -} - -/** * This method recursive traverse the JNDI tree, looking for Context objects. * When it finds them, it traverses them as well. Otherwise it just adds the * values to the list of keys found. @@ -274,17 +263,6 @@ } return null; -} - -/** - * pstrongThis operation is not supported and will throw an - * UnsupportedOperationException./strong/p - * - * @throws UnsupportedOperationException - */ -public Properties getProperties(String key) -{ -throw new UnsupportedOperationException(This operation is not supported); } /** 1.74 +4 -0 jakarta-commons/configuration/xdocs/changes.xml Index: changes.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- changes.xml 2 Dec 2004 22:06:21 - 1.73 +++ changes.xml 3 Dec 2004 02:07:18 - 1.74 @@ -8,6 +8,10 @@ body release version=1.1-dev date=in CVS + action dev=ebourg type=fix +Calling getProperties on a JNDIConfiguration no longer throws an +UnsupportedOperationException. + /action action dev=ebourg type=remove Removed the getPropertyDirect method from AbstractConfiguration, concrete configurations now implement directly the getProperty method - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestFileConfiguration.java
ebourg 2004/11/19 05:19:50 Modified:configuration/src/java/org/apache/commons/configuration AbstractFileConfiguration.java configuration/xdocs changes.xml configuration/src/test/org/apache/commons/configuration TestFileConfiguration.java Log: Saving a configuration now creates the path to the file if it doesn't exist. Constructing a file based configuration with a File no longer throws an exception when the file doesn't exist. AbstractFileConfiguration.save(File) now throws an exception when an error occurs Revision ChangesPath 1.10 +41 -10 jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java Index: AbstractFileConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- AbstractFileConfiguration.java17 Nov 2004 00:18:00 - 1.9 +++ AbstractFileConfiguration.java19 Nov 2004 13:19:50 - 1.10 @@ -17,7 +17,6 @@ package org.apache.commons.configuration; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -27,7 +26,6 @@ import java.io.Reader; import java.io.UnsupportedEncodingException; import java.io.Writer; -import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; @@ -100,7 +98,10 @@ setFile(file); // load the file -load(); +if (file.exists()) +{ +load(); +} } /** @@ -176,7 +177,11 @@ { load(file.toURL()); } -catch (MalformedURLException e) +catch (ConfigurationException e) +{ +throw e; +} +catch (Exception e) { throw new ConfigurationException(e.getMessage(), e); } @@ -198,6 +203,10 @@ in = url.openStream(); load(in); } +catch (ConfigurationException e) +{ +throw e; +} catch (Exception e) { throw new ConfigurationException(e.getMessage(), e); @@ -319,8 +328,9 @@ } /** - * Save the configuration to the specified file. This doesn't change the - * source of the configuration, use setFile() if you need it. + * Save the configuration to the specified file. The file is created + * automatically if it doesn't exist. This doesn't change the source + * of the configuration, use [EMAIL PROTECTED] #setFile} if you need it. * * @param file * @@ -332,12 +342,14 @@ try { +// create the file if necessary +createPath(file); out = new FileOutputStream(file); save(out); } -catch (FileNotFoundException e) +catch (IOException e) { -e.printStackTrace(); +throw new ConfigurationException(e.getMessage(), e); } finally { @@ -469,7 +481,7 @@ { setURL(file.toURL()); } -catch (MalformedURLException e) +catch (IOException e) { e.printStackTrace(); } @@ -607,5 +619,24 @@ { reload(); return super.getKeys(); +} + +/** + * Create the path to the specified file. + */ +private void createPath(File file) +{ +if (file != null) +{ +// create the path to the file if the file doesn't exist +if (!file.exists()) +{ +File parent = file.getParentFile(); +if (parent != null !parent.exists()) +{ +parent.mkdirs(); +} +} +} } } 1.71 +12 -1 jakarta-commons/configuration/xdocs/changes.xml Index: changes.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- changes.xml 19 Nov 2004 01:56:30 - 1.70 +++ changes.xml 19 Nov 2004 13:19:50 - 1.71 @@ -8,8 +8,19 @@ body release version=1.1-dev date=in CVS + action dev=ebourg type=update +Constructing a file based configuration with a File no longer
cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestConfigurationFactory.java
ebourg 2004/11/18 17:56:30 Modified:configuration/xdocs changes.xml configuration/src/java/org/apache/commons/configuration ConfigurationUtils.java configuration/conf resources.jar configuration/src/test/org/apache/commons/configuration TestConfigurationFactory.java Log: ConfigurationUtils.locate() now checks if the URL based ressources exist. Revision ChangesPath 1.70 +14 -9 jakarta-commons/configuration/xdocs/changes.xml Index: changes.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- changes.xml 14 Nov 2004 19:06:32 - 1.69 +++ changes.xml 19 Nov 2004 01:56:30 - 1.70 @@ -9,6 +9,20 @@ release version=1.1-dev date=in CVS action dev=ebourg type=fix +ConfigurationUtils.locate() now checks if the URL based ressources exist. +This fixes a bug preventing configuration files from being found if +the configuration descriptor is in a JAR file (reported by Grant Ingersoll). + /action + action dev=oheger type=fix issue=32236 + Fixed NPE that where caused in the constructors of file based + configurations if an invalid file name was specified. + /action + action dev=oheger type=add issue=31797 + Added support for optional configuration sources in definition files for + ConfigurationFactory. A new required attribute allows to specify whether a + configuration source is mandatory or optional. + /action + action dev=ebourg type=fix JNDIConfiguration.getKeys() now returns an empty iterator instead of throwing a ConfigurationRuntimeException when a NamingException occurs. The NamingExceptions are now logged. @@ -71,15 +85,6 @@ AppletConfiguration, ServletConfiguration, ServletContextConfiguration, ServletRequestConfiguration, ServletFilterConfiguration. /action - action dev=oheger type=fix issue=32236 - Fixed NPE that where caused in the constructors of file based - configurations if an invalid file name was specified. - /action - action dev=oheger type=add issue=31797 - Added support for optional configuration sources in definition files for - ConfigurationFactory. A new required attribute allows to specify whether a - configuration source is mandatory or optional. - /action /release release version=1.0.1-dev date=in CVS 1.12 +18 -8 jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationUtils.java Index: ConfigurationUtils.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationUtils.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ConfigurationUtils.java 17 Nov 2004 00:14:03 - 1.11 +++ ConfigurationUtils.java 19 Nov 2004 01:56:30 - 1.12 @@ -16,11 +16,7 @@ package org.apache.commons.configuration; -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.io.StringWriter; +import java.io.*; import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; @@ -264,13 +260,27 @@ { URL baseURL = new URL(base); url = new URL(baseURL, name); + +// check if the file exists +InputStream in = null; +try +{ +in = url.openStream(); +} +finally +{ +if (in != null) +{ +in.close(); +} +} } log.debug(Configuration loaded from the URL + url); } -catch (MalformedURLException e) +catch (IOException e) { - +url = null; } // attempt to load from an absolute path 1.2 +4 -1 jakarta-commons/configuration/conf/resources.jar Binary file 1.18 +12 -1 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationFactory.java Index: TestConfigurationFactory.java === RCS file: /home/cvs/jakarta-commons/configuration
cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestBaseConfigurationXMLReader.java
ebourg 2004/11/16 16:12:05 Modified:configuration/src/test/org/apache/commons/configuration TestBaseConfigurationXMLReader.java Log: minor style fix Revision ChangesPath 1.4 +3 -3 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestBaseConfigurationXMLReader.java Index: TestBaseConfigurationXMLReader.java === RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestBaseConfigurationXMLReader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TestBaseConfigurationXMLReader.java 27 Feb 2004 17:41:34 - 1.3 +++ TestBaseConfigurationXMLReader.java 17 Nov 2004 00:12:05 - 1.4 @@ -1,5 +1,3 @@ -package org.apache.commons.configuration; - /* * Copyright 2001-2004 The Apache Software Foundation. * @@ -15,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +package org.apache.commons.configuration; import java.io.IOException; import java.util.Arrays; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration ConfigurationUtils.java
ebourg 2004/11/16 16:14:03 Modified:configuration/src/java/org/apache/commons/configuration ConfigurationUtils.java Log: getBasePath now returns null if the specified URL is null Revision ChangesPath 1.11 +6 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationUtils.java Index: ConfigurationUtils.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationUtils.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ConfigurationUtils.java 19 Oct 2004 13:41:44 - 1.10 +++ ConfigurationUtils.java 17 Nov 2004 00:14:03 - 1.11 @@ -372,6 +372,11 @@ */ static String getBasePath(URL url) { +if (url == null) +{ +return null; +} + String s = url.toString(); if (s.endsWith(/) || StringUtils.isEmpty(url.getPath())) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration AbstractFileConfiguration.java
ebourg 2004/11/16 16:18:00 Modified:configuration/src/java/org/apache/commons/configuration AbstractFileConfiguration.java Log: The constructor AbstractFileConfiguration(String) now relies on setFileName() instead of duplicating the logic. This provides an alternate fix to Bug 32236 with a modification to ConfigurationUtils.getBasePath. Revision ChangesPath 1.9 +4 -10 jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java Index: AbstractFileConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- AbstractFileConfiguration.java14 Nov 2004 18:29:02 - 1.8 +++ AbstractFileConfiguration.java17 Nov 2004 00:18:00 - 1.9 @@ -76,14 +76,7 @@ this(); // store the file name -this.fileName = fileName; - -// locate the file -url = ConfigurationUtils.locate(fileName); -if(url == null) -{ -throw new ConfigurationException(fileName + could not be found!); -} +setFileName(fileName); // update the base path setBasePath(ConfigurationUtils.getBasePath(url)); @@ -496,7 +489,7 @@ } /** - * The URL where the configuration is stored. + * Set the URL where the configuration is stored. * * @param url */ @@ -508,6 +501,7 @@ basePath = ConfigurationUtils.getBasePath(url); if (basePath != null basePath.startsWith(file:)) { +// remove the file: prefix from file URLs basePath = basePath.substring(5); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/xdocs index.xml
ebourg 2004/10/25 06:54:08 Modified:configuration/xdocs index.xml Log: front page update: - modified code example - AbstractFileConfiguration mentioned - bug section copied from commons collections - javadoc link to the full API instead of the Configuration interface Revision ChangesPath 1.8 +33 -28jakarta-commons/configuration/xdocs/index.xml Index: index.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/index.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- index.xml 18 Oct 2004 12:50:41 - 1.7 +++ index.xml 25 Oct 2004 13:54:08 - 1.8 @@ -13,19 +13,19 @@ body section name=Intro p - Commons Configuration provides a generic configuration - interface which enables an application to read configuration - data from a variety of sources. Commons Configuration - provides typed access to single, and multi-valued - configuration parameters as demonstrated by the following - code: + Commons Configuration provides a generic configuration interface which enables +an application to read configuration data from a variety of sources. Commons Configuration + provides typed access to single, and multi-valued configuration parameters as demonstrated +by the following code: -source![CDATA[ Double double = Configuration.getDouble(some_double_value); ]]/source +source![CDATA[ +Double double = config.getDouble(number); +Integer integer = config.getInteger(number); +]]/source /p p - Configuration parameters may be loaded from the following - sources: + Configuration parameters may be loaded from the following sources: ul liProperties files/li @@ -37,15 +37,13 @@ liServlet parameters/li /ul -Different configuration sources can be mixed using a - codeConfigurationFactory/code and - codeCompositeConfiguration/code. Additional sources of - configuration parameters can be created by using custom - configuration objects. This customization can be achieved by - extending codeAbstractConfiguration/code. +Different configuration sources can be mixed using a codeConfigurationFactory/code and + a codeCompositeConfiguration/code. Additional sources of configuration parameters can +be created by using custom configuration objects. This customization can be achieved by + extending codeAbstractConfiguration/code or codeAbstractFileConfiguration/code. /p p - The full Configuration API is available a href=apidocs/org/apache/commons/configuration/Configuration.html#method_summaryhere/a. + The full Javadoc API documentation is available a href=apidocs/index.htmlhere/a. /p /section @@ -53,25 +51,32 @@ p The latest release of Apache Jakarta Commons Configuration is available from a href=downloads.htmlhere/a. It is also available from a href=http://www.ibiblio.org/maven/commons-configuration/jars;IBiblio/a. -The a href=changes-report.htmlChanges Report/a -explains all of the changes and bug fixes that have been made. +The a href=changes-report.htmlChanges Report/a explains all of the changes and bug fixes that have been made. /p /section section name=History p -Commons Configuration started as code in Apache JServ. The -JServ code was subsequently added to a -href=http://jakarta.apache.org/turbine;Jakarta Turbine/a. -After Jakarta Turbine, this configuration interface moved to -a href=http://jakarta.apache.org/velocity;Jakarta -Velocity/a and underwent various improvements. After -Velocity, this code was introduced to the a -href=http://jakarta.apache.org/commons;Jakarta Commons/a -as codeExtendedProperties/code. Configuration began life -in the Commons as a Sandbox component, and was promoted to the +Commons Configuration started as code in Apache JServ. The JServ code was subsequently +added to a href=http://jakarta.apache.org/turbine;Jakarta Turbine/a. After Jakarta +Turbine, this configuration interface moved to a href=http://jakarta.apache.org/velocity;Jakarta Velocity/a +and underwent various improvements. After Velocity, this code was introduced to the +a href=http://jakarta.apache.org/commons;Jakarta Commons/a as codeExtendedProperties/code. +Configuration began life
cvs commit: jakarta-commons/configuration/xdocs navigation.xml
ebourg 2004/10/25 06:57:29 Modified:configuration/xdocs navigation.xml Log: menu update: - renamed Overview into Using Configuration - renamed Simple Howto into Properties Howto - added a download link - added a CVS link Revision ChangesPath 1.11 +4 -2 jakarta-commons/configuration/xdocs/navigation.xml Index: navigation.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/navigation.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- navigation.xml22 Sep 2004 11:57:28 - 1.10 +++ navigation.xml25 Oct 2004 13:57:29 - 1.11 @@ -14,14 +14,16 @@ menu name=Configuration item name=Home href=/index.html/ - item name=Overview href=/overview.html/ - item name=Simple Howto href=/howto_properties.html/ + item name=Download href=http://jakarta.apache.org/site/sourceindex.cgi#commons-configuration/ + item name=Using Configuration href=/overview.html/ + item name=Properties Howto href=/howto_properties.html/ item name=ConfigurationFactory Howto href=/howto_configurationfactory.html/ item name=XML Howtohref=/howto_xml.html/ item name=Composite Config Howto href=/howto_compositeconfiguration.html/ item name=Runtime Dependencies href=/dependencies.html/ item name=Roadmap href=/tasks-report.html/ item name=Javadoc href=/apidocs/index.html/ + item name=CVS href=http://cvs.apache.org/viewcvs/jakarta-commons/configuration// /menu menu name=Extensions - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/xdocs overview.xml
ebourg 2004/10/25 07:12:02 Modified:configuration/xdocs overview.xml Log: documentation update: - removed the references to the unit tests, this is discouraging for new users - more examples - replaced digester file by configuration descriptor since digester is just an implementation detail Revision ChangesPath 1.7 +70 -54jakarta-commons/configuration/xdocs/overview.xml Index: overview.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/overview.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- overview.xml 22 Oct 2004 01:40:48 - 1.6 +++ overview.xml 25 Oct 2004 14:12:02 - 1.7 @@ -1,25 +1,25 @@ ?xml version=1.0? document - - properties - titleConfiguration Overview/title - author email=[EMAIL PROTECTED]Eric Pugh/author - /properties - -body + properties +titleConfiguration Overview/title +author email=[EMAIL PROTECTED]Eric Pugh/author +author email=[EMAIL PROTECTED]Emmanuel Bourg/author + /properties + body section name=Using Configuration p -The best way to learn how to use Configuration is to look at the various testcases -that it comes with. This will demonstrate how a Configuration object is populated -from multiple different sources. +One of the strength of Commons Configuration is its ability to mix configurations +from heterogeneous sources, this section will introduce you to the different configurations +available and will show you how to combine them. /p + subsection name=Configuration Sources p -Currently there are quite a number of different sources of Configuration objects. But, +Currently there are quite a number of different sources of Configuration objects. But, by just using a Configuration object versus a specific type like XMLConfiguration or -JNDIConfiguration, you are sheltered from the mechanics of actually retrieving the +JNDIConfiguration, you are sheltered from the mechanics of actually retrieving the configuration values. These various sources include: ul li @@ -39,61 +39,74 @@ Using a key in the JNDI tree, can retrieve values as configuration properties. /li li + strongSystemConfiguration/strong + A configuration using the system properties + /li + li strongConfigurationConverter/strong Takes a java.util.Properties or an o.a.c.collections.ExtendedProperties and converts it to a Configuration object. /li /ul - + /p /subsection + subsection name=Mixing Configuration Sources p -Often you want to provide a base set of configuration values, but allow the user to easily +Often you want to provide a base set of configuration values, but allow the user to easily override them for their specific environment. Well one way is to hard code the default values into your code, and have then provide a property file that overrides this. However, -this is a very rigid way of doing things. Instead, with the CompositeConfiguration you can -provide many different ways of setting up a configuration. You can either do it manually (see -JUnit testcase TestCompositeConfiguration.java, or via the ConfigurationFactory class. +this is a very rigid way of doing things. Instead, with the codeCompositeConfiguration/code +you can provide many different ways of setting up a configuration. You can either do it +manually: /p + +source +CompositeConfiguration config = new CompositeConfiguration(); +config.addConfiguration(new SystemConfiguration()); +config.addConfiguration(new PropertiesConfiguration(application.properties)); +/source + + por via the codeConfigurationFactory/code class:/p + +source +ConfigurationFactory factory = new ConfigurationFactory(config.xml); +Configuration config = factory.getConfiguration(); +/source + p -Using the ConfigurationFactory, (see the Junit testcase TestConfigurationFactory.java) you load -up a digester xml file that specifies how to load up all the Configuration objects. Here is -a sample one using the default digesterRules.xml file: +The codeconfig.xml/code file used in the example above is a configuration descriptor, +it specifies the Configuration objects to load. Here is an example of descriptor: /p - source![CDATA[ +source![CDATA[ ?xml version=1.0 encoding=ISO
cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration DatabaseConfiguration.java
ebourg 2004/10/21 11:02:09 Modified:configuration/xdocs changes.xml configuration/src/java/org/apache/commons/configuration DatabaseConfiguration.java Log: DatabaseConfiguration.isEmpty() now returns true if an SQLException occurs. This is consistent with JNDIConfiguration.isEmpty() and the empty iterator returned by getKeys() in this case. Revision ChangesPath 1.67 +3 -0 jakarta-commons/configuration/xdocs/changes.xml Index: changes.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- changes.xml 19 Oct 2004 13:41:44 - 1.66 +++ changes.xml 21 Oct 2004 18:02:09 - 1.67 @@ -8,6 +8,9 @@ body release version=1.1-dev date=in CVS + action dev=ebourg type=fix +DatabaseConfiguration.isEmpty() now returns true if an SQLException occurs. + /action action dev=ebourg type=add Added two methods copy(Configuration, Configuration) and append(Configuration, Configuration) in ConfigurationUtils to copy 1.12 +2 -2 jakarta-commons/configuration/src/java/org/apache/commons/configuration/DatabaseConfiguration.java Index: DatabaseConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/DatabaseConfiguration.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- DatabaseConfiguration.java18 Oct 2004 14:05:23 - 1.11 +++ DatabaseConfiguration.java21 Oct 2004 18:02:09 - 1.12 @@ -208,7 +208,7 @@ */ public boolean isEmpty() { -boolean empty = false; +boolean empty = true; // build the query StringBuffer query = new StringBuffer(SELECT count(*) FROM + table); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration JNDIConfiguration.java
ebourg 2004/10/21 11:36:14 Modified:configuration/xdocs changes.xml configuration/src/java/org/apache/commons/configuration JNDIConfiguration.java Log: JNDIConfiguration.getKeys() now returns an empty iterator instead of throwing a ConfigurationRuntimeException when a NamingException occurs. The NamingExceptions are now all logged. Added a more explicit javadoc on the methods throwing an UnsupportedOperationException. Revision ChangesPath 1.68 +5 -0 jakarta-commons/configuration/xdocs/changes.xml Index: changes.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- changes.xml 21 Oct 2004 18:02:09 - 1.67 +++ changes.xml 21 Oct 2004 18:36:14 - 1.68 @@ -9,6 +9,11 @@ release version=1.1-dev date=in CVS action dev=ebourg type=fix +JNDIConfiguration.getKeys() now returns an empty iterator instead of +throwing a ConfigurationRuntimeException when a NamingException occurs. +The NamingExceptions are now logged. + /action + action dev=ebourg type=fix DatabaseConfiguration.isEmpty() now returns true if an SQLException occurs. /action action dev=ebourg type=add 1.20 +22 -23 jakarta-commons/configuration/src/java/org/apache/commons/configuration/JNDIConfiguration.java Index: JNDIConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/JNDIConfiguration.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- JNDIConfiguration.java4 Oct 2004 20:06:09 - 1.19 +++ JNDIConfiguration.java21 Oct 2004 18:36:14 - 1.20 @@ -26,10 +26,8 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NameClassPair; -import javax.naming.NameNotFoundException; import javax.naming.NamingEnumeration; import javax.naming.NamingException; -import javax.naming.NotContextException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -110,10 +108,10 @@ } /** - * JNDIConfigurations can not be added to. + * pstrongThis operation is not supported and will throw an + * UnsupportedOperationException./strong/p * - * @param key The Key to add the property to. - * @param token The Value to add. + * @throws UnsupportedOperationException */ public void addProperty(String key, Object token) { @@ -221,7 +219,8 @@ } catch (NamingException e) { -throw new ConfigurationRuntimeException(e.getMessage(), e); +log.error(e.getMessage(), e); +return new ArrayList().iterator(); } } @@ -278,9 +277,10 @@ } /** - * [EMAIL PROTECTED] + * pstrongThis operation is not supported and will throw an + * UnsupportedOperationException./strong/p * - * bThis operation is not supported/b + * @throws UnsupportedOperationException */ public Properties getProperties(String key) { @@ -310,9 +310,9 @@ } } } -catch (NamingException ne) +catch (NamingException e) { -log.warn(ne); +log.error(e.getMessage(), e); return true; } } @@ -326,7 +326,10 @@ } /** - * [EMAIL PROTECTED] + * pstrongThis operation is not supported and will throw an + * UnsupportedOperationException./strong/p + * + * @throws UnsupportedOperationException */ public void setProperty(String key, Object value) { @@ -357,8 +360,9 @@ getBaseContext().lookup(key); return true; } -catch (NamingException ne) +catch (NamingException e) { +log.error(e.getMessage(), e); return false; } } @@ -399,23 +403,18 @@ key = StringUtils.replace(key, ., /); return getBaseContext().lookup(key); } -catch (NameNotFoundException e) -{ -return null; -} -catch (NotContextException e) -{ -return null; -} catch (NamingException e) { -e.printStackTrace(); +log.error(e.getMessage(), e); return null; } } /** - * [EMAIL PROTECTED] + * pstrongThis
cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration/web AppletConfiguration.java ServletConfiguration.java ServletContextConfiguration.java ServletFilterConfiguration.java ServletRequestConfiguration.java
ebourg 2004/10/21 11:42:09 Modified:configuration/src/java/org/apache/commons/configuration/web AppletConfiguration.java ServletConfiguration.java ServletContextConfiguration.java ServletFilterConfiguration.java ServletRequestConfiguration.java Log: explicit javadoc for unsupported methods Revision ChangesPath 1.3 +13 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/web/AppletConfiguration.java Index: AppletConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/web/AppletConfiguration.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AppletConfiguration.java 14 Oct 2004 15:54:06 - 1.2 +++ AppletConfiguration.java 21 Oct 2004 18:42:09 - 1.3 @@ -51,6 +51,12 @@ return applet.getParameter(key); } +/** + * pstrongThis operation is not supported and will throw an + * UnsupportedOperationException./strong/p + * + * @throws UnsupportedOperationException + */ protected void addPropertyDirect(String key, Object obj) { throw new UnsupportedOperationException(Read only configuration); @@ -66,6 +72,12 @@ return getPropertyDirect(key) != null; } +/** + * pstrongThis operation is not supported and will throw an + * UnsupportedOperationException./strong/p + * + * @throws UnsupportedOperationException + */ public void clearProperty(String key) { throw new UnsupportedOperationException(Read only configuration); 1.3 +13 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/web/ServletConfiguration.java Index: ServletConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/web/ServletConfiguration.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ServletConfiguration.java 14 Oct 2004 15:54:06 - 1.2 +++ ServletConfiguration.java 21 Oct 2004 18:42:09 - 1.3 @@ -62,6 +62,12 @@ return config.getInitParameter(key); } +/** + * pstrongThis operation is not supported and will throw an + * UnsupportedOperationException./strong/p + * + * @throws UnsupportedOperationException + */ protected void addPropertyDirect(String key, Object obj) { throw new UnsupportedOperationException(Read only configuration); @@ -77,6 +83,12 @@ return getPropertyDirect(key) != null; } +/** + * pstrongThis operation is not supported and will throw an + * UnsupportedOperationException./strong/p + * + * @throws UnsupportedOperationException + */ public void clearProperty(String key) { throw new UnsupportedOperationException(Read only configuration); 1.3 +13 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/web/ServletContextConfiguration.java Index: ServletContextConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/web/ServletContextConfiguration.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ServletContextConfiguration.java 14 Oct 2004 15:54:06 - 1.2 +++ ServletContextConfiguration.java 21 Oct 2004 18:42:09 - 1.3 @@ -63,6 +63,12 @@ return context.getInitParameter(key); } +/** + * pstrongThis operation is not supported and will throw an + * UnsupportedOperationException./strong/p + * + * @throws UnsupportedOperationException + */ protected void addPropertyDirect(String key, Object obj) { throw new UnsupportedOperationException(Read only configuration); @@ -78,6 +84,12 @@ return getPropertyDirect(key) != null; } +/** + * pstrongThis operation is not supported and will throw an + * UnsupportedOperationException./strong/p + * + * @throws UnsupportedOperationException + */ public void clearProperty(String key) { throw new UnsupportedOperationException(Read only configuration); 1.3 +13 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/web/ServletFilterConfiguration.java Index: ServletFilterConfiguration.java === RCS file: /home/cvs
cvs commit: jakarta-commons/configuration project.properties
ebourg 2004/10/21 17:59:19 Modified:configuration project.properties Log: Changed the default source target set by Maven to compile with the JDK 1.5 (Jira MPJAVA-22) Revision ChangesPath 1.18 +2 -0 jakarta-commons/configuration/project.properties Index: project.properties === RCS file: /home/cvs/jakarta-commons/configuration/project.properties,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- project.properties12 Oct 2004 00:33:06 - 1.17 +++ project.properties22 Oct 2004 00:59:19 - 1.18 @@ -30,3 +30,5 @@ maven.jar.override=on maven.jar.resources=conf/resources.jar + +maven.compile.source = 1.3 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/conf testDigesterBadXML.xml testDigesterConfigurationNamespaceAware.xml testDigesterConfigurationWJNDI.xml testEqualDigester.xml testSequenceDigester.xml
ebourg 2004/10/21 18:19:52 Modified:configuration/xdocs overview.xml configuration/conf testDigesterBadXML.xml testDigesterConfigurationNamespaceAware.xml testDigesterConfigurationWJNDI.xml testEqualDigester.xml testSequenceDigester.xml Log: Removed the unused className attributes from the configuration descriptors Revision ChangesPath 1.5 +6 -6 jakarta-commons/configuration/xdocs/overview.xml Index: overview.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/overview.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- overview.xml 12 Jul 2004 12:14:38 - 1.4 +++ overview.xml 22 Oct 2004 01:19:52 - 1.5 @@ -65,9 +65,9 @@ ?xml version=1.0 encoding=ISO-8859-1 ? configuration - jndi className=org.apache.commons.configuration.JNDIConfiguration prefix=java:comp/env/ - properties className=org.apache.commons.configuration.PropertiesConfiguration fileName=conf/test.properties/ - xml className=org.apache.commons.configuration.XMLConfiguration fileName=conf/test.xml/ + jndi prefix=java:comp/env/ + properties fileName=conf/test.properties/ + xml fileName=conf/test.xml/ /configuration ]] /source @@ -94,7 +94,7 @@ subsection name=Classic Properties File source ![CDATA[ - properties className=org.apache.commons.configuration.PropertiesConfiguration fileName=conf/test.properties/ + properties fileName=conf/test.properties/ ]] /source p @@ -104,7 +104,7 @@ subsection name=XML Properties File source ![CDATA[ - xml className=org.apache.commons.configuration.XMLConfiguration fileName=conf/test.xml/ + xml fileName=conf/test.xml/ ]] /source p @@ -134,7 +134,7 @@ subsection name=JNDI Properties File source ![CDATA[ - jndi className=org.apache.commons.configuration.JNDIConfiguration prefix=java:comp/env/ + jndi prefix=java:comp/env/ ]] /source p 1.3 +1 -7 jakarta-commons/configuration/conf/testDigesterBadXML.xml Index: testDigesterBadXML.xml === RCS file: /home/cvs/jakarta-commons/configuration/conf/testDigesterBadXML.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- testDigesterBadXML.xml12 Jul 2004 12:14:37 - 1.2 +++ testDigesterBadXML.xml22 Oct 2004 01:19:52 - 1.3 @@ -5,12 +5,6 @@ configuration additional -xml className=org.apache.commons.configuration.HierarchicalXMLConfiguration fileName=testHierarchicalXMLConfiguration.xml/ +hierarchicalXml fileName=testHierarchicalXMLConfiguration.xml/ /configuration - - - - - - 1.3 +2 -2 jakarta-commons/configuration/conf/testDigesterConfigurationNamespaceAware.xml Index: testDigesterConfigurationNamespaceAware.xml === RCS file: /home/cvs/jakarta-commons/configuration/conf/testDigesterConfigurationNamespaceAware.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- testDigesterConfigurationNamespaceAware.xml 12 Jul 2004 12:14:37 - 1.2 +++ testDigesterConfigurationNamespaceAware.xml 22 Oct 2004 01:19:52 - 1.3 @@ -2,6 +2,6 @@ configuration xmlns:foo=namespace-one xmlns:bar=namespace-two - foo:properties className=org.apache.commons.configuration.PropertiesConfiguration fileName=conf/test.properties/ - bar:dom className=org.apache.commons.configuration.XMLConfiguration fileName=conf/test.xml/ + foo:properties fileName=conf/test.properties/ + bar:xml fileName=conf/test.xml/ /configuration 1.3 +3 -3 jakarta-commons/configuration/conf/testDigesterConfigurationWJNDI.xml Index: testDigesterConfigurationWJNDI.xml === RCS file: /home/cvs/jakarta-commons/configuration/conf/testDigesterConfigurationWJNDI.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- testDigesterConfigurationWJNDI.xml12 Jul 2004 12:14:37 - 1.2 +++ testDigesterConfigurationWJNDI.xml22 Oct 2004 01:19:52 - 1.3 @@ -1,7 +1,7 @@ ?xml version=1.0 encoding=ISO-8859-1 ? configuration - jndi className=org.apache.commons.configuration.JNDIConfiguration prefix=java:comp/env/ - properties className=org.apache.commons.configuration.PropertiesConfiguration fileName=conf/test.properties/ - dom className
cvs commit: jakarta-commons/configuration/xdocs howto_compositeconfiguration.xml howto_configurationfactory.xml howto_properties.xml howto_xml.xml overview.xml
ebourg 2004/10/21 18:40:49 Modified:configuration/xdocs howto_compositeconfiguration.xml howto_configurationfactory.xml howto_properties.xml howto_xml.xml overview.xml Log: Removed the extra empty lines in the source blocks Revision ChangesPath 1.2 +6 -14 jakarta-commons/configuration/xdocs/howto_compositeconfiguration.xml Index: howto_compositeconfiguration.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/howto_compositeconfiguration.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- howto_compositeconfiguration.xml 24 Feb 2004 13:08:03 - 1.1 +++ howto_compositeconfiguration.xml 22 Oct 2004 01:40:48 - 1.2 @@ -20,15 +20,13 @@ Defaults are very simple. You can just add them as your last configuration object, either through the ConfigurationFactory or manually: /p - source -![CDATA[ + source![CDATA[ Configuration defaults = new PropertiesConfiguration(fileToDefaults); Configuration otherProperties = new PropertiesConfiguration(fileToOtherProperties); CompositeConfiguration cc = new CompositeConfiguration(); cc.addConfiguration(otherProperties); cc.addDefaults(fileToDefaults); -]] - /source +]]/source /subsection subsection name=Saving Changes @@ -39,20 +37,17 @@ the constructor of the CompositeConfiguration what Configuration to save the changes via. /p - source -![CDATA[ + source![CDATA[ PropertiesConfiguration saveConfiguration = new PropertiesConfiguration(fileToSaveChangesIn); Configuration cc = new CompositeConfiguration(saveConfiguration); cc.setProperty(newProperty,new value); saveConfiguration.save(); -]] - /source +]]/source p Alternatively, you can just request the inMemoryConfiguration that stores the changes: - source -![CDATA[ + source![CDATA[ Configuration changes = myCompositeConfiguration.getInMemoryConfiguration(); DatabaseConfiguration config = new DatabaseConfiguration(datasource, configuration, key, value); for (Iterator i = changes.getKeys().iterator();i.hasNext()){ @@ -60,10 +55,7 @@ Object value = changes.get(key); config.setProperty(key,value); } - - -]] - /source +]]/source /p /subsection 1.4 +14 -28 jakarta-commons/configuration/xdocs/howto_configurationfactory.xml Index: howto_configurationfactory.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/howto_configurationfactory.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- howto_configurationfactory.xml12 Jul 2004 12:14:38 - 1.3 +++ howto_configurationfactory.xml22 Oct 2004 01:40:48 - 1.4 @@ -35,15 +35,13 @@ the properties are to be collected. The following listing shows the content of this file: /p - source -![CDATA[ + source![CDATA[ ?xml version=1.0 encoding=ISO-8859-1 ? configuration properties fileName=usergui.properties/ /configuration -]] - /source +]]/source p Definition files for codeConfigurationFactory/code are normal XML files. The root element must be named @@ -65,14 +63,12 @@ Just create a new instance and set the name of the definition file with the codesetConfigurationFileName()/code method. /p - source -![CDATA[ + source![CDATA[ ConfigurationFactory factory = new ConfigurationFactory(); URL configURL = new File(config.xml).toURL(); factory.setConfigurationFileName(configURL.toString()); Configuration config = factory.getConfiguration(); -]] - /source +]]/source p As this code fragment shows the file name passed to the factory
cvs commit: jakarta-commons/configuration/xdocs changes.xml
ebourg 2004/10/19 04:44:31 Modified:configuration/src/java/org/apache/commons/configuration AbstractFileConfiguration.java PropertiesConfiguration.java XMLConfiguration.java configuration/xdocs changes.xml Log: Moved the constructors implementations from PropertiesConfiguration and XMLConfiguration to AbstractFileConfiguration. Revision ChangesPath 1.7 +67 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java Index: AbstractFileConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- AbstractFileConfiguration.java18 Oct 2004 15:45:10 - 1.6 +++ AbstractFileConfiguration.java19 Oct 2004 11:44:31 - 1.7 @@ -53,9 +53,75 @@ protected ReloadingStrategy strategy; private Object reloadLock = new Object(); +/** + * Default constructor + * + * @since 1.1 + */ public AbstractFileConfiguration() { setReloadingStrategy(new InvariantReloadingStrategy()); +} + +/** + * Creates and loads the configuration from the specified file. + * + * @param fileName The name of the file to load. + * + * @throws ConfigurationException Error while loading the file + * @since 1.1 + */ +public AbstractFileConfiguration(String fileName) throws ConfigurationException +{ +this(); + +// store the file name +this.fileName = fileName; + +// locate the file +url = ConfigurationUtils.locate(fileName); + +// update the base path +setBasePath(ConfigurationUtils.getBasePath(url)); + +// load the file +load(); +} + +/** + * Creates and loads the configuration from the specified file. + * + * @param file The file to load. + * @throws ConfigurationException Error while loading the file + * @since 1.1 + */ +public AbstractFileConfiguration(File file) throws ConfigurationException +{ +this(); + +// set the file and update the url, the base path and the file name +setFile(file); + +// load the file +load(); +} + +/** + * Creates and loads the configuration from the specified URL. + * + * @param url The location of the file to load. + * @throws ConfigurationException Error while loading the file + * @since 1.1 + */ +public AbstractFileConfiguration(URL url) throws ConfigurationException +{ +this(); + +// set the URL and update the base path and the file name +setURL(url); + +// load the file +load(); } /** 1.16 +5 -32 jakarta-commons/configuration/src/java/org/apache/commons/configuration/PropertiesConfiguration.java Index: PropertiesConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/PropertiesConfiguration.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- PropertiesConfiguration.java 23 Sep 2004 11:45:07 - 1.15 +++ PropertiesConfiguration.java 19 Oct 2004 11:44:31 - 1.16 @@ -139,7 +139,7 @@ static String include = include; /** Allow file inclusion or not */ -private boolean includesAllowed; +private boolean includesAllowed = true; /** * Creates an empty PropertyConfiguration object which can be @@ -163,20 +163,7 @@ */ public PropertiesConfiguration(String fileName) throws ConfigurationException { -// enable includes -setIncludesAllowed(true); - -// store the file name -this.fileName = fileName; - -// locate the resource -url = ConfigurationUtils.locate(fileName); - -// update the base path -setBasePath(ConfigurationUtils.getBasePath(url)); - -// load the file -load(); +super(fileName); } /** @@ -189,14 +176,7 @@ */ public PropertiesConfiguration(File file) throws ConfigurationException { -// enable includes -setIncludesAllowed(true); - -// set the file and update the url, the base path and the file name -setFile(file); - -// load the file -load(); +super(file); } /** @@ -209,14 +189,7
cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestConfigurationUtils.java
ebourg 2004/10/19 06:41:44 Modified:configuration/xdocs changes.xml configuration/src/java/org/apache/commons/configuration ConfigurationUtils.java configuration/src/test/org/apache/commons/configuration TestConfigurationUtils.java Log: Added copy() and append() in ConfigurationUtils Revision ChangesPath 1.66 +5 -0 jakarta-commons/configuration/xdocs/changes.xml Index: changes.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- changes.xml 19 Oct 2004 11:44:31 - 1.65 +++ changes.xml 19 Oct 2004 13:41:44 - 1.66 @@ -8,6 +8,11 @@ body release version=1.1-dev date=in CVS + action dev=ebourg type=add +Added two methods copy(Configuration, Configuration) and +append(Configuration, Configuration) in ConfigurationUtils to copy +properties between configurations. + /action action dev=ebourg type=update Moved the constructors implementations from PropertiesConfiguration and XMLConfiguration to AbstractFileConfiguration. 1.10 +39 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationUtils.java Index: ConfigurationUtils.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationUtils.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ConfigurationUtils.java 23 Sep 2004 11:42:00 - 1.9 +++ ConfigurationUtils.java 19 Oct 2004 13:41:44 - 1.10 @@ -98,6 +98,44 @@ } /** + * Copy all properties from the source configuration to the target + * configuration. Properties in the target configuration are replaced with + * the properties with the same key in the source configuration. + * + * @param source the source configuration + * @param target the target configuration + * @since 1.1 + */ +public static void copy(Configuration source, Configuration target) +{ +Iterator keys = source.getKeys(); +while (keys.hasNext()) +{ +String key = (String) keys.next(); +target.setProperty(key, source.getProperty(key)); +} +} + +/** + * Append all properties from the source configuration to the target + * configuration. Properties in the source configuration are appended to + * the properties with the same key in the target configuration. + * + * @param source the source configuration + * @param target the target configuration + * @since 1.1 + */ +public static void append(Configuration source, Configuration target) +{ +Iterator keys = source.getKeys(); +while (keys.hasNext()) +{ +String key = (String) keys.next(); +target.addProperty(key, source.getProperty(key)); +} +} + +/** * Constructs a URL from a base path and a file name. The file name can * be absolute, relative or a full URL. If necessary the base path URL is * applied. 1.8 +50 -2 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationUtils.java Index: TestConfigurationUtils.java === RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationUtils.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- TestConfigurationUtils.java 23 Sep 2004 11:42:00 - 1.7 +++ TestConfigurationUtils.java 19 Oct 2004 13:41:44 - 1.8 @@ -1,5 +1,3 @@ -package org.apache.commons.configuration; - /* * Copyright 2001-2004 The Apache Software Foundation. * @@ -16,14 +14,20 @@ * limitations under the License. */ +package org.apache.commons.configuration; + import java.io.File; import java.net.URL; +import java.util.ArrayList; +import java.util.List; import junit.framework.TestCase; +import junitx.framework.ListAssert; /** * Tests the ConfigurationUtils class * + * @version $Revision$, $Date$ */ public class TestConfigurationUtils extends TestCase { @@ -123,4 +127,48 @@ assertEquals(file name for a valid URL + url, bar.xml, ConfigurationUtils.getFileName(url)); } +public void testCopy() +{ +// create the source configuration +Configuration conf1 = new
cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration Configuration.java
ebourg 2004/10/18 02:52:02 Modified:configuration/src/java/org/apache/commons/configuration Configuration.java Log: Javadoc update Revision ChangesPath 1.11 +32 -2 jakarta-commons/configuration/src/java/org/apache/commons/configuration/Configuration.java Index: Configuration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/Configuration.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Configuration.java16 Aug 2004 22:16:31 - 1.10 +++ Configuration.java18 Oct 2004 09:52:02 - 1.11 @@ -171,6 +171,8 @@ /** * Get a boolean associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -210,6 +212,8 @@ /** * Get a byte associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -249,6 +253,8 @@ /** * Get a double associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -287,6 +293,8 @@ /** * Get a float associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -299,6 +307,8 @@ /** * Get a [EMAIL PROTECTED] Float} associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -326,6 +336,8 @@ /** * Get a int associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -338,6 +350,8 @@ /** * Get an [EMAIL PROTECTED] Integer} associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -365,6 +379,8 @@ /** * Get a long associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -377,6 +393,8 @@ /** * Get a [EMAIL PROTECTED] Long} associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -416,6 +434,8 @@ /** * Get a [EMAIL PROTECTED] Short} associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -443,6 +463,8 @@ /** * Get a [EMAIL PROTECTED] BigDecimal} associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -466,6 +488,8 @@ /** * Get a [EMAIL PROTECTED] BigInteger} associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -491,6 +515,8 @@ /** * Get a string associated with the given configuration key. + * If the key doesn't map to an existing object, the default value + * is returned. * * @param key The configuration key. * @param defaultValue The default value. @@ -528,10 +554,12 @@ /** * Get a List of strings associated with the given configuration key. + * If the key doesn't map
cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestDataConfiguration.java
ebourg 2004/10/18 02:54:38 Modified:configuration/src/java/org/apache/commons/configuration AbstractConfiguration.java configuration/xdocs changes.xml Added: configuration/src/java/org/apache/commons/configuration DataConfiguration.java PropertyConverter.java configuration/src/test/org/apache/commons/configuration TestDataConfiguration.java Log: Added a DataConfiguration decorator providing getters for all useful types found in a configuration (URL, Locale, Date, Calendar, Color, lists and arrays) Revision ChangesPath 1.26 +71 -162 jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java http://cvs.apache.org/viewcvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java.diff?r1=1.25r2=1.26 1.1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/DataConfiguration.java http://cvs.apache.org/viewcvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/DataConfiguration.java?rev=1.1 1.1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/PropertyConverter.java http://cvs.apache.org/viewcvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/PropertyConverter.java?rev=1.1 1.56 +6 -1 jakarta-commons/configuration/xdocs/changes.xml http://cvs.apache.org/viewcvs/jakarta-commons/configuration/xdocs/changes.xml.diff?r1=1.55r2=1.56 1.1 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestDataConfiguration.java http://cvs.apache.org/viewcvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestDataConfiguration.java?rev=1.1 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestHierarchicalConfiguration.java
ebourg 2004/10/18 03:19:27 Modified:configuration/xdocs changes.xml configuration/src/java/org/apache/commons/configuration HierarchicalConfiguration.java configuration/src/test/org/apache/commons/configuration TestHierarchicalConfiguration.java Log: Fixed HierarchicalConfiguration.getKeys(String) (bug 31745 by Oliver Heger) Revision ChangesPath 1.57 +4 -0 jakarta-commons/configuration/xdocs/changes.xml Index: changes.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- changes.xml 18 Oct 2004 09:54:37 - 1.56 +++ changes.xml 18 Oct 2004 10:19:26 - 1.57 @@ -8,6 +8,10 @@ body release version=1.1-dev date=in CVS + action dev=oheger type=fix issue=31745 +Fixed HierarchicalConfiguration.getKeys(String), it returned an empty +iterator if the prefix string contained indices. + /action action dev=ebourg type=add Added a DataConfiguration decorator providing getters for all useful types found in a configuration (URL, Locale, Date, Calendar, Color, 1.12 +26 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java Index: HierarchicalConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- HierarchicalConfiguration.java11 Oct 2004 09:27:20 - 1.11 +++ HierarchicalConfiguration.java18 Oct 2004 10:19:26 - 1.12 @@ -377,6 +377,31 @@ getRoot().visit(visitor, new ConfigurationKey()); return visitor.getKeyList().iterator(); } + +/** + * Returns an iterator with all keys defined in this configuration that + * start with the given prefix. The returned keys will not contain any + * indices. + * @param prefix the prefix of the keys to start with + * @return an iterator with the found keys + */ +public Iterator getKeys(String prefix) +{ +DefinedKeysVisitor visitor = new DefinedKeysVisitor(); +List nodes = fetchNodeList(prefix); +ConfigurationKey key = new ConfigurationKey(); + +for(Iterator itNodes = nodes.iterator(); itNodes.hasNext();) +{ +Node node = (Node) itNodes.next(); +for(Iterator it = node.getChildren().iterator(); it.hasNext();) +{ +((Node) it.next()).visit(visitor, key); +} +} + +return visitor.getKeyList().iterator(); +} /** * Returns the maximum defined index for the given key. This is 1.6 +55 -1 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestHierarchicalConfiguration.java Index: TestHierarchicalConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestHierarchicalConfiguration.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- TestHierarchicalConfiguration.java13 Mar 2004 17:04:04 - 1.5 +++ TestHierarchicalConfiguration.java18 Oct 2004 10:19:27 - 1.6 @@ -18,8 +18,10 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import junit.framework.TestCase; @@ -158,6 +160,28 @@ assertTrue(keys.contains(tables.table.fields.field.name)); } +public void testGetKeysString() +{ +// add some more properties to make it more interesting +config.addProperty(tables.table(0).fields.field(1).type, VARCHAR); +config.addProperty(tables.table(0)[EMAIL PROTECTED], system); +config.addProperty(tables.table(0).size, 42); +config.addProperty(tables.table(0).fields.field(0).size, 128); +config.addProperty(connections.connection.param.url, url1); +config.addProperty(connections.connection.param.user, me); +config.addProperty(connections.connection.param.pwd, secret); +config.addProperty(connections.connection(-1).param.url, url2); +config.addProperty(connections.connection(1).param.user, guest); + +checkKeys(tables.table(1), new String[] { name, fields.field.name
cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestBaseConfiguration.java
ebourg 2004/10/18 03:44:31 Modified:configuration/xdocs changes.xml configuration/src/java/org/apache/commons/configuration PropertyConverter.java configuration/src/test/org/apache/commons/configuration TestBaseConfiguration.java Log: Numeric properties can now be specified in hexadecimal format (bug 28026) Revision ChangesPath 1.58 +4 -0 jakarta-commons/configuration/xdocs/changes.xml Index: changes.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- changes.xml 18 Oct 2004 10:19:26 - 1.57 +++ changes.xml 18 Oct 2004 10:44:31 - 1.58 @@ -8,6 +8,10 @@ body release version=1.1-dev date=in CVS + action dev=ebourg type=add issue=28026 +Numeric properties can now be specified in hexadecimal format, +for example number = 0xC5F0. + /action action dev=oheger type=fix issue=31745 Fixed HierarchicalConfiguration.getKeys(String), it returned an empty iterator if the prefix string contained indices. 1.2 +47 -6 jakarta-commons/configuration/src/java/org/apache/commons/configuration/PropertyConverter.java Index: PropertyConverter.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/PropertyConverter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PropertyConverter.java18 Oct 2004 09:54:37 - 1.1 +++ PropertyConverter.java18 Oct 2004 10:44:31 - 1.2 @@ -84,7 +84,15 @@ { try { -return new Byte((String) value); +String string = (String) value; +if (string.startsWith(0x)) +{ +return new Byte((byte) Integer.parseInt(string.substring(2), 16)); +} +else +{ +return new Byte(string); +} } catch (NumberFormatException e) { @@ -113,7 +121,16 @@ { try { -return new Short((String) value); +String string = (String) value; +if (string.startsWith(0x)) +{ +return new Short((short) Integer.parseInt(string.substring(2), 16)); +} +else +{ +return new Short(string); +} + } catch (NumberFormatException e) { @@ -142,7 +159,15 @@ { try { -return new Integer((String) value); +String string = (String) value; +if (string.startsWith(0x)) +{ +return new Integer((int) Long.parseLong(string.substring(2), 16)); +} +else +{ +return new Integer(string); +} } catch (NumberFormatException e) { @@ -171,7 +196,15 @@ { try { -return new Long((String) value); +String string = (String) value; +if (string.startsWith(0x)) +{ +return new Long(new BigInteger(string.substring(2), 16).longValue()); +} +else +{ +return new Long(string); +} } catch (NumberFormatException e) { @@ -258,7 +291,15 @@ { try { -return new BigInteger((String) value); +String string = (String) value; +if (string.startsWith(0x)) +{ +return new BigInteger(string.substring(2), 16); +} +else +{ +return new BigInteger(string); +} } catch (NumberFormatException e) { 1.16 +570 -504 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestBaseConfiguration.java Index: TestBaseConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestBaseConfiguration.java,v
cvs commit: jakarta-commons/configuration/xdocs changes.xml
ebourg 2004/10/18 04:12:09 Modified:configuration/src/java/org/apache/commons/configuration AbstractFileConfiguration.java FileConfiguration.java HierarchicalXMLConfiguration.java XMLConfiguration.java configuration/xdocs changes.xml Log: Moved the auto save logic from XMLConfiguration to AbstractFileConfiguration Revision ChangesPath 1.5 +43 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java Index: AbstractFileConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AbstractFileConfiguration.java4 Oct 2004 21:45:10 - 1.4 +++ AbstractFileConfiguration.java18 Oct 2004 11:12:08 - 1.5 @@ -45,6 +45,7 @@ protected String fileName; protected String basePath; protected URL url; +protected boolean autoSave; /** * Load the configuration from the underlying URL. If the URL is not @@ -430,5 +431,46 @@ // update the file name fileName = ConfigurationUtils.getFileName(url); +} + +public void setAutoSave(boolean autoSave) +{ +this.autoSave = autoSave; +} + +public boolean isAutoSave() +{ +return autoSave; +} + +/** + * Save the configuration if the automatic persistence is enabled + * and if a file is specified. + */ +protected void possiblySave() +{ +if (autoSave fileName != null) +{ +try +{ +save(); +} +catch (ConfigurationException e) +{ +throw new ConfigurationRuntimeException(Failed to auto-save, e); +} +} +} + +protected void addPropertyDirect(String key, Object obj) +{ +super.addPropertyDirect(key, obj); +possiblySave(); +} + +public void clearProperty(String key) +{ +super.clearProperty(key); +possiblySave(); } } 1.2 +17 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/FileConfiguration.java Index: FileConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/FileConfiguration.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FileConfiguration.java22 Sep 2004 17:17:30 - 1.1 +++ FileConfiguration.java18 Oct 2004 11:12:08 - 1.2 @@ -207,4 +207,20 @@ */ void setURL(URL url); +/** + * Enable of disable the automatical saving of modified properties to the disk. + * + * @param autoSave codetrue/code to enable, codefalse/code to disable + * @since 1.1 + */ +void setAutoSave(boolean autoSave); + +/** + * Tells if properties are automatically saved to the disk. + * + * @return codetrue/code if auto-saving is enabled, codefalse/code otherwise + * @since 1.1 + */ +boolean isAutoSave(); + } 1.4 +11 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalXMLConfiguration.java Index: HierarchicalXMLConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalXMLConfiguration.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- HierarchicalXMLConfiguration.java 22 Sep 2004 17:17:30 - 1.3 +++ HierarchicalXMLConfiguration.java 18 Oct 2004 11:12:08 - 1.4 @@ -239,6 +239,16 @@ delegate.setURL(url); } +public void setAutoSave(boolean autoSave) +{ +delegate.setAutoSave(autoSave); +} + +public boolean isAutoSave() +{ +return delegate.isAutoSave(); +} + private class FileConfigurationDelegate extends AbstractFileConfiguration { public void load(Reader in) throws ConfigurationException 1.18 +7 -46 jakarta-commons/configuration/src/java/org/apache/commons/configuration/XMLConfiguration.java Index: XMLConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/XMLConfiguration.java,v retrieving revision 1.17
cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestConfigurationConverter.java
ebourg 2004/10/18 05:32:06 Modified:configuration/src/test/org/apache/commons/configuration TestConfigurationConverter.java Log: Added a test for getMap Fixed the parameters order on the assertions Revision ChangesPath 1.7 +24 -12 jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationConverter.java Index: TestConfigurationConverter.java === RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestConfigurationConverter.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- TestConfigurationConverter.java 16 Aug 2004 22:16:31 - 1.6 +++ TestConfigurationConverter.java 18 Oct 2004 12:32:06 - 1.7 @@ -19,6 +19,7 @@ import java.util.List; import java.util.Properties; import java.util.Vector; +import java.util.Map; import junit.framework.TestCase; import org.apache.commons.collections.ExtendedProperties; @@ -42,14 +43,14 @@ Configuration config = ConfigurationConverter.getConfiguration(eprops); -assertEquals(This returns 'teststring', config.getString(string), teststring); +assertEquals(This returns 'teststring', teststring, config.getString(string)); List item1 = config.getList(list); -assertEquals(This returns 'item 1', (String) item1.get(0), item 1); +assertEquals(This returns 'item 1', item 1, (String) item1.get(0)); Vector item2 = config.getVector(list); -assertEquals(This returns 'item 1', (String) item2.get(0), item 1); +assertEquals(This returns 'item 1', item 1, (String) item2.get(0)); -assertEquals(This returns 123, config.getInt(int), 123); +assertEquals(This returns 123, 123, config.getInt(int)); } public void testPropertiesToConfiguration() @@ -61,14 +62,14 @@ Configuration config = ConfigurationConverter.getConfiguration(props); -assertEquals(This returns 'teststring', config.getString(string), teststring); +assertEquals(This returns 'teststring', teststring, config.getString(string)); List item1 = config.getList(list); -assertEquals(This returns 'item 1', (String) item1.get(0), item 1); +assertEquals(This returns 'item 1', item 1, (String) item1.get(0)); Vector item2 = config.getVector(list); -assertEquals(This returns 'item 1', (String) item2.get(0), item 1); +assertEquals(This returns 'item 1', item 1, (String) item2.get(0)); -assertEquals(This returns 123, config.getInt(int), 123); +assertEquals(This returns 123, 123, config.getInt(int)); } public void testConfigurationToExtendedProperties() @@ -81,10 +82,10 @@ ExtendedProperties eprops = ConfigurationConverter.getExtendedProperties(config); -assertEquals(This returns 'teststring', eprops.getString(string), teststring); +assertEquals(This returns 'teststring', teststring, eprops.getString(string)); List list = eprops.getVector(list); -assertEquals(This returns 'item 1', (String) list.get(0), item 1); -assertEquals(This returns 123, eprops.getInt(int), 123); +assertEquals(This returns 'item 1', item 1, (String) list.get(0)); +assertEquals(This returns 123, 123, eprops.getInt(int)); } public void testConfigurationToProperties() @@ -99,6 +100,17 @@ assertNotNull(null properties, props); assertEquals('string' property, teststring, props.getProperty(string)); assertEquals('array' property, item 1, item 2, props.getProperty(array)); +} + +public void testConfigurationToMap() +{ +Configuration config = new BaseConfiguration(); +config.addProperty(string, teststring); + +Map map = ConfigurationConverter.getMap(config); + +assertNotNull(null map, map); +assertEquals('string' property, teststring, map.get(string)); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/configuration/conf testDigesterConfiguration3.xml
ebourg 2004/10/18 05:50:42 Modified:configuration/xdocs changes.xml index.xml configuration/src/java/org/apache/commons/configuration ConfigurationConverter.java ConfigurationFactory.java ConfigurationMap.java configuration/src/test/org/apache/commons/configuration TestConfigurationFactory.java configuration/conf testDigesterConfiguration3.xml Added: configuration/src/java/org/apache/commons/configuration MapConfiguration.java SystemConfiguration.java configuration/src/test/org/apache/commons/configuration TestMapConfiguration.java TestSystemConfiguration.java Log: Added MapConfiguration and SystemConfiguration Revision ChangesPath 1.60 +13 -0 jakarta-commons/configuration/xdocs/changes.xml Index: changes.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- changes.xml 18 Oct 2004 11:12:09 - 1.59 +++ changes.xml 18 Oct 2004 12:50:41 - 1.60 @@ -8,6 +8,19 @@ body release version=1.1-dev date=in CVS + action dev=ebourg type=add issue=26066 +Added a SystemConfiguration wrapping the system properties. +ConfigurationFactory recognizes the corresponding lt;system/gt; +element. + /action + action dev=ebourg type=add +Added a MapConfiguration to turn any Map into a Configuration. The +getConfiguration() methods in ConfigurationConverter now use +MapConfiguration, as a result the Configuration returned is always +synchronized with the underlying Properties or ExtendedProperties, +changes made to the Configuration are available in the Properties, +and reciprocally. + /action action dev=ebourg type=add issue=31532 The autoSave feature of XMLConfiguration has been generalized to all file based configurations. 1.7 +3 -0 jakarta-commons/configuration/xdocs/index.xml Index: index.xml === RCS file: /home/cvs/jakarta-commons/configuration/xdocs/index.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- index.xml 24 Sep 2004 20:52:57 - 1.6 +++ index.xml 18 Oct 2004 12:50:41 - 1.7 @@ -32,6 +32,9 @@ liXML documents/li liJNDI/li liJDBC Datasource/li + liSystem properties/li + liApplet parameters/li + liServlet parameters/li /ul Different configuration sources can be mixed using a 1.8 +5 -25 jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationConverter.java Index: ConfigurationConverter.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationConverter.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ConfigurationConverter.java 12 Aug 2004 16:06:01 - 1.7 +++ ConfigurationConverter.java 18 Oct 2004 12:50:41 - 1.8 @@ -16,7 +16,6 @@ package org.apache.commons.configuration; -import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -47,17 +46,7 @@ */ public static Configuration getConfiguration(ExtendedProperties eprops) { -Configuration config = new BaseConfiguration(); - -Iterator keys = eprops.getKeys(); - -while (keys.hasNext()) -{ -String key = (String) keys.next(); -config.setProperty(key, eprops.getProperty(key)); -} - -return config; +return new MapConfiguration(eprops); } /** @@ -68,17 +57,7 @@ */ public static Configuration getConfiguration(Properties props) { -Configuration config = new BaseConfiguration(); - -Enumeration keys = props.keys(); - -while (keys.hasMoreElements()) -{ -String key = (String) keys.nextElement(); -config.setProperty(key, props.getProperty(key)); -} - -return config; +return new MapConfiguration(props); } /** @@ -152,7 +131,8 @@ * @param config Configuration object to convert * @return Map created from the Configuration */ -public static Map getMap(Configuration config) { +public static Map
cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestDatabaseConfiguration.java
ebourg 2004/10/18 07:05:23 Modified:configuration/src/java/org/apache/commons/configuration AbstractConfiguration.java BaseConfiguration.java Configuration.java DatabaseConfiguration.java configuration/xdocs changes.xml configuration/src/test/org/apache/commons/configuration TestDatabaseConfiguration.java Log: Added Configuration.clear() Revision ChangesPath 1.27 +13 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java Index: AbstractConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- AbstractConfiguration.java18 Oct 2004 09:54:37 - 1.26 +++ AbstractConfiguration.java18 Oct 2004 14:05:22 - 1.27 @@ -329,6 +329,18 @@ /** * [EMAIL PROTECTED] */ +public void clear() +{ +Iterator it = getKeys(); +while (it.hasNext()) +{ +clearProperty((String) it.next()); +} +} + +/** + * [EMAIL PROTECTED] + */ public abstract Iterator getKeys(); /** 1.9 +9 -3 jakarta-commons/configuration/src/java/org/apache/commons/configuration/BaseConfiguration.java Index: BaseConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/BaseConfiguration.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- BaseConfiguration.java5 Jul 2004 09:54:17 - 1.8 +++ BaseConfiguration.java18 Oct 2004 14:05:23 - 1.9 @@ -60,7 +60,6 @@ super(); } - /** * Adds a key/value pair to the map. This routine does no magic morphing. * It ensures the keylist is maintained @@ -139,7 +138,6 @@ public boolean containsKey(String key) { return store.containsKey(key); - } /** @@ -153,6 +151,14 @@ { store.remove(key); } +} + +/** + * [EMAIL PROTECTED] + */ +public void clear() +{ +store.clear(); } /** 1.12 +6 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/Configuration.java Index: Configuration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/Configuration.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Configuration.java18 Oct 2004 09:52:02 - 1.11 +++ Configuration.java18 Oct 2004 14:05:23 - 1.12 @@ -117,6 +117,11 @@ void clearProperty(String key); /** + * Remove all properties from the configuration. + */ +void clear(); + +/** * Gets a property from the configuration. * * @param key property to retrieve 1.11 +40 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/DatabaseConfiguration.java Index: DatabaseConfiguration.java === RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/DatabaseConfiguration.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- DatabaseConfiguration.java20 Sep 2004 09:37:07 - 1.10 +++ DatabaseConfiguration.java18 Oct 2004 14:05:23 - 1.11 @@ -340,6 +340,45 @@ /** * [EMAIL PROTECTED] */ +public void clear() +{ +// build the query +StringBuffer query = new StringBuffer(DELETE FROM + table); +if (nameColumn != null) +{ +query.append( WHERE + nameColumn + =?); +} + +Connection conn = null; +PreparedStatement pstmt = null; + +try +{ +conn = datasource.getConnection(); + +// bind the parameters +pstmt = conn.prepareStatement(query.toString()); +if (nameColumn != null) +{ +pstmt.setString(1, name); +} + +pstmt.executeUpdate(); +} +catch (SQLException e) +{ +log.error(e.getMessage(), e); +} +finally +{ +// clean up +closeQuietly(conn
cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration/reloading - New directory
ebourg 2004/10/18 08:41:57 jakarta-commons/configuration/src/java/org/apache/commons/configuration/reloading - New directory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]