com.ibm.icu.util
Class ByteArrayWrapper

java.lang.Object
  extended bycom.ibm.icu.util.ByteArrayWrapper
All Implemented Interfaces:
Comparable
Direct Known Subclasses:
RawCollationKey

Deprecated. This is a draft API and might change in a future release of ICU.

public class ByteArrayWrapper
extends Object
implements Comparable

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
Status:
Draft ICU 2.8.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..

Field Summary
 byte[] bytes
          Deprecated. This is a draft API and might change in a future release of ICU.
 int size
          Deprecated. This is a draft API and might change in a future release of ICU.
 
Constructor Summary
ByteArrayWrapper()
          Deprecated. This is a draft API and might change in a future release of ICU.
ByteArrayWrapper(byte[] bytesToAdopt, int size)
          Deprecated. This is a draft API and might change in a future release of ICU.
ByteArrayWrapper(ByteBuffer source)
          Deprecated. This is a draft API and might change in a future release of ICU.
 
Method Summary
 ByteArrayWrapper append(byte[] src, int start, int limit)
          Deprecated. This is a draft API and might change in a future release of ICU.
 int compareTo(Object other)
          Deprecated. This is a draft API and might change in a future release of ICU.
 ByteArrayWrapper ensureCapacity(int capacity)
          Deprecated. This is a draft API and might change in a future release of ICU.
 boolean equals(Object other)
          Deprecated. This is a draft API and might change in a future release of ICU.
 int hashCode()
          Deprecated. This is a draft API and might change in a future release of ICU.
 byte[] releaseBytes()
          Deprecated. This is a draft API and might change in a future release of ICU.
 ByteArrayWrapper set(byte[] src, int start, int limit)
          Deprecated. This is a draft API and might change in a future release of ICU.
 String toString()
          Deprecated. This is a draft API and might change in a future release of ICU.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

bytes

public byte[] bytes
Deprecated. This is a draft API and might change in a future release of ICU.

Internal byte array.

Status:
Draft ICU 2.8.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..

size

public int size
Deprecated. This is a draft API and might change in a future release of ICU.

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().

Status:
Draft ICU 2.8.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..
Constructor Detail

ByteArrayWrapper

public ByteArrayWrapper()
Deprecated. This is a draft API and might change in a future release of ICU.

Construct a new ByteArrayWrapper with no data.

Status:
Draft ICU 2.8.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..

ByteArrayWrapper

public ByteArrayWrapper(byte[] bytesToAdopt,
                        int size)
Deprecated. This is a draft API and might change in a future release of ICU.

Construct a new ByteArrayWrapper from a byte array and size

Parameters:
bytesToAdopt - the byte array to adopt
size - the length of valid data in the byte array
Throws:
IndexOutOfBoundsException - if bytesToAdopt == null and size != 0, or size < 0, or size > bytesToAdopt.length.
Status:
Draft ICU 3.2.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..

ByteArrayWrapper

public ByteArrayWrapper(ByteBuffer source)
Deprecated. This is a draft API and might change in a future release of ICU.

Construct a new ByteArrayWrapper from the contents of a ByteBuffer.

Parameters:
source - the ByteBuffer from which to get the data.
Status:
Draft ICU 3.2.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..
Method Detail

ensureCapacity

public ByteArrayWrapper ensureCapacity(int capacity)
Deprecated. This is a draft API and might change in a future release of ICU.

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.
Returns:
this ByteArrayWrapper
Status:
Draft ICU 3.2.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..

set

public final ByteArrayWrapper set(byte[] src,
                                  int start,
                                  int limit)
Deprecated. This is a draft API and might change in a future release of ICU.

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
start - start offset of src to copy from
limit - end + 1 offset of src to copy from
Returns:
this ByteArrayWrapper
Status:
Draft ICU 3.2.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..

append

public final ByteArrayWrapper append(byte[] src,
                                     int start,
                                     int limit)
Deprecated. This is a draft API and might change in a future release of ICU.

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
start - start offset of src to copy from
limit - end + 1 offset of src to copy from
Returns:
this ByteArrayWrapper
Status:
Draft ICU 3.2.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..

releaseBytes

public final byte[] releaseBytes()
Deprecated. This is a draft API and might change in a future release of ICU.

Releases the internal byte array to the caller, resets the internal byte array to null and its size to 0.

Returns:
internal byte array.
Status:
Draft ICU 2.8.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..

toString

public String toString()
Deprecated. This is a draft API and might change in a future release of ICU.

Returns string value for debugging

Status:
Draft ICU 3.2.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..

equals

public boolean equals(Object other)
Deprecated. This is a draft API and might change in a future release of ICU.

Return true if the bytes in each wrapper are equal.

Parameters:
other - the object to compare to.
Returns:
true if the two objects are equal.
Status:
Draft ICU 3.2.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..

hashCode

public int hashCode()
Deprecated. This is a draft API and might change in a future release of ICU.

Return the hashcode.

Returns:
the hashcode.
Status:
Draft ICU 3.2.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..

compareTo

public int compareTo(Object other)
Deprecated. This is a draft API and might change in a future release of ICU.

Compare this object to another ByteArrayWrapper, which must not be null.

Specified by:
compareTo in interface Comparable
Parameters:
other - the object to compare to.
Returns:
a value <0, 0, or >0 as this compares less than, equal to, or greater than other.
Throws:
ClassCastException - if the other object is not a ByteArrayWrapper
Status:
Draft ICU 3.2.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..


Copyright (c) 2004 IBM Corporation and others.