Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 40261 invoked from network); 6 Jul 2003 18:17:59 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 6 Jul 2003 18:17:59 -0000 Received: (qmail 15018 invoked by uid 97); 6 Jul 2003 18:20:28 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 15010 invoked from network); 6 Jul 2003 18:20:28 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 6 Jul 2003 18:20:28 -0000 Received: (qmail 40051 invoked by uid 500); 6 Jul 2003 18:17:57 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 40040 invoked by uid 500); 6 Jul 2003 18:17:57 -0000 Received: (qmail 40037 invoked from network); 6 Jul 2003 18:17:57 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 6 Jul 2003 18:17:57 -0000 Received: (qmail 26550 invoked by uid 1332); 6 Jul 2003 18:17:56 -0000 Date: 6 Jul 2003 18:17:56 -0000 Message-ID: <20030706181756.26549.qmail@icarus.apache.org> From: henning@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration CompositeConfiguration.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N henning 2003/07/06 11:17:56 Modified: configuration/src/java/org/apache/commons/configuration CompositeConfiguration.java Log: Changed getStringArray() and getVector() to return all the configuration values referenced in all sub configurations. Now CompositeConfiguration and Simple Configurations behave just the same Revision Changes Path 1.15 +20 -23 jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java Index: CompositeConfiguration.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- CompositeConfiguration.java 6 Jul 2003 15:19:08 -0000 1.14 +++ CompositeConfiguration.java 6 Jul 2003 18:17:56 -0000 1.15 @@ -698,15 +698,10 @@ */ public String[] getStringArray(String key) { - try - { - return getFirstMatchingConfig(key).getStringArray(key); - } - catch (NoSuchElementException nsee) - { - return new String[0]; - } + Vector v = getVector(key); + return (String []) v.toArray(new String [0]); } + /** * Get a Vector of strings associated with the given configuration key. * @@ -717,15 +712,20 @@ */ public Vector getVector(String key) { - try + Vector v = new Vector(); + + for (ListIterator li = configList.listIterator(); li.hasNext();) { - return getFirstMatchingConfig(key).getVector(key); - } - catch (NoSuchElementException nsee) - { - return new Vector(); + Configuration config = (Configuration) li.next(); + if (config.containsKey(key)) + { + v.addAll(config.getVector(key)); + } } + + return v; } + /** * Get a Vector of strings associated with the given configuration key. * @@ -737,15 +737,11 @@ */ public Vector getVector(String key, Vector defaultValue) { - try - { - return getFirstMatchingConfig(key).getVector(key, defaultValue); - } - catch (NoSuchElementException nsee) - { - return defaultValue; - } + Vector v = getVector(key); + + return (v.size() == 0) ? defaultValue : v; } + private Configuration getFirstMatchingConfig(String key) { for (ListIterator i = configList.listIterator(); i.hasNext();) @@ -759,6 +755,7 @@ throw new NoSuchElementException( '\'' + key + "' doesn't map to an existing object"); } + public Configuration getConfiguration(int index) { return (Configuration) configList.get(index); --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org