Package com.portal.pcm
Class AssocArray
java.lang.Object
com.portal.pcm.AssocArray
- Direct Known Subclasses:
SparseArray
The AssocArray (or Associative Array)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Represents a pair of objects, often used to store two related values.class
An implementation ofEnumeration
that iterates over pairs of objects. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all keys and values from the array.boolean
containsKey
(Object key) Returns true if the array contains the value of a specific key.elements()
Get an enumeration of values.Returns a value from the array given its associative key.getPairs()
Returns an enumeration of pairs.boolean
isEmpty()
Returns true if the array is empty.keys()
Get an enumeration of keys.Adds a key:value association to the array.Removes the first instance of key and its associated value.int
size()
Returns the number of keys in the associative array.
-
Field Details
-
keys
A vector that holds the keys used in the system. -
values
A vector that holds the values used in the system.
-
-
Constructor Details
-
AssocArray
public AssocArray()Constructs an Associative Array.
-
-
Method Details
-
elements
Get an enumeration of values.- Returns:
- an Enumeration object for the array values.
-
get
Returns a value from the array given its associative key. If multiple identical keys exist, returns first instance.- Parameters:
key
- - Key object associated with value to lookup.- Returns:
- the value object associated with key.
-
isEmpty
public boolean isEmpty()Returns true if the array is empty.- Returns:
- true if the array is empty.
-
keys
Get an enumeration of keys.- Returns:
- an Enumeration object for the array keys.
-
put
Adds a key:value association to the array.- Parameters:
key
- New associative key.value
- New value to associate with key.- Returns:
- If key was present already, returns old value object.
- Throws:
NullPointerException
- is thrown if value is null.
-
remove
Removes the first instance of key and its associated value.- Parameters:
key
- the key to remove.- Returns:
- The value associated with key.
-
size
public int size()Returns the number of keys in the associative array.- Returns:
- The number of keys stored in the array.
-
clear
public void clear()Removes all keys and values from the array. -
containsKey
Returns true if the array contains the value of a specific key.- Parameters:
key
- Key to look for.- Returns:
- true if key exists in array.
-
getPairs
Returns an enumeration of pairs.This method provides an enumeration over pairs of keys and values.
- Returns:
- An instance of
AssocArray.PairEnumeration
that enumerates the pairs.
-