Methods Summary |
---|
public boolean | equals(java.lang.Object o)Checks whether this ClassID is equal to another
object.
if (o == null || !(o instanceof ClassID))
return false;
final ClassID cid = (ClassID) o;
if (bytes.length != cid.bytes.length)
return false;
for (int i = 0; i < bytes.length; i++)
if (bytes[i] != cid.bytes[i])
return false;
return true;
|
public byte[] | getBytes()Gets the bytes making out the class ID. They are returned in
correct order, i.e. big-endian.
return bytes;
|
public int | hashCode()
return new String(bytes).hashCode();
|
public int | length()
return LENGTH;
|
public byte[] | read(byte[] src, int offset)Reads the class ID's value from a byte array by turning
little-endian into big-endian.
bytes = new byte[16];
/* Read double word. */
bytes[0] = src[3 + offset];
bytes[1] = src[2 + offset];
bytes[2] = src[1 + offset];
bytes[3] = src[0 + offset];
/* Read first word. */
bytes[4] = src[5 + offset];
bytes[5] = src[4 + offset];
/* Read second word. */
bytes[6] = src[7 + offset];
bytes[7] = src[6 + offset];
/* Read 8 bytes. */
for (int i = 8; i < 16; i++)
bytes[i] = src[i + offset];
return bytes;
|
public void | setBytes(byte[] bytes)Sets the bytes making out the class ID.
for (int i = 0; i < this.bytes.length; i++)
this.bytes[i] = bytes[i];
|
public java.lang.String | toString()Returns a human-readable representation of the Class ID in standard
format "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" .
StringBuffer sbClassId = new StringBuffer(38);
sbClassId.append('{");
for (int i = 0; i < 16; i++)
{
sbClassId.append(HexDump.toHex(bytes[i]));
if (i == 3 || i == 5 || i == 7 || i == 9)
sbClassId.append('-");
}
sbClassId.append('}");
return sbClassId.toString();
|
public void | write(byte[] dst, int offset)Writes the class ID to a byte array in the
little-endian format.
/* Check array size: */
if (dst.length < 16)
throw new ArrayStoreException
("Destination byte[] must have room for at least 16 bytes, " +
"but has a length of only " + dst.length + ".");
/* Write double word. */
dst[0 + offset] = bytes[3];
dst[1 + offset] = bytes[2];
dst[2 + offset] = bytes[1];
dst[3 + offset] = bytes[0];
/* Write first word. */
dst[4 + offset] = bytes[5];
dst[5 + offset] = bytes[4];
/* Write second word. */
dst[6 + offset] = bytes[7];
dst[7 + offset] = bytes[6];
/* Write 8 bytes. */
for (int i = 8; i < 16; i++)
dst[i + offset] = bytes[i];
|