|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.helidb.lang.hasher.ShortToShortHasher
public class ShortToShortHasher
This is a value-preserving Short
hasher. It does not support null
values.
Hashes have a length of two bytes.
Since this object does not contain any internal state, the singleton instance
INSTANCE
may be used instead of instantiating the class.
Field Summary | |
---|---|
static ShortToShortHasher |
INSTANCE
The singleton instance. |
Constructor Summary | |
---|---|
ShortToShortHasher()
|
Method Summary | |
---|---|
Short |
fromBytes(byte[] barr)
Interpret the serialized hash value. |
int |
getHashLength()
Get the size of the hash in bytes. |
Short |
hash(Short s)
Hash the supplied value. |
boolean |
isPreservingValues()
Does the hashing operation not modify the hashed value at all? This is true if v.equals(hasher.hash(v)) for all values v
accepted by the hasher. |
byte[] |
toBytes(Short s)
Serialize the hash to a byte array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final ShortToShortHasher INSTANCE
Constructor Detail |
---|
public ShortToShortHasher()
Method Detail |
---|
public int getHashLength()
Hasher
byte
array created by Hasher.toBytes(Comparable)
and accepted by
Hasher.fromBytes(byte[])
.
getHashLength
in interface Hasher<Short,Short>
public byte[] toBytes(Short s)
Hasher
For a given Hasher
object, the byte arrays returned by this
method must always be of the same size.
toBytes
in interface Hasher<Short,Short>
s
- The hash to serialize.
public Short fromBytes(byte[] barr)
Hasher
fromBytes
in interface Hasher<Short,Short>
barr
- The serialized hash value.
public Short hash(Short s)
Hasher
Hashing may be a fairly expensive operation, depending on the implementation. Clients should try to reuse the result from this method as much as possible.
hash
in interface Hasher<Short,Short>
s
- The value to hash.
public boolean isPreservingValues()
Hasher
true
if v.equals(hasher.hash(v))
for all values v
accepted by the hasher.
isPreservingValues
in interface Hasher<Short,Short>
true
, always.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |