net.i2p.data
Class ByteArray

java.lang.Object
  extended by net.i2p.data.ByteArray
All Implemented Interfaces:
Serializable, Comparable
Direct Known Subclasses:
MsgID, Token

public class ByteArray
extends Object
implements Serializable, Comparable

Wrap up an array of bytes so that they can be compared and placed in hashes, maps, and the like.

See Also:
Serialized Form

Constructor Summary
ByteArray()
           
ByteArray(byte[] data)
          Sets valid = data.length, unless data is null Sets offset = 0
ByteArray(byte[] data, int offset, int length)
          Sets offset = offset Sets valid = length
 
Method Summary
 int compareTo(Object obj)
           
 boolean equals(Object o)
           
 byte[] getData()
           
 int getOffset()
           
 int getValid()
          Count how many of the bytes in the array are 'valid'.
 int hashCode()
           
 void setData(byte[] data)
          Warning, does not set valid
 void setOffset(int offset)
           
 void setValid(int valid)
           
 String toBase64()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ByteArray

public ByteArray()

ByteArray

public ByteArray(byte[] data)
Sets valid = data.length, unless data is null Sets offset = 0

Parameters:
data - may be null

ByteArray

public ByteArray(byte[] data,
                 int offset,
                 int length)
Sets offset = offset Sets valid = length

Parameters:
data - may be null but why would you do that
Method Detail

getData

public byte[] getData()

setData

public void setData(byte[] data)
Warning, does not set valid


getValid

public int getValid()
Count how many of the bytes in the array are 'valid'. this property does not necessarily have meaning for all byte arrays.


setValid

public void setValid(int valid)

getOffset

public int getOffset()

setOffset

public void setOffset(int offset)

equals

public final boolean equals(Object o)
Overrides:
equals in class Object

compareTo

public final int compareTo(Object obj)
Specified by:
compareTo in interface Comparable

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

toBase64

public final String toBase64()