com.plumtree.openfoundation.util
Class XPSynchronizedHashtable

java.lang.Object
  extended bycom.plumtree.openfoundation.util.XPHashtable
      extended bycom.plumtree.openfoundation.util.XPSynchronizedHashtable
All Implemented Interfaces:
IXPDictionary

public class XPSynchronizedHashtable
extends XPHashtable
implements IXPDictionary

XPSynchronizedHashtable is a synchronized wrapper over XPHashtable.


Field Summary
static int KEYS
          The type argument to GetArray that denotes the key.
static int VALUES
          The type argument to GetArray() that denotes the value.
 
Fields inherited from class com.plumtree.openfoundation.util.XPHashtable
hashMap
 
Constructor Summary
XPSynchronizedHashtable()
          Creates a new, empty XPSynchronizedHashtable.
XPSynchronizedHashtable(int capacity)
          Creates a new, emtpy XPSynchronizedHashtable with the specified initial capacity.
XPSynchronizedHashtable(int capacity, float loadFactor)
          Creates a new, empty hashtable with the specified initial capacity and the specified load factor.
XPSynchronizedHashtable(XPHashtable ht)
          Copy constructor that clones the given XPHashtable and creates XPSynchronizedHashtable.
 
Method Summary
 void Clear()
          Clears this hashtable so that it contains no keys.
 java.lang.Object Clone()
          Creates a shallow copy of this hashtable.
 boolean Contains(java.lang.Object _value)
          Tests if some key maps into the specified value in this hashtable.
 boolean ContainsKey(java.lang.Object key)
          Tests if the specified object is a key in this hashtable.
 boolean ContainsValue(java.lang.Object _value)
          Tests if this hashtable maps one or more keys to this value.
 java.lang.Object[] GetArray(int type)
          Returns an array of keys or values in the hashtable as indicated by the type argument.
 java.lang.Object GetElement(java.lang.Object key)
          Returns the value to which the specified key is mapped in this hashtable.
 IXPEnumerator GetElements()
          Returns an XPEnumerator that can iterate through the values in this hashtable.
 IXPDictionaryEnumerator GetEnumerator()
          Return a non-synchronized enumerator over the elements of the underlying XPHashtable per the common behavior of Java and C#.
 IXPEnumerator GetKeys()
          Returns an XPEnumerator that can iterate through the keys in this hashtable.
 int GetSize()
          Returns the number of elements in this hashtable.
 java.util.HashMap GetUnderlyingObject()
          Returns the platfrom specific object that this class wraps.
 boolean IsEmpty()
          Tests if this hashtable has no elements.
 java.lang.Object PutElement(java.lang.Object key, java.lang.Object _value)
          Maps the specified key to the specified value in this hashtable.
 java.lang.Object RemoveElement(java.lang.Object key)
          Removes the key (and its corresponding value) from this hashtable.
 
Methods inherited from class com.plumtree.openfoundation.util.XPHashtable
GetSynchronized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEYS

public static final int KEYS
The type argument to GetArray that denotes the key.

See Also:
Constant Field Values

VALUES

public static final int VALUES
The type argument to GetArray() that denotes the value.

See Also:
Constant Field Values
Constructor Detail

XPSynchronizedHashtable

public XPSynchronizedHashtable()
Creates a new, empty XPSynchronizedHashtable.


XPSynchronizedHashtable

public XPSynchronizedHashtable(int capacity)
Creates a new, emtpy XPSynchronizedHashtable with the specified initial capacity.

Parameters:
capacity - the initial capacity of the list.

XPSynchronizedHashtable

public XPSynchronizedHashtable(int capacity,
                               float loadFactor)
Creates a new, empty hashtable with the specified initial capacity and the specified load factor.

Parameters:
capacity - the initial capactity of the hashtable.
loadFactor - the load factor of the hashtable.

XPSynchronizedHashtable

public XPSynchronizedHashtable(XPHashtable ht)
Copy constructor that clones the given XPHashtable and creates XPSynchronizedHashtable.

Parameters:
ht - the XPHashtable to be copied into this object
Method Detail

Clear

public void Clear()
Clears this hashtable so that it contains no keys.

Overrides:
Clear in class XPHashtable

Clone

public java.lang.Object Clone()
Creates a shallow copy of this hashtable. All the structure of the hashtable itself is copied, but the keys and values are not cloned. This is a relatively expensive operation.

Overrides:
Clone in class XPHashtable
Returns:
a clone of the hashtable.

Contains

public boolean Contains(java.lang.Object _value)
Tests if some key maps into the specified value in this hashtable. This operation is more expensive than the containsKey method.

Overrides:
Contains in class XPHashtable
Parameters:
_value - a value to search for.
Returns:
true if and only if some key maps to the value argument in this hashtable as determined by the equals method; false otherwise.

ContainsKey

public boolean ContainsKey(java.lang.Object key)
Tests if the specified object is a key in this hashtable.

Specified by:
ContainsKey in interface IXPDictionary
Overrides:
ContainsKey in class XPHashtable
Parameters:
key - possible key.
Returns:
true if and only if the specified object is a key in this hashtable, as determined by the equals method; false otherwise.

ContainsValue

public boolean ContainsValue(java.lang.Object _value)
Tests if this hashtable maps one or more keys to this value.

Overrides:
ContainsValue in class XPHashtable
Parameters:
_value - value whose presence in this hashtable is to be tested.
Returns:
true if this hashtable maps one or more keys to the specified value.

GetArray

public java.lang.Object[] GetArray(int type)
Returns an array of keys or values in the hashtable as indicated by the type argument.

Overrides:
GetArray in class XPHashtable
Parameters:
type - the type of information in the array returned (key or value)
Returns:
An array off keys or values in the hashtable as indicated by the type argument.

GetElement

public java.lang.Object GetElement(java.lang.Object key)
Returns the value to which the specified key is mapped in this hashtable.

Specified by:
GetElement in interface IXPDictionary
Overrides:
GetElement in class XPHashtable
Parameters:
key - a key in the hashtable.
Returns:
the value to which the key is mapped in this hashtable; null if the key is not mapped to any value in this hashtable.

GetElements

public IXPEnumerator GetElements()
Returns an XPEnumerator that can iterate through the values in this hashtable.

Specified by:
GetElements in interface IXPDictionary
Overrides:
GetElements in class XPHashtable
Returns:
An XPEnumerator that can iterate through the values in this hashtable.

GetKeys

public IXPEnumerator GetKeys()
Returns an XPEnumerator that can iterate through the keys in this hashtable.

Specified by:
GetKeys in interface IXPDictionary
Overrides:
GetKeys in class XPHashtable
Returns:
An XPEnumerator that can iterate through the keys in this hashtable.

GetSize

public int GetSize()
Returns the number of elements in this hashtable.

Specified by:
GetSize in interface IXPDictionary
Overrides:
GetSize in class XPHashtable
Returns:
The number of elements in this hashtable.

IsEmpty

public boolean IsEmpty()
Tests if this hashtable has no elements.

Overrides:
IsEmpty in class XPHashtable
Returns:
true if this hashtable has no elements; false otherwise.

PutElement

public java.lang.Object PutElement(java.lang.Object key,
                                   java.lang.Object _value)
Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

Specified by:
PutElement in interface IXPDictionary
Overrides:
PutElement in class XPHashtable
Parameters:
key - the hashtable key.
_value - the value.
Returns:
the previous value of the specified key in this hashtable, or null if it did not have one.

RemoveElement

public java.lang.Object RemoveElement(java.lang.Object key)
Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.

Specified by:
RemoveElement in interface IXPDictionary
Overrides:
RemoveElement in class XPHashtable
Parameters:
key - the key that needs to be removed.
Returns:
the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.

GetUnderlyingObject

public java.util.HashMap GetUnderlyingObject()
Returns the platfrom specific object that this class wraps.

Overrides:
GetUnderlyingObject in class XPHashtable
Returns:
An instance of HashMap.

GetEnumerator

public IXPDictionaryEnumerator GetEnumerator()
Return a non-synchronized enumerator over the elements of the underlying XPHashtable per the common behavior of Java and C#.

Specified by:
GetEnumerator in interface IXPDictionary
Overrides:
GetEnumerator in class XPHashtable
Returns:
IXPDictionaryEnumerator


Copyright 2002, 2003, 2004 Plumtree Software Inc. All Rights Reserved.