oemware.core
Class ByteArray

java.lang.Object
  extended by oemware.core.ByteArray

public final class ByteArray
extends java.lang.Object

The byte array object. This is a thin wrapper around a byte array that implements the hash code method and eauals. This is mainly used for it's comparison features. Null data objects are not allowd. This uses the length and offset in the equals and hash code.

Some of this code was taken from java.util.Arrays.


Field Summary
 byte[] data
           
 int length
           
 int offset
           
 
Constructor Summary
ByteArray()
          Creates an empty byte array.
ByteArray(byte[] pData)
          Create a new byte array with the data.
ByteArray(byte[] pData, int pOffset, int pLength)
          Create a new byte array with a subset of the byte array.
 
Method Summary
 boolean equals(java.lang.Object pObject)
          Overrides the default equals to compare the byte array.
 int hashCode()
          Overrides the default hash code to handle the bye array (or sction of).
 boolean isEqual(byte[] pData)
          Check to see if the data passed is equal to this value.
 java.lang.String toString()
          This is for debug only.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

data

public byte[] data

length

public volatile int length

offset

public volatile int offset
Constructor Detail

ByteArray

public ByteArray()
Creates an empty byte array. The data must be set. You must manually set the length.


ByteArray

public ByteArray(byte[] pData)
Create a new byte array with the data. The offset is set to zero and the length is set to the length of the data.

Parameters:
pData - The byte array.

ByteArray

public ByteArray(byte[] pData,
                 int pOffset,
                 int pLength)
Create a new byte array with a subset of the byte array.

Parameters:
pData - The data.
pOffset - The offset in the pData array.
pLength - the length of the data to use.
Method Detail

isEqual

public final boolean isEqual(byte[] pData)
Check to see if the data passed is equal to this value.

Parameters:
pData - The data.
Returns:
True if it's equal.

equals

public final boolean equals(java.lang.Object pObject)
Overrides the default equals to compare the byte array.

Overrides:
equals in class java.lang.Object
Parameters:
pObject - The object to check. May not be null.
Returns:
True if they're equal.

hashCode

public final int hashCode()
Overrides the default hash code to handle the bye array (or sction of).

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code.

toString

public final java.lang.String toString()
This is for debug only. It creates a string of the object.

Overrides:
toString in class java.lang.Object
Returns:
A new string object.


Copyright © 2009 Deft Labs - Released under LGPL, Version 3.0