[ Back | Previous | Next ]

Lookup table with Hashtable and Enumeration.

Package:
java.util.*
Product:
JDK
Release:
1.0.2
Related Links:
Calendar
EventObject
Hashtable
Locale
Properties
PropertyResourceBundle
TimeZone
Comment:
Lookup table with Hashtable and Enumeration. 

      public class CGI {

            /* Lookup table for name/value pairs */
            public Hashtable lookup=null;
            private String outType=null;

            /** Method to retrieve the value portion of a name/value pair
              * @param name Field name
              * @return value Data value (null if name not found)
            **/
            public String valueOf(String name) {
                    return (String)lookup.get(name);
            }

            /** Method to list out all name/value pairs
            **/
            public void list() {
                   String name, value;
                   for (Enumeration e=lookup.keys(); e.hasMoreElements();) {
                            name = (String)e.nextElement();
                            value = (String)lookup.get(name);
                            //System.out.println(name+"="+value);
                    }
            }
      }
1