| java.lang.Object com.ibm.icu.util.ByteArrayWrapper
All known Subclasses: com.ibm.icu.text.RawCollationKey,
ByteArrayWrapper | public class ByteArrayWrapper implements Comparable(Code) | |
A simple utility class to wrap a byte array.
Generally passed as an argument object into a method. The method takes
responsibility of writing into the internal byte array and increasing its
size when necessary.
author: syn wee |
Field Summary | |
public byte[] | bytes Internal byte array. | public int | size Size of the internal byte array used. |
Constructor Summary | |
public | ByteArrayWrapper() Construct a new ByteArrayWrapper with no data. | public | ByteArrayWrapper(byte[] bytesToAdopt, int size) | public | ByteArrayWrapper(ByteBuffer source) Construct a new ByteArrayWrapper from the contents of a ByteBuffer. |
Method Summary | |
final public ByteArrayWrapper | append(byte[] src, int start, int limit) Appends the internal byte array from offset size with the
contents of src from offset start to limit. | public int | compareTo(Object other) Compare this object to another ByteArrayWrapper, which must not be null.
Parameters: other - the object to compare to. | public ByteArrayWrapper | ensureCapacity(int capacity) Ensure that the internal byte array is at least of length capacity. | public boolean | equals(Object other) Return true if the bytes in each wrapper are equal.
Parameters: other - the object to compare to. | public int | hashCode() Return the hashcode. | final public byte[] | releaseBytes() Releases the internal byte array to the caller, resets the internal
byte array to null and its size to 0. | final public ByteArrayWrapper | set(byte[] src, int start, int limit) Set the internal byte array from offset 0 to (limit - start) with the
contents of src from offset start to limit. | public String | toString() |
bytes | public byte[] bytes(Code) | | Internal byte array.
|
size | public int size(Code) | | Size of the internal byte array used.
Different from bytes.length, size will be <= bytes.length.
Semantics of size is similar to java.util.Vector.size().
|
ByteArrayWrapper | public ByteArrayWrapper()(Code) | | Construct a new ByteArrayWrapper with no data.
|
ByteArrayWrapper | public ByteArrayWrapper(byte[] bytesToAdopt, int size)(Code) | | Construct a new ByteArrayWrapper from a byte array and size
Parameters: bytesToAdopt - the byte array to adopt Parameters: size - the length of valid data in the byte array throws: IndexOutOfBoundsException - if bytesToAdopt == null and size != 0, orsize < 0, or size > bytesToAdopt.length. |
ByteArrayWrapper | public ByteArrayWrapper(ByteBuffer source)(Code) | | Construct a new ByteArrayWrapper from the contents of a ByteBuffer.
Parameters: source - the ByteBuffer from which to get the data. |
append | final public ByteArrayWrapper append(byte[] src, int start, int limit)(Code) | | Appends the internal byte array from offset size with the
contents of src from offset start to limit. This increases the size of
the internal byte array to (size + limit - start).
Parameters: src - source byte array to copy from Parameters: start - start offset of src to copy from Parameters: limit - end + 1 offset of src to copy from this ByteArrayWrapper |
compareTo | public int compareTo(Object other)(Code) | | Compare this object to another ByteArrayWrapper, which must not be null.
Parameters: other - the object to compare to. a value <0, 0, or >0 as this compares less than, equal to, orgreater than other. throws: ClassCastException - if the other object is not a ByteArrayWrapper |
ensureCapacity | public ByteArrayWrapper ensureCapacity(int capacity)(Code) | | Ensure that the internal byte array is at least of length capacity.
If the byte array is null or its length is less than capacity, a new
byte array of length capacity will be allocated.
The contents of the array (between 0 and size) remain unchanged.
Parameters: capacity - minimum length of internal byte array. this ByteArrayWrapper |
equals | public boolean equals(Object other)(Code) | | Return true if the bytes in each wrapper are equal.
Parameters: other - the object to compare to. true if the two objects are equal. |
hashCode | public int hashCode()(Code) | | Return the hashcode.
the hashcode. |
releaseBytes | final public byte[] releaseBytes()(Code) | | Releases the internal byte array to the caller, resets the internal
byte array to null and its size to 0.
internal byte array. |
set | final public ByteArrayWrapper set(byte[] src, int start, int limit)(Code) | | Set the internal byte array from offset 0 to (limit - start) with the
contents of src from offset start to limit. If the byte array is null or its length is less than capacity, a new
byte array of length (limit - start) will be allocated.
This resets the size of the internal byte array to (limit - start).
Parameters: src - source byte array to copy from Parameters: start - start offset of src to copy from Parameters: limit - end + 1 offset of src to copy from this ByteArrayWrapper |
toString | public String toString()(Code) | | Returns string value for debugging
|
|
|