Class QueueOfBytes

java.lang.Object
  |
  +--QueueOfBytes

public class QueueOfBytes
extends java.lang.Object

Class QueueOfBytes uses a LinkedList from the java.util package. It can be used to collect raw bytes in a FIFO manner. Since its size is maintained in a byte, it must never have more than 127 bytes of data. This was done so that signed data does not cause problems in RSA.


Constructor Summary
QueueOfBytes()
          Constructor
 
Method Summary
 byte dequeue()
          dequeue Precondition The queue must contain at least one data byte.
 void enqueue(byte b)
          enqueue
 byte[] getBlockOfBytes()
          getBlockOfBytes
 boolean isEmpty()
          isEmpty
static void main(java.lang.String[] a)
          Test driver for QueueOfBytes
 byte size()
          size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueueOfBytes

public QueueOfBytes()
Constructor
Parameters:
none -
Postcondition
An empty QueueOfBytes is created
Throws:
OutOfMemoryError - Indicates that there is insufficient memory for a new QueueOfBytes,
Method Detail

isEmpty

public boolean isEmpty()
isEmpty
Parameters:
none -
Postcondition
returns true if and only if the QueueOfBytes is empty

size

public byte size()
size
Parameters:
none -
Postcondition
returns current size (data bytes) of the QueueOfBytes

enqueue

public void enqueue(byte b)
enqueue
Parameters:
b - is raw byte of data
Precondition
The queue must contain less than 127 bytes before enqueue is called.
Postcondition
the byte is added to the rear of the QueueOfBytes

dequeue

public byte dequeue()
dequeue
Precondition
The queue must contain at least one data byte.
Postcondition
the byte has been removed from the queue
Returns:
the byte at the front of the queue

getBlockOfBytes

public byte[] getBlockOfBytes()
getBlockOfBytes
Returns:
the queue in a block of bytes the first byte is the queue size the remaining bytes contain the queue data

main

public static void main(java.lang.String[] a)
Test driver for QueueOfBytes