ariba.util.core
Class Hashtable

java.lang.Object
  extended by java.util.AbstractMap
      extended by ariba.util.core.Hashtable
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.util.Map
Direct Known Subclasses:
AWCaseInsensitiveHashtable, AWStringKeyHashtable, EqHashtable, OrderedHashtable

public class Hashtable
extends java.util.AbstractMap
implements java.lang.Cloneable, java.io.Externalizable

A Hashtable class that has a number of performance improvements over other Hashtable classes. The methods are not internally synchronized, so care must be taken at the application level to synchronize.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
Hashtable()
          Deprecated. use MapUtil.map
Hashtable(java.util.Hashtable source)
          Deprecated. use MapUtil.map
Hashtable(int initialCapacity)
          Deprecated. use MapUtil.map
Hashtable(java.util.Map source)
          Creates new Hashtable with the same contents as the given Map.
 
Method Summary
 void clear()
          Removes all keys and elements from the Hashtable.
 java.lang.Object clone()
          Creates a shallow copy of the Hashtable.
 boolean contains(java.lang.Object element)
          Checks if the Hashtable contains the specified element.
 boolean containsKey(java.lang.Object key)
          Checks if the Hashtable has an entry matching the key key.
 int count()
          Deprecated. replaced by size
 java.util.Enumeration elements()
          Deprecated. use values.iterator() instead
 java.lang.Object[] elementsArray()
          Deprecated. use MapUtil.elementsArray
 Vector elementsVector()
          Deprecated. use MapUtil.elementsList
 java.util.Set entrySet()
          Note: While iterating through a set of entries in the Hashtable, do not keep references to Key.Entry objects after a subsequent call to next().
 void fromSerializedString(java.lang.String serialized)
          Populates the hashtable with serialized data from the string.
 java.lang.Object get(java.lang.Object key)
          Searches the Hashtable and returns the element associated with the matched key.
 boolean isEmpty()
          Indicates if the hashtable contains any elements.
 java.util.Enumeration keys()
          Deprecated. use keySet.iterator() instead
 java.lang.Object[] keysArray()
          Deprecated. use MapUtil.keysArray
 java.util.Set keySet()
          Returns a Set view of the keys contained in this map.
 Vector keysVector()
          Deprecated. use MapUtil.keysList
 java.lang.Object put(java.lang.Object key, java.lang.Object element)
          Places the key/element pair in the Hashtable.
 void readExternal(java.io.ObjectInput input)
          Implementation of Externalizable interface.
 java.lang.Object remove(java.lang.Object key)
          Finds and removes key and the element associated with it from the Hashtable.
 int removeElement(java.lang.Object element)
          Deprecated. use MapUtil.removeElement
 int size()
          Returns the number of elements in the Hashtable.
 java.lang.String toSerializedString()
          Returns a string serialization of the Hashtable using the Serializer.
 java.lang.String toString()
          Returns the Hashtable's string representation.
 java.lang.String[] toStringArray()
          Converts a string into a string array for persistence purposes.
 java.util.Collection values()
          Returns a collection view of the values contained in this map.
 void writeExternal(java.io.ObjectOutput output)
          Implementation of Externalizable interface.
 
Methods inherited from class java.util.AbstractMap
containsValue, equals, hashCode, putAll
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Hashtable

public Hashtable()
Deprecated. use MapUtil.map

Constructs an empty Hashtable. The Hashtable will grow on demand as more elements are added.

See Also:
MapUtil.map()

Hashtable

public Hashtable(int initialCapacity)
Deprecated. use MapUtil.map

Constructs a Hashtable capable of holding a specified number of elements.

Parameters:
initialCapacity - the number of elements this Hashtable is capable of holding before needing to grow.
See Also:
MapUtil.map(int)

Hashtable

public Hashtable(java.util.Hashtable source)
Deprecated. use MapUtil.map

Creates new Hashtable with the same contents as the given Hashtable.

Parameters:
source - source Hashtable
See Also:
MapUtil.map(java.util.Map)

Hashtable

public Hashtable(java.util.Map source)
Creates new Hashtable with the same contents as the given Map.

Parameters:
source - source Map
Method Detail

clone

public java.lang.Object clone()
Creates a shallow copy of the Hashtable. The table itself is cloned, but none of the keys or elements are copied.

Overrides:
clone in class java.util.AbstractMap
Returns:
the cloned copy
Throws:
java.lang.InternalError - if the cloning operation fails.

count

public int count()
Deprecated. replaced by size

Returns the number of elements in the Hashtable.

Returns:
the number of elements in the Hashtable
See Also:
size()

size

public int size()
Returns the number of elements in the Hashtable.

Specified by:
size in interface java.util.Map
Overrides:
size in class java.util.AbstractMap
Returns:
the number of elements in the Hashtable

isEmpty

public boolean isEmpty()
Indicates if the hashtable contains any elements.

Specified by:
isEmpty in interface java.util.Map
Overrides:
isEmpty in class java.util.AbstractMap
Returns:
true if there are no elements in the Hashtable.

keys

public java.util.Enumeration keys()
Deprecated. use keySet.iterator() instead

Returns an Enumeration of the Hashtable's keys.

Returns:
an enumeration of the keys in this Hashtable.
See Also:
keySet, Set.iterator(), elements()

elements

public java.util.Enumeration elements()
Deprecated. use values.iterator() instead

Returns an Enumeration of the Hashtable's elements.

Returns:
an enumeration of the elements in this Hashtable.
See Also:
values, Collection.iterator(), keys()

keysVector

public Vector keysVector()
Deprecated. use MapUtil.keysList

Returns a Vector containing the Hashtable's keys. If the Hashtable contains no keys, return an empty Vector object.

Returns:
the Vector object mentioned above.
See Also:
MapUtil.keysList(java.util.Map)

elementsVector

public Vector elementsVector()
Deprecated. use MapUtil.elementsList

Returns a Vector containing the Hashtable's elements. If the hashtable containes no elements, an empty Vector object is returned.

Returns:
the Vector object mentioned above.
See Also:
MapUtil.elementsList(java.util.Map)

keysArray

public java.lang.Object[] keysArray()
Deprecated. use MapUtil.keysArray

Returns an Object array containing the Hashtable's keys. If the Hashtable contains no keys, an empty array is returned.

Returns:
the Object array above mentioned.
See Also:
MapUtil.keysArray(java.util.Map)

elementsArray

public java.lang.Object[] elementsArray()
Deprecated. use MapUtil.elementsArray

Returns an Object array containing the Hashtable's elements.

Returns:
the Object array mentioned above. If there the hashtable contains no elements, an empty array is returned.
See Also:
MapUtil.elementsArray(java.util.Map)

contains

public boolean contains(java.lang.Object element)
Checks if the Hashtable contains the specified element. This method is slow -- O(n) -- because it must scan the table searching for the element.

Parameters:
element - the element to search for in the Hashtable
Returns:
Returns true if the Hashtable contains the element.
Throws:
java.lang.NullPointerException - if element is null

containsKey

public boolean containsKey(java.lang.Object key)
Checks if the Hashtable has an entry matching the key key.

Specified by:
containsKey in interface java.util.Map
Overrides:
containsKey in class java.util.AbstractMap
Parameters:
key - the key to search for in the Hashtable
Returns:
true if the Hashtable contains the key key.
Throws:
java.lang.NullPointerException - if key is null

get

public java.lang.Object get(java.lang.Object key)
Searches the Hashtable and returns the element associated with the matched key.

Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.AbstractMap
Parameters:
key - the key to search the hashtable's keys for. Hashtable hashes and compares key using hashCode() and equals().
Returns:
the element associated with the key. This method returns null if the Hashtable does not contain key.
Throws:
java.lang.NullPointerException - if key is null and this Hashtable is not empty.

remove

public java.lang.Object remove(java.lang.Object key)
Finds and removes key and the element associated with it from the Hashtable.

Specified by:
remove in interface java.util.Map
Overrides:
remove in class java.util.AbstractMap
Parameters:
key - the key to search the hashtable's keys for. Hashtable hashes and compares key using hashCode() and equals().
Returns:
the element associated with the key removed, or null if key was not present.

removeElement

public int removeElement(java.lang.Object element)
Deprecated. use MapUtil.removeElement

Finds and removes all occurrences of element from the Hashtable. Note that this method is slow -- O(n) -- because it must scan the table searching for the element.

Parameters:
element - the element to search for. Hashtable compares elements using equals().
Returns:
the number of elements removed.
See Also:
MapUtil.removeElement(java.util.Map, java.lang.Object)

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object element)
Places the key/element pair in the Hashtable. If there is a key in the Hashtable matching key the corresponding element in the Hashtable is replaced by the specified element

Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.AbstractMap
Parameters:
key - the key to place into the Hashtable; may not be null
element - the element to place into the Hashtable; may not be null
Returns:
the element previously associated with the key if any, null otherwise.
Throws:
java.lang.NullPointerException - if element or key are null

clear

public void clear()
Removes all keys and elements from the Hashtable.

Specified by:
clear in interface java.util.Map
Overrides:
clear in class java.util.AbstractMap

toString

public java.lang.String toString()
Returns the Hashtable's string representation.

Overrides:
toString in class java.util.AbstractMap
Returns:
the Hashtable's string representation

toStringArray

public java.lang.String[] toStringArray()
Converts a string into a string array for persistence purposes.

Returns:
string array serialization of this Hashtable

toSerializedString

public java.lang.String toSerializedString()
Returns a string serialization of the Hashtable using the Serializer.

Returns:
string serialization of this Hashtable
See Also:
Serializer

fromSerializedString

public void fromSerializedString(java.lang.String serialized)
Populates the hashtable with serialized data from the string.

Parameters:
serialized - String containing serialized Hashtable data

writeExternal

public void writeExternal(java.io.ObjectOutput output)
                   throws java.io.IOException
Implementation of Externalizable interface. Saves the contents of this Hashtable object.

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
output - the stream to write the object to
Throws:
java.io.IOException - Includes any I/O exceptions that may occur

readExternal

public void readExternal(java.io.ObjectInput input)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Implementation of Externalizable interface. Reads the contents into this Hashtable.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
input - the stream to read data from in order to restore the object
Throws:
java.io.IOException - if I/O errors occur
java.lang.ClassNotFoundException - If the class for an object being restored cannot be found.

entrySet

public java.util.Set entrySet()
Note: While iterating through a set of entries in the Hashtable, do not keep references to Key.Entry objects after a subsequent call to next(). Each entry is valid from the point where next() is called until the subsequent call to next(), at which point the old entry is invalid. Entries do remain valid after a call to remove(), however.

Specified by:
entrySet in interface java.util.Map
Specified by:
entrySet in class java.util.AbstractMap
Returns:
a set of Key.Entry objects

keySet

public java.util.Set keySet()
Returns a Set view of the keys contained in this map. The Set is backed by the map, so changes to the map are reflected in the Set, and vice-versa. (If the map is modified while an iteration over the Set is in progress, the results of the iteration are undefined.) The Set supports element removal, which removes the corresponding entry from the map, via the Iterator.remove, Set.remove, removeAll retainAll, and clear operations. It does not support the add or addAll operations.

Specified by:
keySet in interface java.util.Map
Overrides:
keySet in class java.util.AbstractMap
Returns:
a Set view of the keys contained in this map.

values

public java.util.Collection values()
Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. (If the map is modified while an iteration over the collection is in progress, the results of the iteration are undefined.) The collection supports element removal, which removes the corresponding entry from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Specified by:
values in interface java.util.Map
Overrides:
values in class java.util.AbstractMap
Returns:
a collection view of the values contained in this map.


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.