com.ccg.util
Class LookupOrdered

java.lang.Object
  extended by com.ccg.util.LookupOrdered
All Implemented Interfaces:
Lookup, LookupKeyed, Cloneable

public class LookupOrdered
extends Object
implements LookupKeyed, Cloneable

A LookupKeyed class which maintains key order. This class implements the LookupKeyed interface and provides some additional functionality. Its key additions are:

Since:
1.0
Version:
$Revision: 1.1.1.1 $
Author:
$Author: pkb $
See Also:
LookupKeyed, LookupINI

Constructor Summary
LookupOrdered()
          Initializes object to an empty LookupKeyed table.
 
Method Summary
 void add(Object key, Object data)
          Add a new key/value pair to the lookup table.
 Object clone()
          Makes a fairly light weight clone of the object.
 Object get(Object key)
          Fetch the value associated with a "key" Try to lookup the Object which is associated with the key.
 Enumeration getKeys()
          Get enumeration of all of the keys in the lookup table.
 String getString(Object key)
          Fetch a String "value" associated with a "key".
 void print(PrintWriter pw)
          Print the contents like a Java Properties file.
 void remove(Object key)
          Removes a object from the table based on key value.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LookupOrdered

public LookupOrdered()
Initializes object to an empty LookupKeyed table. After constructing the object in this fashion, you will want to use one of the add methods to add key/value pairs to the lookup table.

Since:
1.0
See Also:
add(java.lang.Object, java.lang.Object)
Method Detail

clone

public Object clone()
Makes a fairly light weight clone of the object.

This method constructs a lightweight clone of the object. The relationship between the "cloned" object and the original object will be as follows:

Overrides:
clone in class Object
Returns:
Clone of the original object (you may cast it to a LookupOrdered object.
Since:
1.0

add

public void add(Object key,
                Object data)
Add a new key/value pair to the lookup table. This method adds/replaces a key/value pair. The getKeys() method will return the list of keys in the order they are originally added.

Parameters:
key - The "key" to store the data with. If null (which is allowed), then the object will remain unchanged.
data - The "value" to associate with the key. It can be null.
Since:
1.0
See Also:
LookupOrdered(), print(java.io.PrintWriter)

get

public Object get(Object key)
Fetch the value associated with a "key" Try to lookup the Object which is associated with the key. This method will never throw an exception.

Specified by:
get in interface Lookup
Specified by:
get in interface LookupKeyed
Parameters:
key - Key to use to look up object with (if you pass null, you will get null back).
Returns:
Object found (if exists) or null if not found.
Since:
1.0
See Also:
LookupCreate

remove

public void remove(Object key)
Removes a object from the table based on key value.

Parameters:
key - Key to use to look up object with (if you pass null, we don't do anything).
Since:
1.0
See Also:
get(Object)

getString

public String getString(Object key)
Fetch a String "value" associated with a "key". Try to lookup the String object which is associated with the key.

Specified by:
getString in interface Lookup
Specified by:
getString in interface LookupKeyed
Parameters:
key - Key to use to look up object with (if you pass null, you will get null back).
Returns:
Object found (if exists) returned as a String or null if not found. This implies that the objects contained by the Lookup table all support the Object.toString() method without Exception.
Since:
1.0
See Also:
LookupCreate

getKeys

public Enumeration getKeys()
Get enumeration of all of the keys in the lookup table. This implementation returns the list of all of the keys - in the order the keys were added to the lookup table.

Specified by:
getKeys in interface LookupKeyed
Returns:
Enumeration list of all keys in the Lookup table.
Since:
1.0

print

public void print(PrintWriter pw)
Print the contents like a Java Properties file. This method prints the contents of the lookup table in the form expected by the Properties class. In addition, the order the elements are printed should be the same as the way they were added.

Parameters:
pw - Where to print the lookup table in ASCII form.
Since:
1.0
See Also:
add(java.lang.Object, java.lang.Object)


Copyright 1998-1998-2006 null. All Rights Reserved.