Package com.sun.corba.ee.impl.ior
Class ByteBuffer
java.lang.Object
com.sun.corba.ee.impl.ior.ByteBuffer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
The amount by which the capacity of the ByteBuffer is automatically incremented when its size becomes greater than its capacity.protected int
The number of valid components in this ByteBuffer object.protected byte[]
The array buffer into which the components of the ByteBuffer are stored. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty ByteBuffer so that its internal data array has size 10 and its standard capacity increment is zero.ByteBuffer
(int initialCapacity) Constructs an empty ByteBuffer with the specified initial capacity and with its capacity increment equal to zero.ByteBuffer
(int initialCapacity, int capacityIncrement) Constructs an empty ByteBuffer with the specified initial capacity and capacity increment. -
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(byte value) void
append
(int value) void
int
capacity()
Returns the current capacity of this ByteBuffer.private void
doAppend
(int value) private void
ensureCapacityHelper
(int minCapacity) This implements the unsynchronized semantics of ensureCapacity.boolean
isEmpty()
Tests if this ByteBuffer has no components.int
size()
Returns the number of components in this ByteBuffer.byte[]
toArray()
Returns an array containing all of the elements in this ByteBuffer in the correct order.void
Trims the capacity of this ByteBuffer to be the ByteBuffer's current size.
-
Field Details
-
elementData
protected byte[] elementDataThe array buffer into which the components of the ByteBuffer are stored. The capacity of the ByteBuffer is the length of this array buffer, and is at least large enough to contain all the ByteBuffer's elements.Any array elements following the last element in the ByteBuffer are 0.
-
elementCount
protected int elementCountThe number of valid components in this ByteBuffer object. Components elementData[0] through elementData[elementCount-1] are the actual items. -
capacityIncrement
protected int capacityIncrementThe amount by which the capacity of the ByteBuffer is automatically incremented when its size becomes greater than its capacity. If the capacity increment is less than or equal to zero, the capacity of the ByteBuffer is doubled each time it needs to grow.
-
-
Constructor Details
-
ByteBuffer
public ByteBuffer(int initialCapacity, int capacityIncrement) Constructs an empty ByteBuffer with the specified initial capacity and capacity increment.- Parameters:
initialCapacity
- the initial capacity of the ByteBuffer.capacityIncrement
- the amount by which the capacity is increased when the ByteBuffer overflows.- Throws:
IllegalArgumentException
- if the specified initial capacity is negative
-
ByteBuffer
public ByteBuffer(int initialCapacity) Constructs an empty ByteBuffer with the specified initial capacity and with its capacity increment equal to zero.- Parameters:
initialCapacity
- the initial capacity of the ByteBuffer.- Throws:
IllegalArgumentException
- if the specified initial capacity is negative
-
ByteBuffer
public ByteBuffer()Constructs an empty ByteBuffer so that its internal data array has size 10 and its standard capacity increment is zero.
-
-
Method Details
-
trimToSize
public void trimToSize()Trims the capacity of this ByteBuffer to be the ByteBuffer's current size. If the capacity of this cector is larger than its current size, then the capacity is changed to equal the size by replacing its internal data array, kept in the field elementData, with a smaller one. An application can use this operation to minimize the storage of a ByteBuffer. -
ensureCapacityHelper
private void ensureCapacityHelper(int minCapacity) This implements the unsynchronized semantics of ensureCapacity. Synchronized methods in this class can internally call this method for ensuring capacity without incurring the cost of an extra synchronization.- See Also:
-
capacity
public int capacity()Returns the current capacity of this ByteBuffer.- Returns:
- the current capacity (the length of its internal data arary, kept in the field elementData of this ByteBuffer.
-
size
public int size()Returns the number of components in this ByteBuffer.- Returns:
- the number of components in this ByteBuffer.
-
isEmpty
public boolean isEmpty()Tests if this ByteBuffer has no components.- Returns:
true
if and only if this ByteBuffer has no components, that is, its size is zero;false
otherwise.
-
append
public void append(byte value) -
append
public void append(int value) -
doAppend
private void doAppend(int value) -
append
-
toArray
public byte[] toArray()Returns an array containing all of the elements in this ByteBuffer in the correct order.- Returns:
- Array of elements in the buffer
- Since:
- 1.2
-