|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.etill.framework.supervisor.GenericKey
GenericKey is a convenience class which provides function to easily generate Hashtable keys from compound strings. As an example, the Framework extends this class to generate hash keys from a combination of
To create your own key type, create a class that extends GenericKey and implement a constructor for the class that:
keys
Vector with one element for each string to
be included in the hash value and then
hashcodeValue
instance variable using the
calculateHashCode
method.
As an example, here is the source code for the Payment key mentioned above:
public PaymentKey (String merchantNumber, String orderNumber, String paymentNumber)
{
keys = new Vector(3);
keys.addElement(merchantNumber);
keys.addElement(orderNumber);
keys.addElement(paymentNumber);
hashcodeValue = calculateHashCode();
}
Once this key object has been created, it can be used as the key value in a Hashtable
since this class also implements the methods that Hashtable requires for an object
to serve as a key (equals
and hashCode
).
Hashtable
, Serialized FormField Summary | |
---|---|
protected int |
hashcodeValue
Contains the hashcode for the given set of strings. |
protected Vector |
keys
Contains the strings that will be combined to determine the hashcode value |
protected static String |
SEPARATOR
|
Constructor Summary | |
---|---|
GenericKey()
|
Method Summary | |
---|---|
int |
calculateHashCode()
Returns a Java-generated hash code based on the contents of the keys
Vector. |
int |
calculateHashCode11()
|
protected String |
elementAt(int i)
Convenience method to provide access to the individual strings contained in the protected keys Vector. |
boolean |
equals(Object aKey)
Indicates whether the input object is an equivalent of this key object. |
int |
hashCode()
Returns this key object's hashcode value. |
String |
toString()
Returns a string representation of this object for tracing purposes. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final String SEPARATOR
protected Vector keys
protected int hashcodeValue
calculateHashCode
method.Constructor Detail |
public GenericKey()
Method Detail |
protected String elementAt(int i)
keys
Vector.i
- an int containing the index if the Vector element to be returned.public int calculateHashCode()
keys
Vector.
Concatenates all of the strings in the keys
Vector together and then
calcuates a hashcode value using the resulting String's hashCode
method.
hashcodeValue
instance variable.public int calculateHashCode11()
public boolean equals(Object aKey)
equals
in class Object
true
if the objects match, false
if not.public int hashCode()
hashCode
in class Object
hashcodeValue
instance
variable.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |