uk.org.ogsadai.activity.transform
Class ByteQueue

java.lang.Object
  |
  +--uk.org.ogsadai.activity.transform.ByteQueue

public class ByteQueue
extends java.lang.Object

A ByteQueue enqueues and dequeues bytes.

Author:
The OGSA-DAI Project Team

Constructor Summary
ByteQueue()
          Constructs a byte queue with the default initial queue capacity
ByteQueue(int queueCapacity)
          Constructs a byte queue with the specified initial queue capacity.
 
Method Summary
 int available()
          Returns the number of bytes avaialable for reading from the queue.
 int dequeue(byte[] bytes, int start, int length)
          Dequeues an array of bytes.
 void empty()
          Empties the queue, freeing up resources.
 void enqueue(byte[] bytes, int index, int length)
          Enqueues an array of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteQueue

public ByteQueue()
Constructs a byte queue with the default initial queue capacity


ByteQueue

public ByteQueue(int queueCapacity)
Constructs a byte queue with the specified initial queue capacity.

Parameters:
queueCapacity - the initial queue capacity.
Method Detail

empty

public void empty()
Empties the queue, freeing up resources.


enqueue

public void enqueue(byte[] bytes,
                    int index,
                    int length)
Enqueues an array of bytes.

Parameters:
bytes - The array of bytes.
index - The index within the array to start enqueing bytes from.
length - The length of bytes to enqueu, from the start index.

dequeue

public int dequeue(byte[] bytes,
                   int start,
                   int length)
Dequeues an array of bytes. Returns the number of bytes dequeued.

Parameters:
bytes - The byte[] to dequeue into.
start - The start index within bytes to dequeue into.
length - The maximum number of bytes to dequeue.
Returns:
The number of bytes that were dequeued.

available

public int available()
Returns the number of bytes avaialable for reading from the queue.