anthill.util
Class KeyHash
java.lang.Object
|
+--anthill.util.SHADigest
|
+--anthill.util.KeyHash
- All Implemented Interfaces:
- java.lang.Comparable, java.io.Externalizable, java.io.Serializable
- public class KeyHash
- extends SHADigest
The class KeyHash
computes the digest (or hash)
of a specified string keyword, and enables various other classes
to compare keyword hashes and store them in a HashMap
or other collections in need of a hashCode method.
- Version:
- $Revision$
- Author:
- Hein Meling
- See Also:
- Serialized Form
Field Summary |
protected java.lang.String |
keyword
The keyword for this KeyHash object. |
Constructor Summary |
KeyHash()
Default constructor for externalization. |
KeyHash(boolean secure)
Creates a new KeyHash instance based on a randomly
generated SHA-1 hash key. |
KeyHash(boolean secure,
java.lang.String keyword)
Compute a SHA-1 hash value for the specified keyword, or compute
a random SHA-1 identifier if the keyword is equal to null. |
KeyHash(java.lang.String keyword)
Compute a SHA-1 hash value for the specified keyword, or compute
a random SHA-1 identifier if the keyword is equal to null. |
Method Summary |
java.lang.String |
getKeyword()
Returns the keyword associated with this KeyHash object. |
void |
readExternal(java.io.ObjectInput in)
Marshals this KeyHash to the specified output stream. |
java.lang.String |
toString()
Returns a string representation of the object. |
void |
writeExternal(java.io.ObjectOutput out)
Marshals this KeyHash to the specified output stream. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
keyword
protected java.lang.String keyword
- The keyword for this
KeyHash
object.
KeyHash
public KeyHash()
- Default constructor for externalization.
KeyHash
public KeyHash(boolean secure)
- Creates a new
KeyHash
instance based on a randomly
generated SHA-1 hash key.
- Parameters:
secure
- if true, the secure random generator will be used;
otherwise the standard random generator is used.
KeyHash
public KeyHash(java.lang.String keyword)
- Compute a SHA-1 hash value for the specified keyword, or compute
a random SHA-1 identifier if the keyword is equal to null.
- Parameters:
keyword
- A string keyword to be hashed and stored in this object.
KeyHash
public KeyHash(boolean secure,
java.lang.String keyword)
- Compute a SHA-1 hash value for the specified keyword, or compute
a random SHA-1 identifier if the keyword is equal to null.
- Parameters:
secure
- if true, the secure random generator will be used;
otherwise the standard random generator is used.keyword
- a string keyword to be hashed and stored in this object.
getKeyword
public java.lang.String getKeyword()
- Returns the keyword associated with this
KeyHash
object.
- Returns:
- keyword the keyword string associated with this
KeyHash
.
toString
public java.lang.String toString()
- Returns a string representation of the object.
- Overrides:
toString
in class SHADigest
readExternal
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException
- Marshals this
KeyHash
to the specified output stream.
- Overrides:
readExternal
in class SHADigest
- Parameters:
in
- an ObjectInput
stream object- Throws:
java.io.IOException
- if an error occurs
writeExternal
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
- Marshals this
KeyHash
to the specified output stream.
- Overrides:
writeExternal
in class SHADigest
- Parameters:
out
- an ObjectOutput
stream object- Throws:
java.io.IOException
- if an error occurs