|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.jini.outrigger.snaplogstore.ByteArrayWrapper
class ByteArrayWrapper
In the backend Uuid
s are represented using
byte[16]
s. This works fine is most places, but
sometimes we need to use a Uuid
as a key in a hash
table. Arrays do not make good hash table keys so we wrap the array
in one of these to provide suitable implementations of
hashCode
and equals
.
This method also has utility methods for converting
Uuid
s to and from byte[16]
s.
Field Summary | |
---|---|
private int |
hash
A 32 bit hash of uuid |
private byte[] |
uuid
The 16 bytes being wrapped |
Constructor Summary | |
---|---|
ByteArrayWrapper(byte[] v)
Create a new ByteArrayWrapper that
wraps the provided array. |
Method Summary | |
---|---|
boolean |
equals(Object o)
|
int |
hashCode()
|
(package private) static int |
hashFor(byte[] uuid)
Compute an equivalent hash to Uuid . |
(package private) static byte[] |
toByteArray(Uuid uuid)
Encode the passed Uuid in to a newly allocated
byte[16] in big-endian byte order. |
(package private) static Uuid |
toUuid(byte[] bits)
Create a new Uuid that matches the bit pattern
in the passed byte[] . |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private byte[] uuid
private int hash
Constructor Detail |
---|
ByteArrayWrapper(byte[] v)
ByteArrayWrapper
that
wraps the provided array.
v
- The array to wrap.
IllegalArgumentException
- if v.length
is
not 16.Method Detail |
---|
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
static byte[] toByteArray(Uuid uuid)
Uuid
in to a newly allocated
byte[16]
in big-endian byte order.
uuid
- the Uuid
to encode.
byte[16]
initialized to the
same bit pattern as uuid
.
NullPointerException
- if uuid
is
null
.static Uuid toUuid(byte[] bits)
Uuid
that matches the bit pattern
in the passed byte[]
. Assumes the bit pattern
is in big-endian byte order.
bits
- the byte[]
with bit pattern
Uuid
that matches the
passed byte[]
.
NullPointerException
- if uuid
is
null
.
IllegalArgumentException
- if bits.length
is not 16.static int hashFor(byte[] uuid)
Uuid
.
IllegalArgumentException
- if uuid.length
is not 16.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |