com.ibm.dse.applsrv.aa
Class Dictionary

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--com.ibm.dse.applsrv.aa.Dictionary

public class Dictionary
extends java.util.Dictionary
implements java.lang.Cloneable, java.io.Serializable

General dictionary class.

See Also:
Serialized Form

Constructor Summary
Dictionary()
           
Dictionary(int initialCapacity)
           
Dictionary(int initialCapacity, float loadFactor)
          Constructs a new, empty dictionary with the specified initial capacity and the specified load factor.
Dictionary(java.lang.Object key, boolean value)
          Create and return a dictionary initialized to one key/value pair.
Dictionary(java.lang.Object key, int value)
          Create and return a dictionary initialized to one key/value pair.
Dictionary(java.lang.Object key1, int value1, java.lang.Object key2, int value2)
          Create and return a dictionary initialized to two key/value pairs.
Dictionary(java.lang.Object key, java.lang.Object value)
          Create and return a dictionary initialized to one key/value pair.
Dictionary(java.lang.Object key1, java.lang.Object value1, java.lang.Object key2, java.lang.Object value2)
          Create and return a dictionary initialized to two key/value pairs.
 
Method Summary
 void add(java.lang.Object key, boolean value)
          Add a key with a boolean value to this dictionary.
 void add(java.lang.Object key, java.lang.Object value)
          Adds the specified value to this dictionary associated with the specified key.
 void addAll(java.util.Dictionary d)
          Add all of the entries in the specified dictionary into the current dictionary.
 void addAll(java.lang.String[] v)
          Add all of the entries in the specified list into the current dictionary.
 void addnn(java.lang.Object key, java.lang.Object value)
          Adds the specified value to this dictionary associated with the specified key.
 void append(java.lang.Object key, java.lang.String value)
          Appended the specified value to an existing value for the same key.
 java.util.Hashtable asHashtable()
          Return a copy of this dictionary as a Hashtable.
 java.lang.String asList()
          Returns a rather long string representation of this dictionary.
static java.lang.String asList(Dictionary dictionary)
          Return a string representation of the specified dictionary.
 java.lang.Object at(java.lang.Object key)
          Returns the value associated with the specified key.
 void clear()
          Clears this dictionary so that it contains no keys.
 java.lang.Object clone()
          Creates a shallow copy of this dictionary.
 boolean contains(java.lang.Object value)
          Tests if some key maps into the specified value in this dictionary.
 boolean containsKey(java.lang.Object key)
          Tests if the specified object is a key in this dictionary.
 Dictionary copy()
          Return a copy of this dictionary.
static Dictionary copy(Dictionary aDictionary)
          Return a copy of the specified dictionary or null if the argument is null.
 java.util.Enumeration elements()
          Returns an enumeration of the values in this dictionary.
 java.util.Enumeration enum()
          Returns an enumeration of the values in this dictionary.
static Dictionary from(java.util.Dictionary dictionary)
          Create and return a dictionary consisting of all the elements of the specified dictionary.
static Dictionary from(java.lang.String s)
          Create and return a dictionary based on the argument string which is expected to be of the format: "key1=value1 key2=value2 ...
static Dictionary from(java.lang.String[] v)
          Create and return a dictionary based on the alternating keys & values in the specified list.
 java.lang.Object get(java.lang.Object key)
          Returns the value associated with the specified key.
 java.lang.Object get(java.lang.Object key, java.lang.Object defaultValue)
          Returns the value associated with the specified key or the default value if the key is not found.
 boolean isEmpty()
          Checks if this dictionary is empty.
 java.util.Enumeration keys()
          Returns an enumeration of the keys in this dictionary.
 Array keysAsArray()
          Returns an array of the keys in this dictionary.
 java.lang.String[] keysAsStrings()
          Returns the keys of this dictionary as an array of string - of course the keys actually have to be string for this method to work.
 Array keysForValue(java.lang.Object value)
          Return a list of keys who's values are equal to the specified value.
 void load(java.lang.String s)
          Fill this dictionary with key-value pairs based on the argument string which is expected to be of the format: "key1=value1 key2=value2 ...
 java.lang.Object put(java.lang.Object key, boolean value)
          Add a key with a boolean value to this dictionary.
 java.lang.Object put(java.lang.Object key, char value)
          Add a key with a character value to this dictionary.
 java.lang.Object put(java.lang.Object key, int value)
          Add a key with a integer value to this dictionary.
 java.lang.Object put(java.lang.Object key, long value)
          Add a key with a long integer value to this dictionary.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Adds the specified value to this dictionary associated with the specified key.
protected  void rehash()
          Rehashes the contents of this dictionary into a dictionary with a larger capacity.
 java.lang.Object remove(java.lang.Object key)
          Removes the key (and its corresponding value) from this dictionary.
 void set(java.util.Dictionary d)
          Set the contents of this dictionary to be the same as the contents of the specified dictionary.
 void set(java.lang.Object key, java.lang.Object value)
          Set the contents of this dictionary to be the single specified key/value pair.
 int size()
          Return the size (i.e.
 java.lang.String toString()
          Returns a rather long string representation of this dictionary.
 java.lang.Object[] values()
          Returns the values of this dictionary as an object array.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Dictionary

public Dictionary()

Dictionary

public Dictionary(int initialCapacity)
Parameters:
initialCapacity - int

Dictionary

public Dictionary(int initialCapacity,
                  float loadFactor)
Constructs a new, empty dictionary with the specified initial capacity and the specified load factor.
Parameters:
initialCapacity - int - the initial capacity of the dictionary.
loadFactor - float - a number between 0.0 and 1.0.
Throws:
java.lang.IllegalArgumentException - - if the initial capacity is less than or equal to zero, or if the load factor is less than or equal to zero.

Dictionary

public Dictionary(java.lang.Object key,
                  int value)
Create and return a dictionary initialized to one key/value pair.
Parameters:
key - Object - the new key.
value - int - the corresponding value.

Dictionary

public Dictionary(java.lang.Object key1,
                  int value1,
                  java.lang.Object key2,
                  int value2)
Create and return a dictionary initialized to two key/value pairs. If the 2 keys are the same then the second overrides the first.
Parameters:
key1 - Object - the first key.
value1 - int - the corresponding value.
key2 - Object - the second key.
value2 - int - the corresponding value.

Dictionary

public Dictionary(java.lang.Object key,
                  java.lang.Object value)
Create and return a dictionary initialized to one key/value pair.
Parameters:
key - Object - the new key.
value - Object - the corresponding value.

Dictionary

public Dictionary(java.lang.Object key1,
                  java.lang.Object value1,
                  java.lang.Object key2,
                  java.lang.Object value2)
Create and return a dictionary initialized to two key/value pairs. If the 2 keys are the same then the second overrides the first.
Parameters:
key1 - Object - the first key.
value1 - Object - the corresponding value.
key2 - Object - the second key.
value2 - Object - the corresponding value.

Dictionary

public Dictionary(java.lang.Object key,
                  boolean value)
Create and return a dictionary initialized to one key/value pair.
Parameters:
key - Object - the new key.
value - boolean - the corresponding value.
Method Detail

add

public void add(java.lang.Object key,
                java.lang.Object value)
Adds the specified value to this dictionary associated with the specified key. If the key already exists then its value is replaces with this one.
Parameters:
key - Object - the search key.
value - Object - the associated value.
Throws:
NullPointerException - - if key or value is null.

add

public void add(java.lang.Object key,
                boolean value)
Add a key with a boolean value to this dictionary.
Parameters:
key - Object - the dictionary key.
value - boolean - the boolean value.
Throws:
NullPointerException - - if the key is null.

addAll

public void addAll(java.lang.String[] v)
Add all of the entries in the specified list into the current dictionary. The entries are: "key1" "value1" "key2" "value2" ...
Parameters:
v - String[] - the key/value pairs to load.

addAll

public void addAll(java.util.Dictionary d)
Add all of the entries in the specified dictionary into the current dictionary.
Parameters:
d - Dictionary - the dictionary to load.

addnn

public void addnn(java.lang.Object key,
                  java.lang.Object value)
Adds the specified value to this dictionary associated with the specified key. If the key already exists then its value is replaces with this one. If either is null then do nothing.
Parameters:
key - Object - the search key.
value - Object - the associated value.

append

public void append(java.lang.Object key,
                   java.lang.String value)
Appended the specified value to an existing value for the same key.
Parameters:
key - Object - the search key.
value - String - the value to append.
Throws:
NullPointerException - - if key or value is null.

asHashtable

public java.util.Hashtable asHashtable()
Return a copy of this dictionary as a Hashtable.
Returns:
Hashtable - the Hashtable copy of this dictionary.

asList

public java.lang.String asList()
Returns a rather long string representation of this dictionary.
Returns:
String - a string representation of this dictionary.

asList

public static java.lang.String asList(Dictionary dictionary)
Return a string representation of the specified dictionary.
Parameters:
dictionary - Dictionary - the dictionary to enlist.
Returns:
String - the enlist dictionary.

at

public java.lang.Object at(java.lang.Object key)
Returns the value associated with the specified key.
Parameters:
key - Object - the search key.
Returns:
Object - the associated value or null if the key was not found.
Throws:
NullPointerException - - if key is null.

clear

public void clear()
Clears this dictionary so that it contains no keys.

clone

public java.lang.Object clone()
Creates a shallow copy of this dictionary. The keys and values themselves are not cloned.
Overrides:
clone in class java.lang.Object
Returns:
Object - a clone of this dictionary.

contains

public boolean contains(java.lang.Object value)
Tests if some key maps into the specified value in this dictionary. This operation is more expensive than the containsKey method.
Parameters:
Object - value - a value to search for.
Returns:
boolean - true if some key maps to the value argument in this dictionary; false otherwise.
Throws:
NullPointerException - - if the value is null.

containsKey

public boolean containsKey(java.lang.Object key)
Tests if the specified object is a key in this dictionary.
Parameters:
Object - key - a key to search for.
Returns:
boolean - true if the key is found; false otherwise.
Throws:
NullPointerException - - if key is null.

copy

public Dictionary copy()
Return a copy of this dictionary.
Returns:
Dictionary - the copy of this dictionary.

copy

public static Dictionary copy(Dictionary aDictionary)
Return a copy of the specified dictionary or null if the argument is null.
Parameters:
aDictionary - Dictionary - the dictionary to copy or null.
Returns:
Dictionary - the copy of the dictionary or null.

elements

public java.util.Enumeration elements()
Returns an enumeration of the values in this dictionary. Use the Enumeration methods on the returned object to fetch the elements sequentially.
Overrides:
elements in class java.util.Dictionary
Returns:
Enumeration - the enumeration of the values in this dictionary.

enum

public java.util.Enumeration enum()
Returns an enumeration of the values in this dictionary.
Returns:
Enumeration - the enumerated values.

from

public static Dictionary from(java.lang.String[] v)
Create and return a dictionary based on the alternating keys & values in the specified list.
Parameters:
v - String[] - the list of key/value pairs.
Returns:
Dictionary - the dictionary.

from

public static Dictionary from(java.lang.String s)
Create and return a dictionary based on the argument string which is expected to be of the format: "key1=value1 key2=value2 ... keyN=valueN".
Parameters:
s - String - the string to parse.
Returns:
Dictionary - the dictionary.

from

public static Dictionary from(java.util.Dictionary dictionary)
Create and return a dictionary consisting of all the elements of the specified dictionary.
Parameters:
dictionary - java.util.Dictionary - the dictionary to read.
Returns:
Dictionary - the new dictionary.

get

public java.lang.Object get(java.lang.Object key)
Returns the value associated with the specified key.
Overrides:
get in class java.util.Dictionary
Parameters:
key - Object - the search key.
Returns:
Object - the associated value or null if the key was not found.
Throws:
NullPointerException - - if key is null.

get

public java.lang.Object get(java.lang.Object key,
                            java.lang.Object defaultValue)
Returns the value associated with the specified key or the default value if the key is not found.
Parameters:
key - Object - the search key.
defaultValue - Object - the default value.
Returns:
Object - the associated value or defaultValue if the key was not found.
Throws:
NullPointerException - - if key is null.

isEmpty

public boolean isEmpty()
Checks if this dictionary is empty.
Overrides:
isEmpty in class java.util.Dictionary
Returns:
boolean - true if this dictionary is empty else false.

keys

public java.util.Enumeration keys()
Returns an enumeration of the keys in this dictionary.
Overrides:
keys in class java.util.Dictionary
Returns:
Enumeration - the enumeration of the keys in this dictionary.

keysAsArray

public Array keysAsArray()
Returns an array of the keys in this dictionary.
Returns:
Array - the array of keys.

keysAsStrings

public java.lang.String[] keysAsStrings()
Returns the keys of this dictionary as an array of string - of course the keys actually have to be string for this method to work.
Returns:
String[] - the keys.

keysForValue

public Array keysForValue(java.lang.Object value)
Return a list of keys who's values are equal to the specified value. The value cannot be null.
Returns:
Array - the list of matching keys.

load

public void load(java.lang.String s)
Fill this dictionary with key-value pairs based on the argument string which is expected to be of the format: "key1=value1 key2=value2 ... keyN=valueN".
Parameters:
s - String - the string to parse.

put

public java.lang.Object put(java.lang.Object key,
                            char value)
Add a key with a character value to this dictionary.
Parameters:
key - Object - the dictionary key.
value - char - the character value.
Returns:
- the previous value of the specified key in this dictionary, or null if it did not have one.
Throws:
NullPointerException - - if the key is null.

put

public java.lang.Object put(java.lang.Object key,
                            int value)
Add a key with a integer value to this dictionary.
Parameters:
key - Object - the dictionary key.
value - int - the integer value.
Returns:
- the previous value of the specified key in this dictionary, or null if it did not have one.
Throws:
NullPointerException - - if the key is null.

put

public java.lang.Object put(java.lang.Object key,
                            long value)
Add a key with a long integer value to this dictionary.
Parameters:
key - Object - the dictionary key.
value - long - the long integer value.
Returns:
- the previous value of the specified key in this dictionary, or null if it did not have one.
Throws:
NullPointerException - - if the key is null.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Adds the specified value to this dictionary associated with the specified key. If the key already exists then its value is replaces with this one.
Overrides:
put in class java.util.Dictionary
Parameters:
key - Object - the search key.
value - Object - the associated value.
Returns:
Object - the previous associated value or null if the key was not found.
Throws:
NullPointerException - - if key or value is null.

put

public java.lang.Object put(java.lang.Object key,
                            boolean value)
Add a key with a boolean value to this dictionary.
Parameters:
key - Object - the dictionary key.
value - boolean - the boolean value.
Returns:
- the previous value of the specified key in this dictionary, or null if it did not have one.
Throws:
NullPointerException - - if the key is null.

rehash

protected void rehash()
Rehashes the contents of this dictionary into a dictionary with a larger capacity. This method is called automatically when the number of keys in this dictionary exceeds this dictionary's capacity and load factor.

remove

public java.lang.Object remove(java.lang.Object key)
Removes the key (and its corresponding value) from this dictionary. This method does nothing if the key is not in this dictionary.
Overrides:
remove in class java.util.Dictionary
Parameters:
key - Object - the key to be removed.
Returns:
Object - the associated value or null if the key was not found.
Throws:
NullPointerException - - if key is null.

set

public void set(java.lang.Object key,
                java.lang.Object value)
Set the contents of this dictionary to be the single specified key/value pair.
Parameters:
key - Object - the new key.
value - Object - the corresponding value.

set

public void set(java.util.Dictionary d)
Set the contents of this dictionary to be the same as the contents of the specified dictionary.
Parameters:
d - java.util.Dictionary - the hash table to load.

size

public int size()
Return the size (i.e. number of keys) in this dictionary.
Overrides:
size in class java.util.Dictionary
Returns:
int - the size.

toString

public java.lang.String toString()
Returns a rather long string representation of this dictionary.
Overrides:
toString in class java.lang.Object
Returns:
String - a string representation of this dictionary.

values

public java.lang.Object[] values()
Returns the values of this dictionary as an object array.
Returns:
Object[] - the values.