Class SimpleHashtable<K,V>

java.lang.Object
com.sun.xml.dtdparser.SimpleHashtable<K,V>
All Implemented Interfaces:
Enumeration<K>

final class SimpleHashtable<K,V> extends Object implements Enumeration<K>
This class implements a special purpose hashtable. It works like a normal java.util.Hashtable except that:
  1. Keys to "get" are strings which are known to be interned, so that "==" is used instead of "String.equals". (Interning could be document-relative instead of global.)
  2. It's not synchronized, since it's to be used only by one thread at a time.
  3. The keys () enumerator allocates no memory, with live updates to the data disallowed.
  4. It's got fewer bells and whistles: fixed threshold and load factor, no JDK 1.2 collection support, only keys can be enumerated, things can't be removed, simpler inheritance; more.

The overall result is that it's less expensive to use these in performance-critical locations, in terms both of CPU and memory, than java.util.Hashtable instances. In this package it makes a significant difference when normalizing attributes, which is done for each start-element construct.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    Hashtable collision list.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
     
     
    private int
     
    private static final float
     
     
    private int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new, empty hashtable with a default capacity.
    SimpleHashtable(int initialCapacity)
    Constructs a new, empty hashtable with the specified initial capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    get(String key)
    Returns the value to which the specified key is mapped in this hashtable.
    Returns the value to which the specified key is mapped in this hashtable ...
    boolean
    Used to view this as an enumeration; returns true if there are more keys to be enumerated.
    Returns an enumeration of the keys in this hashtable.
    Used to view this as an enumeration; returns the next key in the enumeration.
    put(K key, V value)
    Maps the specified key to the specified value in this hashtable.
    private void
    Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently.
    int
    Returns the number of keys in this hashtable.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Enumeration

    asIterator
  • Field Details

  • Constructor Details

    • SimpleHashtable

      public SimpleHashtable(int initialCapacity)
      Constructs a new, empty hashtable with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the hashtable.
    • SimpleHashtable

      public SimpleHashtable()
      Constructs a new, empty hashtable with a default capacity.
  • Method Details

    • clear

      public void clear()
    • size

      public int size()
      Returns the number of keys in this hashtable.
      Returns:
      the number of keys in this hashtable.
    • keys

      public Enumeration<K> keys()
      Returns an enumeration of the keys in this hashtable.
      Returns:
      an enumeration of the keys in this hashtable.
      See Also:
    • hasMoreElements

      public boolean hasMoreElements()
      Used to view this as an enumeration; returns true if there are more keys to be enumerated.
      Specified by:
      hasMoreElements in interface Enumeration<K>
    • nextElement

      public K nextElement()
      Used to view this as an enumeration; returns the next key in the enumeration.
      Specified by:
      nextElement in interface Enumeration<K>
    • get

      public V get(String key)
      Returns the value to which the specified key is mapped in this hashtable.
    • getNonInterned

      public V getNonInterned(String key)
      Returns the value to which the specified key is mapped in this hashtable ... the key isn't necessarily interned, though.
    • rehash

      private void rehash()
      Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently. This method is called automatically when the number of keys in the hashtable exceeds this hashtable capacity and load factor.
    • put

      public V put(K key, V value)
      Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

      The value can be retrieved by calling the get method with a key that is equal to the original key.