ebourg 2004/06/21 05:37:40 Modified: configuration/src/java/org/apache/commons/configuration AbstractConfiguration.java CompositeConfiguration.java Configuration.java Log: getList revamp - getList(key, null) in AbstractConfiguration now returns null for non existing keys - getList(String) has been removed from CompositeConfiguration - javadoc update in the Configuration interface Revision Changes Path 1.12 +3 -17 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.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- AbstractConfiguration.java 16 Jun 2004 18:13:53 -0000 1.11 +++ AbstractConfiguration.java 21 Jun 2004 12:37:40 -0000 1.12 @@ -1217,27 +1217,14 @@ * Get a List of strings associated with the given configuration key. * * @param key The configuration key. - * * @return The associated List. * * @throws ConversionException is thrown if the key maps to an * object that is not a List. - * - * @throws NoSuchElementException is thrown if the key doesn't - * map to an existing object. */ public List getList(String key) { - List list = getList(key, null); - if (list != null) - { - return list; - } - else - { - throw new NoSuchElementException( - '\'' + key + "' doesn't map to an existing object"); - } + return getList(key, new ArrayList()); } /** @@ -1245,7 +1232,6 @@ * * @param key The configuration key. * @param defaultValue The default value. - * * @return The associated List. * * @throws ConversionException is thrown if the key maps to an @@ -1271,7 +1257,7 @@ } else if (value == null) { - list = ((defaultValue == null) ? new ArrayList() : defaultValue); + list = defaultValue; } else { 1.14 +14 -24 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- CompositeConfiguration.java 15 Jun 2004 15:53:58 -0000 1.13 +++ CompositeConfiguration.java 21 Jun 2004 12:37:40 -0000 1.14 @@ -262,11 +262,10 @@ * Get a List of strings associated with the given configuration key. * * @param key The configuration key. + * @param defaultValue The default value. * @return The associated List. - * @exception ConversionException is thrown if the key maps to an - * object that is not a List. */ - public List getList(String key) + public List getList(String key, List defaultValue) { List list = new ArrayList(); @@ -282,25 +281,14 @@ } // add all elements from the in memory configuration - list.addAll(inMemoryConfiguration.getList(key, null)); - - return list; - } + list.addAll(inMemoryConfiguration.getList(key)); - /** - * Get a List of strings associated with the given configuration key. - * - * @param key The configuration key. - * @param defaultValue The default value. - * @return The associated List. - * @exception ConversionException is thrown if the key maps to an - * object that is not a List. - */ - public List getList(String key, List defaultValue) - { - List list = getList(key); + if (list.isEmpty()) + { + return defaultValue; + } - return list.isEmpty() ? defaultValue : list; + return list; } /** @@ -308,8 +296,9 @@ * * @param key The configuration key. * @return The associated string array if key is found. - * @exception ConversionException is thrown if the key maps to an - * object that is not a String/List of Strings. + * + * @throws ConversionException is thrown if the key maps to an + * object that is not a String/List of Strings. */ public String[] getStringArray(String key) { @@ -326,7 +315,8 @@ /** * @return Returns the inMemoryConfiguration. */ - public Configuration getInMemoryConfiguration() { + public Configuration getInMemoryConfiguration() + { return inMemoryConfiguration; } } 1.8 +3 -4 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Configuration.java 16 Jun 2004 18:13:53 -0000 1.7 +++ Configuration.java 21 Jun 2004 12:37:40 -0000 1.8 @@ -504,6 +504,7 @@ /** * Get an array of strings associated with the given configuration key. + * If the key doesn't map to an existing object an empty array is returned * * @param key The configuration key. * @return The associated string array if key is found. @@ -515,15 +516,13 @@ /** * Get a List of strings associated with the given configuration key. + * If the key doesn't map to an existing object an empty List is returned. * * @param key The configuration key. * @return The associated List. * * @throws ConversionException is thrown if the key maps to an * object that is not a List. - * - * @throws NoSuchElementException is thrown if the key doesn't - * map to an existing object. */ List getList(String key);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]