|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tffenterprises.util.Buffer
public class Buffer
Buffer is a byte buffer that knows how many bytes of real data it contains. This is useful is several byte arrays are to be juggled around, so that data remains neatly encapsulated, and memory allocations kept to a minimum.
One creates a Buffer objects with a certain maximum capacity, and then
bytes can be added to it with the setData()
methods.
Field Summary | |
---|---|
(package private) byte[] |
buf
The byte array that will contain the data. |
(package private) int |
datalength
The number of bytes containing valid data. |
Constructor Summary | |
---|---|
Buffer(int max)
Constructor: create a buffer of fixed capacity, containing a maximum of max bytes. |
Method Summary | |
---|---|
byte[] |
getData()
Returns the data contained in this Buffer. |
int |
getDataLength()
Returns the current length of the data contained in this Buffer. |
int |
getMax()
Returns the maximum capacity of this Buffer. |
void |
setData(byte[] data)
Sets the data in this buffer, copying the entire array to this buffer. |
void |
setData(byte[] data,
int length)
Sets the data in this buffer, copying length bytes from
the byte array to this buffer. |
void |
setDataLength(int length)
Change the current length of the data contained in this Buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
byte[] buf
int datalength
Constructor Detail |
---|
public Buffer(int max)
max
bytes.
max
- the capacity of the Buffer.Method Detail |
---|
public int getMax()
public byte[] getData()
public void setData(byte[] data)
data
- the byte array to be copied into this Buffer.public void setData(byte[] data, int length)
length
bytes from
the byte array to this buffer.
data
- the byte array to be copied into this Buffer.length
- how many bytes to copy from data
to this
Buffer.public int getDataLength()
public void setDataLength(int length)
length
- the new data length.
java.lang.IllegalArgumentException
- if length
is greater
than this Buffer's maximum size.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |