001    package com.oxygenxml.validate.nvdl;
002    
003    import java.util.Hashtable;
004    import java.util.Enumeration;
005    
006    /**
007     * Utility class, stores a set of objects. 
008     * It uses a Hashtable for internal storage.
009     */
010    class Hashset {
011      /**
012       * The internal storage, a hashtable.
013       */
014      private final Hashtable table = new Hashtable();
015    
016      /**
017       * Test if an object belongs to this set or not.
018       * @param key The object.
019       * @return true if the object is contained in this set.
020       */
021      boolean contains(Object key) {
022        return table.get(key) != null;
023      }
024    
025      /**
026       * Adds an object to this set.
027       * @param key The object to be added.
028       */
029      void add(Object key) {
030        table.put(key, key);
031      }
032    
033      /**
034       * Adds all the objects from another set to this set - union.
035       * @param set The other set.
036       */
037      void addAll(Hashset set) {
038        for (Enumeration enume = set.table.keys(); enume.hasMoreElements();)
039          add(enume.nextElement());
040      }
041    
042      /**
043       * Removes all the objects from this set.
044       */
045      void clear() {
046        table.clear();
047      }
048    
049      /**
050       * Get an enumeration will all the objects from this set.
051       * @return an enumeration with all the objects from this set.
052       */
053      Enumeration members() {
054        return table.keys();
055      }
056    }