Package org.apache.derby.iapi.util
Class ByteArray
- java.lang.Object
-
- org.apache.derby.iapi.util.ByteArray
-
public final class ByteArray extends java.lang.ObjectByteArray wraps java byte arrays (byte[]) to allow byte arrays to be used as keys in hashtables. This is required because the equals function on byte[] directly uses reference equality.This class also allows the trio of array, offset and length to be carried around as a single object.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static booleanequals(byte[] a, int aOffset, int aLength, byte[] b, int bOffset, int bLength)Compare two byte arrays using value equality.booleanequals(java.lang.Object other)Value equality for byte arrays.byte[]getArray()intgetLength()intgetOffset()inthashCode()voidreadExternal(java.io.ObjectInput in)Read this object from a stream of stored objects.voidsetBytes(byte[] array)voidsetBytes(byte[] array, int length)voidsetBytes(byte[] array, int offset, int length)voidsetLength(int newLength)voidwriteExternal(java.io.ObjectOutput out)Write the byte array out w/o compression
-
-
-
Method Detail
-
setBytes
public void setBytes(byte[] array)
-
setBytes
public void setBytes(byte[] array, int length)
-
setBytes
public void setBytes(byte[] array, int offset, int length)
-
equals
public boolean equals(java.lang.Object other)
Value equality for byte arrays.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getArray
public final byte[] getArray()
-
getOffset
public final int getOffset()
-
getLength
public final int getLength()
-
setLength
public final void setLength(int newLength)
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOExceptionRead this object from a stream of stored objects.- Parameters:
in- read this.- Throws:
java.io.IOException- thrown on error
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOExceptionWrite the byte array out w/o compression- Parameters:
out- write bytes here.- Throws:
java.io.IOException- thrown on error
-
equals
private static boolean equals(byte[] a, int aOffset, int aLength, byte[] b, int bOffset, int bLength)Compare two byte arrays using value equality. Two byte arrays are equal if their length is identical and their contents are identical.
-
-