|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--anthill.types.SimpleHashedKeyword
In this simple implementation of the HashedKeyword
interface,
keywords are hashed using the hashCode
method of Java string.
The main advantage of this implementation with respect to more robust
hashing functions like SHA are its small memory footprint and its performance.
Field Summary |
Fields inherited from interface anthill.types.HashedKeyword |
NAME |
Constructor Summary | |
SimpleHashedKeyword(Factory factory,
String name)
Default constructor for externalization. |
|
SimpleHashedKeyword(String keyword)
Constructs a new hashed keyword starting from a plaintext keyword. |
Method Summary | |
int |
compareTo(Object obj)
Compares this object with the specified object for order. |
boolean |
equals(Object obj)
Check whether this hashed keyword is equal to the specified object. |
byte[] |
getBytes()
Returns the bytes representing the hashed value of the keyword. |
String |
getKeyword()
Returns the keyword associated with this hashed keyword. |
int |
hashCode()
Returns a hash code value for the object. |
void |
init(String keyword)
Initializes a new hashed keyword starting from a plaintext keyword. |
int |
isCloser(Object x,
Object y)
Compares this object against the provided objects for
closeness. |
String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SimpleHashedKeyword(Factory factory, String name)
public SimpleHashedKeyword(String keyword)
Method Detail |
public void init(String keyword)
init
in interface HashedKeyword
public String getKeyword()
getKeyword
in interface HashedKeyword
public byte[] getBytes()
getBytes
in interface HashedKeyword
public String toString()
toString
in class Object
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int compareTo(Object obj) throws ClassCastException
compareTo
in interface Comparable
obj
- the object to be compared
ClassCastException
public int isCloser(Object x, Object y)
this
object against the provided objects for
closeness. An implementation of this method must return an
int
according to the following rules:
-1 is returned if the value of x is considered closer to this object than the value of y. +1 is returned if the value of y is considered closer to this object than the value of x. 0 is returned if the values of x and y are equally close to this object.
isCloser
in interface Closeness
ClassCastException
- if x or y are not SimpleHashedKeyword
objects
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |