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

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private static int DEFAULT_QUEUE_CAPACITY
          Default start size for the queue
private  int mAvailable
          Keeps track of the number of queued bytes available for dequeueing
private  int mEnd
          Index to the end of the queue
private  int mHead
          Index to the head of the queue
private  byte[] mQueue
          Byte array for the atual queue
 
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
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

DEFAULT_QUEUE_CAPACITY

private static final int DEFAULT_QUEUE_CAPACITY
Default start size for the queue

See Also:
Constant Field Values

mQueue

private byte[] mQueue
Byte array for the atual queue


mHead

private int mHead
Index to the head of the queue


mEnd

private int mEnd
Index to the end of the queue


mAvailable

private int mAvailable
Keeps track of the number of queued bytes available for dequeueing

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.

Returns:
number of bytes.