Class ByteVector

java.lang.Object
   |
   +----java.util.Vector
           |
           +----ByteVector

public class ByteVector
extends Vector

NetRand Project

Software Engineering - CS536

University of Wisconsin - Milwaukee

Authors:


File: ByteVector.java

The ByteVector class adds functionality to the Vector class for operating specifically on Vectors of Byte objects.


Constructor Index

 o ByteVector()
calls the Vector() constructor
 o ByteVector(int)
calls the Vector( int initialCapacity ) constructor, which allows the initial capacity of the vector to be specified
 o ByteVector(int, int)
calls the Vector( ini initialCapacity, int capacityIncrement ) constructor, which allows the initial capacity of the vector to be specified as well as the amount by which the capacity of increased when the ByteVector overflows.

Method Index

 o addByte(byte)
adds a byte to the ByteVector
 o addBytes(byte[])
add an array of bytes to the ByteVector
 o addBytes(byte[], int, int)
add a section of an array of bytes to the ByteVector
 o byteAt(int)
returns the value of the byte at a specific location in the ByteVector
 o copyInto(byte[])
copies the contents of the ByteVector into an array
 o copyInto(byte[], int, int)
copies the contents of the ByteVector into an array
 o copyInto(byte[], int, int, int)
copies the contents of the ByteVector into an array
 o firstByte()
 o lastByte()
 o truncFromFront(int)
sets the size of the ByteVector and deletes excess bytes from the front of the ByteVector

Constructors

 o ByteVector
 public ByteVector()
calls the Vector() constructor

 o ByteVector
 public ByteVector(int initialCapacity)
calls the Vector( int initialCapacity ) constructor, which allows the initial capacity of the vector to be specified

Parameters:
initialCapacity - - the initial number of bytes the ByteVector can hold
 o ByteVector
 public ByteVector(int initialCapacity,
                   int capacityIncrement)
calls the Vector( ini initialCapacity, int capacityIncrement ) constructor, which allows the initial capacity of the vector to be specified as well as the amount by which the capacity of increased when the ByteVector overflows.

Parameters:
initialCapacity - - the initial number of byte the ByteVector can hold
capacityIncrement - - the amount to increment Vector when overflow

Methods

 o addByte
 public final synchronized void addByte(byte theByte)
adds a byte to the ByteVector

Parameters:
theByte - - the byte to add to the ByteVector
 o addBytes
 public final synchronized void addBytes(byte anArray[])
add an array of bytes to the ByteVector

Parameters:
anArray - - the array of bytes to add the ByteVector
 o addBytes
 public final synchronized void addBytes(byte anArray[],
                                         int beginIndex,
                                         int endIndex)
add a section of an array of bytes to the ByteVector

Parameters:
anArray - - an array containing the bytes to add to the ByteVector
beginIndex - - index of the first byte to add to the ByteVector
endIndex - - adds all bytes up to but not including anArray[endIndex]
 o copyInto
 public final synchronized void copyInto(byte anArray[])
copies the contents of the ByteVector into an array

Parameters:
anArray - - bytes are copied into this array starting at the first byte in the ByteVector until anArray[] is full
 o copyInto
 public final synchronized void copyInto(byte anArray[],
                                         int beginIndex,
                                         int endIndex)
copies the contents of the ByteVector into an array

Parameters:
anArray - - the array to copy the bytes into
beginIndex - - the index of the first element in the ByteVector to begin copying into anArray[]
endIndex - - the index of the element in the ByteVector immediately after the last byte to be copied into anArray[]
 o copyInto
 public final synchronized void copyInto(byte anArray[],
                                         int offset,
                                         int beginIndex,
                                         int endIndex)
copies the contents of the ByteVector into an array

Parameters:
anArray - - the array to copy the bytes into
offset - - offset into anArray[]
beginIndex - - the index of the first element in the ByteVector to begin copying into anArray[]
endIndex - - the index of the element in the ByteVector immediately after the last byte to be copied into anArray[]
 o byteAt
 public final synchronized byte byteAt(int index)
returns the value of the byte at a specific location in the ByteVector

Parameters:
index - - index of the byte in the ByteVector
Returns:
the value of the byte residing at that index
 o firstByte
 public final synchronized byte firstByte()
Returns:
the value of the first byte in the ByteVector
 o lastByte
 public final synchronized byte lastByte()
Returns:
the value of the last byte in the ByteVector
 o truncFromFront
 public final synchronized void truncFromFront(int vectorSize)
sets the size of the ByteVector and deletes excess bytes from the front of the ByteVector

Parameters:
vectorSize - - the desired size of the ByteVector