anthill.types
Class SHAHashedKeyword

java.lang.Object
  |
  +--anthill.util.SHADigest
        |
        +--anthill.types.SHAHashedKeyword
All Implemented Interfaces:
Closeness, Comparable, Externalizable, HashedKeyword, Serializable

public class SHAHashedKeyword
extends SHADigest
implements HashedKeyword, Serializable

The class SHAHashedKeyword 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: 1.2 $
Author:
Hein Meling
See Also:
Serialized Form

Field Summary
protected  String keyword
          The keyword for this SHAHashedKeyword object.
 
Fields inherited from class anthill.util.SHADigest
digest, DIGEST_SIZE, DIGEST_TYPE, hashcode, random, RANDOM_TYPE, rdigest
 
Fields inherited from interface anthill.types.HashedKeyword
NAME
 
Constructor Summary
SHAHashedKeyword()
          Default constructor for externalization.
SHAHashedKeyword(boolean secure)
          Creates a new SHAHashedKeyword instance based on a randomly generated SHA-1 hash key.
SHAHashedKeyword(boolean secure, 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.
SHAHashedKeyword(Factory factory, String name)
          Default constructor for externalization.
SHAHashedKeyword(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
 String getKeyword()
          Returns the keyword associated with this SHAHashedKeyword object.
 void init(boolean secure, String keyword)
           
 void init(String keyword)
          Initializes the hashed keyword by setting the keyword contained in it.
 void readExternal(ObjectInput in)
          Marshals this SHAHashedKeyword to the specified output stream.
 String toString()
          Returns a string representation of the object.
 void writeExternal(ObjectOutput out)
          Marshals this SHAHashedKeyword to the specified output stream.
 
Methods inherited from class anthill.util.SHADigest
compareTo, compareTo, computeDigest, computeHash, computeRandomSHA, equals, getBytes, hashCode, initRandom, isCloser
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface anthill.types.HashedKeyword
getBytes
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface anthill.types.Closeness
isCloser
 

Field Detail

keyword

protected String keyword
The keyword for this SHAHashedKeyword object.

Constructor Detail

SHAHashedKeyword

public SHAHashedKeyword()
Default constructor for externalization.


SHAHashedKeyword

public SHAHashedKeyword(Factory factory,
                        String name)
Default constructor for externalization.


SHAHashedKeyword

public SHAHashedKeyword(boolean secure)
Creates a new SHAHashedKeyword 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.

SHAHashedKeyword

public SHAHashedKeyword(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.

SHAHashedKeyword

public SHAHashedKeyword(boolean secure,
                        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.
Method Detail

init

public void init(String keyword)
Description copied from interface: HashedKeyword
Initializes the hashed keyword by setting the keyword contained in it.

Specified by:
init in interface HashedKeyword

init

public void init(boolean secure,
                 String keyword)

getKeyword

public String getKeyword()
Returns the keyword associated with this SHAHashedKeyword object.

Specified by:
getKeyword in interface HashedKeyword
Returns:
keyword the keyword string associated with this SHAHashedKeyword.

toString

public String toString()
Returns a string representation of the object.

Overrides:
toString in class SHADigest

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Marshals this SHAHashedKeyword to the specified output stream.

Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class SHADigest
Parameters:
in - an ObjectInput stream object
Throws:
IOException - if an error occurs

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Marshals this SHAHashedKeyword to the specified output stream.

Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class SHADigest
Parameters:
out - an ObjectOutput stream object
Throws:
IOException - if an error occurs