com.ccg.util
Interface Lookup

All Known Subinterfaces:
LookupKeyed
All Known Implementing Classes:
CommandLine, CommandLineUtility, LookupINI, LookupOrdered, LookupProperties, TagLookup

public interface Lookup

Generic "fetch" interface. Seems like I'm always using things that are collections of objects which have a lookup by key function (things like java.util.Hashtable, java.util.Properties, java.applet.Applet, CommandLine as some examples). This interface is provided to allow one to create a wrapper around these types of objects to provide a standard lookup object.

If you design methods which accept a Lookup object, you will gain a lot of flexibility in your methods.

Since:
1.0
Version:
$Revision: 1.1.1.1 $
Author:
$Author: pkb $
See Also:
LookupCreate, CommandLine

Method Summary
 Object get(Object key)
          Fetch the value associated with a "key" Try to lookup the Object which is associated with the key.
 String getString(Object key)
          Fetch a String "value" associated with a "key".
 

Method Detail

get

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

If you are implementing this method in your class, you must be certain that it never invokes the getString(Object) method! Let me repeat: It is permitted for the getString(java.lang.Object) method to invoke this method, but not the other way around! Failure to follow this convention can result in potentially infinite recursion.

Parameters:
key - Key to use to look up object with (if you pass null, you will get null back). If the object passed is non-null, it should not throw any exceptions if the Object.toString() is invoked on it.
Returns:
Object found (if exists) or null if not found.
Since:
1.0
See Also:
LookupCreate

getString

String getString(Object key)
Fetch a String "value" associated with a "key". Try to lookup the String object which is associated with the key. This method should never throw an exception (if implemented correctly). Most implementation will probably just wrap the get(java.lang.Object) method with this method.

Parameters:
key - Key to use to look up object with (if you pass null, you will get null back). If the object passed is non-null, it should not throw any exceptions if the Object.toString() is invoked on it.
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


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