mondrian.util
Class ByteString

java.lang.Object
  extended by mondrian.util.ByteString
All Implemented Interfaces:
Serializable, Comparable<ByteString>

public class ByteString
extends Object
implements Comparable<ByteString>, Serializable

Collection of bytes.

ByteString is to bytes what String is to chars: It is immutable, implements equality (hashCode and equals), comparison (compareTo) and serialization correctly.

Author:
jhyde
See Also:
Serialized Form

Constructor Summary
ByteString(byte[] bytes)
          Creates a ByteString.
 
Method Summary
 byte byteAt(int i)
          Returns the byte at a given position in the byte string.
 Object clone()
           
 int compareTo(ByteString that)
           
 boolean equals(Object obj)
           
 int hashCode()
           
 int length()
          Returns the number of bytes in this byte string.
 String toString()
          Returns this byte string in hexadecimal format.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ByteString

public ByteString(byte[] bytes)
Creates a ByteString.

Parameters:
bytes - Bytes
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

compareTo

public int compareTo(ByteString that)
Specified by:
compareTo in interface Comparable<ByteString>

toString

public String toString()
Returns this byte string in hexadecimal format.

Overrides:
toString in class Object
Returns:
Hexadecimal string

clone

public Object clone()
Overrides:
clone in class Object

length

public int length()
Returns the number of bytes in this byte string.

Returns:
Length of this byte string

byteAt

public byte byteAt(int i)
Returns the byte at a given position in the byte string.

Parameters:
i - Index
Returns:
Byte at given position
Throws:
IndexOutOfBoundsException - if the index argument is negative or not less than length()

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads