henning 2003/07/06 08:14:10 Modified: configuration/src/java/org/apache/commons/configuration BaseConfiguration.java Log: Replace the internal Hashtable with the keysAsListed ArrayList by the commons-collections provided SequencedHashMap, which keeps its keys in sequence automatically. Revision Changes Path 1.13 +6 -30 jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/BaseConfiguration.java Index: BaseConfiguration.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/BaseConfiguration.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- BaseConfiguration.java 7 Jun 2003 18:24:00 -0000 1.12 +++ BaseConfiguration.java 6 Jul 2003 15:14:10 -0000 1.13 @@ -56,14 +56,16 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Hashtable; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.NoSuchElementException; import java.util.Properties; import java.util.StringTokenizer; import java.util.Vector; +import org.apache.commons.collections.SequencedHashMap; + /** * Basic configuration classe. Stores the configuration data but does not * provide any load or save functions. If you want to load your Configuration @@ -92,18 +94,11 @@ private static final int INITIAL_LIST_SIZE = 2; /** stores the configuration key-value pairs */ - private Hashtable store = new Hashtable(); + private SequencedHashMap store = new SequencedHashMap(); /** stores the configuration key-value pairs */ protected Configuration defaults = null; - /** - * These are the keys in the order they listed in the configuration file. - * This is useful when you wish to perform operations with configuration - * information in a particular order. - */ - protected ArrayList keysAsListed = new ArrayList(); - /** start token */ protected static final String START_TOKEN = "${"; /** end token */ @@ -250,13 +245,6 @@ */ protected void addPropertyDirect(String key, Object obj) { - // safety check - if (!store.containsKey(key)) - { - keysAsListed.add(key); - } - - // and the value store.put(key, obj); } @@ -506,18 +494,6 @@ { if (containsKey(key)) { - /* - * we also need to rebuild the keysAsListed or else things get - * *very* confusing - */ - for (int i = 0; i < keysAsListed.size(); i++) - { - if (((String) keysAsListed.get(i)).equals(key)) - { - keysAsListed.remove(i); - break; - } - } store.remove(key); } } @@ -530,7 +506,7 @@ */ public Iterator getKeys() { - return keysAsListed.iterator(); + return store.iterator(); } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]