ariba.ui.aribaweb.util
Class AWIntKeyHashtable

java.lang.Object
  extended by java.util.AbstractMap
      extended by ariba.ui.aribaweb.util.AWIntKeyHashtable
All Implemented Interfaces:
AWDisposable, java.util.Map

public final class AWIntKeyHashtable
extends java.util.AbstractMap
implements AWDisposable

This code duplicated from ariba.util.core.Hashtable and is temporary until we get this capability in ariba.util.core.


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>
 
Field Summary
static java.lang.String ClassName
          Name of this class.
 
Constructor Summary
AWIntKeyHashtable()
          Constructs an empty Hashtable.
AWIntKeyHashtable(java.util.Hashtable source)
          Creates new Hashtable with the same contents as the given Hashtable.
AWIntKeyHashtable(int initialCapacity)
          Constructs a Hashtable capable of holding a specified number of elements.
 
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(int key)
          Checks if the Hashtable has an entry matching the key key.
 int count()
          Returns the number of elements in the Hashtable.
 void dispose()
          Disosable interface implementation
 java.util.Iterator elements()
          Returns an Iterator of the Hashtable's elements.
 java.lang.Object[] elementsArray()
          Returns an Object array containing the Hashtable's elements.
 java.util.List elementsVector()
          Returns a Vector containing the Hashtable's elements.
 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(int key)
          Searches the Hashtable and returns the element associated with the matched key.
 java.lang.Object get(java.lang.Object key)
           
 boolean isEmpty()
          Indicates if the hashtable contains any elements.
 int[] keysArray()
          Returns an Object array containing the Hashtable's keys.
 AWArrayManager keysVector()
          Returns a Vector containing the Hashtable's keys.
 java.lang.Object put(int key, java.lang.Object element)
          Places the key/element pair in the Hashtable.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 java.lang.Object remove(int key)
          Finds and removes key and the element associated with it from the Hashtable.
 int removeElement(java.lang.Object element)
          Finds and removes all occurrences of element from the Hashtable.
 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.
 
Methods inherited from class java.util.AbstractMap
containsKey, containsValue, equals, hashCode, keySet, putAll, remove, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ClassName

public static final java.lang.String ClassName
Name of this class. Value is "ariba.util.core.Hashtable".

See Also:
Constant Field Values
Constructor Detail

AWIntKeyHashtable

public AWIntKeyHashtable()
Constructs an empty Hashtable. The Hashtable will grow on demand as more elements are added. return new empty Hashtable


AWIntKeyHashtable

public AWIntKeyHashtable(int initialCapacity)
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. return new empty Hashtable with given initial capacity

AWIntKeyHashtable

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

Parameters:
source - source Hashtable return new Hashtable with same contents as source
Method Detail

dispose

public void dispose()
Disosable interface implementation

Specified by:
dispose in interface AWDisposable

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()
Returns the number of elements in the Hashtable.

Returns:
the number of elements in the Hashtable

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.

elements

public java.util.Iterator elements()
Returns an Iterator of the Hashtable's elements.

Returns:
an enumeration of the elements in this Hashtable.
See Also:
_keys

keysVector

public AWArrayManager keysVector()
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.

elementsVector

public java.util.List elementsVector()
Returns a Vector containing the Hashtable's elements. If the hashtable containes no elements, an empty Vector ojbect is returned.

Returns:
the Vector object mentioned above.

keysArray

public int[] 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.

elementsArray

public java.lang.Object[] 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.

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(int key)
Checks if the Hashtable has an entry matching the key key.

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(int key)
Searches the Hashtable and returns the element associated with the matched key.

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

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.AbstractMap

remove

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

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)
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.

put

public java.lang.Object put(int 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

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

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.AbstractMap

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

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


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