propertylist/IPropertylist: removed obsolete loadTextDB_sub()
[metux-java.git] / util / UniqueNameList.java
blobc38cd40af4d8d90a3128adba48a021f9260a7662
1 /*
2 This class represents a list of (unique) flags, which may exist,
3 but only once at max. If we add some flag twice, nothing really
4 happens.
6 Flaglists can also be used to collect things like search path
7 arguments, etc.
9 Operations:
11 void add(String name) -> add some flag
12 void clear(String name) -> clear some flag
13 String[] getFlagNames() -> lists all flags to an String array
17 package org.de.metux.util;
19 import java.util.Hashtable;
20 import java.util.Enumeration;
22 public class UniqueNameList
24 Hashtable ht = new Hashtable();
26 public void add(String name)
28 if ((name!=null)&&(name.length()!=0))
29 ht.put(name,name);
32 public void add(String name[])
34 if (name!=null)
35 for (int x=0; x<name.length; x++)
36 add(name[x]);
39 public void clear(String name)
41 if ((name!=null)&&(name.length()!=0))
42 ht.remove(name);
45 public String[] getNames()
47 String res[] = new String[ht.size()];
48 int x=0;
49 for (Enumeration e=ht.keys(); e.hasMoreElements();)
50 res[x++]=(String)e.nextElement();
51 return res;
54 public boolean exists(String name)
56 return (ht.get(name) != null);
59 public String toString()
61 String s = null;
62 for (Enumeration e=ht.keys(); e.hasMoreElements();)
63 s = ((s==null)?("{ \""):", \"")+e.nextElement()+"\"";
64 return s+" }; ";