Author: xor
Date: 2008-09-18 15:01:28 +0000 (Thu, 18 Sep 2008)
New Revision: 22684

Modified:
   trunk/plugins/WoT/Config.java
Log:
Add a function to return a list of all configuration-keys.

Modified: trunk/plugins/WoT/Config.java
===================================================================
--- trunk/plugins/WoT/Config.java       2008-09-18 14:06:37 UTC (rev 22683)
+++ trunk/plugins/WoT/Config.java       2008-09-18 15:01:28 UTC (rev 22684)
@@ -6,6 +6,7 @@
 package plugins.WoT;

 import java.util.HashMap;
+import java.util.Iterator;

 import com.db4o.ObjectContainer;

@@ -42,6 +43,20 @@
        }

        /**
+        * Get all valid configuration keys.
+        * @return A String array containing a copy of all keys in the database 
at the point of calling the function. Changes to the array do not change the 
database.
+        */
+       public String[] getAllKeys() {
+               /* We use toArray() to create a *copy* of the Set<String>. If we
+                * returned an iterator of the keySet, modifications on the
+                * configuration HashMap would be reflected in the iterator. 
This might
+                * lead to problems if the configuration is modified while 
someone is
+                * using an iterator returned by this function. Further the 
iterator
+                * would allow the user to delete keys from the configuration - 
xor */
+               return (String[])params.keySet().toArray();
+       }
+       
+       /**
         * Add the default configuration values to the database.
         * @param overwrite If true, overwrite already set values with the 
default value.
         */


Reply via email to