|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGiciStream.ByteStream
public class ByteStream
This class is a byte buffer, useful to store a byte stream. When the length of the ByteStream is known a priori, this class should be instantianed using the constructor with the initialSizeBuffer. When the length it is not known, this class begins instantiating a small buffer and duplicates its size (copying all contents) when it is full. The duplication of the buffer length is performed until maxBuffAllocation is reached, then is increased the number of bytes of this variable. Variables initialBuffAllocation and maxBuffAllocation controls the performance of this method; default values ara intialized to be efficient when containing small buffers (not more than 10 KB). If you need larger buffer capacities, you should change these variables.
Field Summary | |
---|---|
private byte[] |
byteBuffer
Byte array used to store bytes. |
private int |
index
Index of the current position of the byte buffer (number of bytes saved in byteBuffer minus 1). |
private int |
initialBuffAllocation
Initial length of the byte buffer. |
private int |
maxBuffAllocation
When the buffer is full, its length is duplicated until maxBuffAllocation is reached. |
Constructor Summary | |
---|---|
ByteStream()
Class constructor (performs needed initializations). |
|
ByteStream(byte[] byteBuffer,
int numBytes)
Class constructor allowing to insert a byte array (performs needed initializations). |
|
ByteStream(int initialSizeBuffer)
Class constructor with a specified amount of bytes to allocate initially in the buffer. |
Method Summary | |
---|---|
void |
addByte(byte b)
Inserts a byte in the ByteStream. |
void |
addBytes(byte[] bytes,
int numBytes)
Inserts bytes in the bytestream. |
void |
deleteBeginBytes(int num)
Deletes a number of bytes of the bytestream (at the begining of bytestream). |
void |
deleteEndBytes(int num)
Deletes a number of bytes of the bytestream (at the end of bytestream). |
byte |
getByte(int numByte)
Return the byte indicated. |
byte[] |
getByteStream()
Return the byte stream in an array of bytes (the length of array byte returned is equal or greater than the real bytes contained in byteStream -it can be known using getNumBytes function-). |
int |
getNumBytes()
Return the number of bytes in the byte stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private byte[] byteBuffer
All values allowed.
private int index
Negative values are not allowed for this field.
private final int initialBuffAllocation
Negative values are not allowed for this field.
private final int maxBuffAllocation
Negative values are not allowed for this field.
Constructor Detail |
---|
public ByteStream()
public ByteStream(int initialSizeBuffer)
initialSizeBuffer
- number of bytes that initially the buffer will containpublic ByteStream(byte[] byteBuffer, int numBytes)
byteBuffer
- the byte buffer to usenumBytes
- of bytes valid in byte bufferMethod Detail |
---|
public void addByte(byte b)
b
- the byte that will be inserted into byte streampublic void addBytes(byte[] bytes, int numBytes)
bytes
- an array of bytes that will be inserted into byte streamnumBytes
- the number of bytes to insert in the bytestreampublic void deleteEndBytes(int num)
num
- the number of bytes to deletepublic void deleteBeginBytes(int num)
num
- the number of bytes to deletepublic byte getByte(int numByte) throws WarningException
numByte
- the number of byte in bytestream (starting at 0)
WarningException
- when numByte is greater than the buffer lengthpublic byte[] getByteStream()
public int getNumBytes()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |