ariba.util.core
Class MultiKeyHashtable

java.lang.Object
  extended by ariba.util.core.MultiKeyHashtable
All Implemented Interfaces:
java.lang.Cloneable

public class MultiKeyHashtable
extends java.lang.Object
implements java.lang.Cloneable

A MultiKeyHashtable class that allows for multiple keys per entry. This is useful when several keys are required to uniquely identify an object. For example, to uniquely identify a Method, we must have the Class and the name of the Method. Note that this class is not thread-safe. This does NOT currently support removing values.


Constructor Summary
MultiKeyHashtable(int keyCount)
          Constructs a new, empty MultiKeyHashtable which uses the specified number of keys.
MultiKeyHashtable(int keyCount, int initialSize, boolean useIdentityComparison)
          Constructs a new, empty MultiKeyHashtable which uses the specified number of keys, initial size, and whether or not comparisons use the 'equals' method or simply '=='.
 
Method Summary
 void add(MultiKeyHashtable otherHashtable)
          Adds all the items from otherHashtable to the reciever.
 java.lang.Object clone()
          Creates a copy of the receiver including a copy of the internal keys and values arrays.
 java.lang.Object get(java.lang.Object key0, java.lang.Object key1)
          Locates and returns the value keyed by the two keys key0, key1.
 java.lang.Object get(java.lang.Object key0, java.lang.Object key1, java.lang.Object key2)
          Locates and returns the value keyed by the three keys key0, key1, key2.
 java.lang.Object get(java.lang.Object key0, java.lang.Object key1, java.lang.Object key2, java.lang.Object key3)
          Locates and returns the value keyed by the fours keys key0, key1, key2, key3.
 int keyCount()
          The number of keys expected by the table.
 java.lang.Object put(java.lang.Object key0, java.lang.Object key1, java.lang.Object value)
          Inserts the value keyed by the two keys key0, key1.
 java.lang.Object put(java.lang.Object key0, java.lang.Object key1, java.lang.Object key2, java.lang.Object value)
          Inserts the value keyed by the three keys key0, key1, key2.
 java.lang.Object put(java.lang.Object key0, java.lang.Object key1, java.lang.Object key2, java.lang.Object key3, java.lang.Object value)
          Inserts the value keyed by the four keys key0, key1, key2, key3.
 java.lang.Object putIfAbsent(java.lang.Object key0, java.lang.Object key1, java.lang.Object value)
          See put(..).
 java.lang.Object putIfAbsent(java.lang.Object key0, java.lang.Object key1, java.lang.Object key2, java.lang.Object value)
          See put(..).
 java.lang.Object putIfAbsent(java.lang.Object key0, java.lang.Object key1, java.lang.Object key2, java.lang.Object key3, java.lang.Object value)
          See put(..).
 java.lang.Object remove(java.lang.Object[] targetKeyList)
          Removes from the table the object value for a list of target keys.
 int size()
          The current size (or number of entries) in the table.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiKeyHashtable

public MultiKeyHashtable(int keyCount)
Constructs a new, empty MultiKeyHashtable which uses the specified number of keys.

Parameters:
keyCount - the number of keys which the table will use. All gets and puts must use this number of keys to access the table.

MultiKeyHashtable

public MultiKeyHashtable(int keyCount,
                         int initialSize,
                         boolean useIdentityComparison)
Constructs a new, empty MultiKeyHashtable which uses the specified number of keys, initial size, and whether or not comparisons use the 'equals' method or simply '=='.

Parameters:
keyCount - the number of keys which the table will use. All gets and puts must use this number of keys to access the table.
initialSize - the number of slots created when the hashtable is first created.
useIdentityComparison - a flag to inidicate if the internal comparisons should use the 'equals' method or simply use '=='.
Method Detail

remove

public java.lang.Object remove(java.lang.Object[] targetKeyList)
Removes from the table the object value for a list of target keys.

Parameters:
targetKeyList - the list of target keys to remove.
Returns:
the existing value for the target keys or null if no existing value.

get

public java.lang.Object get(java.lang.Object key0,
                            java.lang.Object key1)
Locates and returns the value keyed by the two keys key0, key1. This puts the keys into and internal, shared keyList, so its imperative that you lock around this and all access to this class if its to be used in a multi-threaded scenario.

Parameters:
key0 - the first key.
key1 - the second key.
Returns:
Returns the value keyed by key0, key1 or null if not found.

get

public java.lang.Object get(java.lang.Object key0,
                            java.lang.Object key1,
                            java.lang.Object key2)
Locates and returns the value keyed by the three keys key0, key1, key2. This puts the keys into and internal, shared keyList, so its imperative that you lock around this and all access to this class if its to be used in a multi-threaded scenario.

Parameters:
key0 - the first key.
key1 - the second key.
key2 - the second key.
Returns:
Returns the value keyed by key0, key1, key2 or null if not found.

get

public java.lang.Object get(java.lang.Object key0,
                            java.lang.Object key1,
                            java.lang.Object key2,
                            java.lang.Object key3)
Locates and returns the value keyed by the fours keys key0, key1, key2, key3. This puts the keys into and internal, shared keyList, so its imperative that you lock around this and all access to this class if its to be used in a multi-threaded scenario.

Parameters:
key0 - the first key.
key1 - the second key.
key2 - the second key.
key3 - the second key.
Returns:
Returns the value keyed by key0, key1, key2, key3 or null if not found.

put

public java.lang.Object put(java.lang.Object key0,
                            java.lang.Object key1,
                            java.lang.Object value)
Inserts the value keyed by the two keys key0, key1. This puts the keys into and internal, shared keyList, so its imperative that you lock around this and all access to this class if its to be used in a multi-threaded scenario.

Parameters:
key0 - the first key.
key1 - the second key.
Returns:
Returns the value keyed by key0, key1 or null if not found.

put

public java.lang.Object put(java.lang.Object key0,
                            java.lang.Object key1,
                            java.lang.Object key2,
                            java.lang.Object value)
Inserts the value keyed by the three keys key0, key1, key2. This puts the keys into and internal, shared keyList, so its imperative that you lock around this and all access to this class if its to be used in a multi-threaded scenario.

Parameters:
key0 - the first key.
key1 - the second key.
key2 - the third key.
Returns:
Returns the value keyed by key0, key1, key2 or null if not found.

put

public java.lang.Object put(java.lang.Object key0,
                            java.lang.Object key1,
                            java.lang.Object key2,
                            java.lang.Object key3,
                            java.lang.Object value)
Inserts the value keyed by the four keys key0, key1, key2, key3. This puts the keys into and internal, shared keyList, so its imperative that you lock around this and all access to this class if its to be used in a multi-threaded scenario.

Parameters:
key0 - the first key.
key1 - the second key.
key2 - the third key.
key3 - the fourth key.
Returns:
Returns the value keyed by key0, key1, key2, key3 or null if not found.

putIfAbsent

public java.lang.Object putIfAbsent(java.lang.Object key0,
                                    java.lang.Object key1,
                                    java.lang.Object value)
See put(..). This is the same as the corresponding put() method, except it will not replace the existing value if one already exists. In either case, the return value is the existing value.

Parameters:
key0 - the first key.
key1 - the second key.
Returns:
Returns the value keyed by key0, key1 or null if not found.

putIfAbsent

public java.lang.Object putIfAbsent(java.lang.Object key0,
                                    java.lang.Object key1,
                                    java.lang.Object key2,
                                    java.lang.Object value)
See put(..). This is the same as the corresponding put() method, except it will not replace the existing value if one already exists. In either case, the return value is the existing value.

Parameters:
key0 - the first key.
key1 - the second key.
key2 - the third key.
Returns:
Returns the value keyed by key0, key1, key2 or null if not found.

putIfAbsent

public java.lang.Object putIfAbsent(java.lang.Object key0,
                                    java.lang.Object key1,
                                    java.lang.Object key2,
                                    java.lang.Object key3,
                                    java.lang.Object value)
See put(..). This is the same as the corresponding put() method, except it will not replace the existing value if one already exists. In either case, the return value is the existing value.

Parameters:
key0 - the first key.
key1 - the second key.
key2 - the third key.
key3 - the fourth key.
Returns:
Returns the value keyed by key0, key1, key2, key3 or null if not found.

size

public int size()
The current size (or number of entries) in the table. This varies as items are added. Note: remove is currently not supported.

Returns:
Returns the current number of entries in the table.

keyCount

public int keyCount()
The number of keys expected by the table. Once this number is established in the costructor, it will never change.

Returns:
Returns the number of keys expected by the table.

add

public void add(MultiKeyHashtable otherHashtable)
Adds all the items from otherHashtable to the reciever. The keyCounts for both table must be the same, else a runtime exception will be thrown.

Parameters:
otherHashtable - is another MultiKeyHashtable with the same keyCount.

clone

public java.lang.Object clone()
Creates a copy of the receiver including a copy of the internal keys and values arrays.

Overrides:
clone in class java.lang.Object
Returns:
a new copy of the receiver. The internal keys and values arrays are also cloned.


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