|
Orbital library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object orbital.util.Buffer
public class Buffer
This class encapsulates a Buffer containing bytes. Those bytes in the Buffer are kept as a byte[].
java.nio.Buffer
Field Summary | |
---|---|
protected byte[] |
buf
The buffer where data is stored. |
protected int |
count
The index one greater than the index of the last valid byte in the buffer. |
Constructor Summary | |
---|---|
Buffer()
The current position in the buffer. |
|
Buffer(byte[] initialContent)
|
|
Buffer(byte[] initialContent,
int off,
int len)
Creates a new Buffer with an initial content specified by a part of a byte-array. |
|
Buffer(int initialCapacity)
Creates a new Buffer with an initial capacity, but empty (of size 0). |
Method Summary | |
---|---|
void |
append(byte[] b)
Append a byte[] to the end of this Buffer, |
void |
append(byte[] b,
int off,
int len)
Append a part of a byte[] (starting at off) to the end of this Buffer, increasing its size by the length of b. |
void |
append(int val,
int len)
Append a byte value len times to the end of this Buffer, increasing its size by len. |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this Buffer, if necessary, to ensure that it can hold at least the number of bytes specified by the minimum capacity argument. |
byte[] |
getBuffer()
Gets the whole underlying byte-buffer containing the data (size like the whole capacity). |
byte[] |
getBytes()
Get a copy of the buffer. |
byte[] |
getBytes(int len)
Get a part of the buffer, beginning at front (index 0). |
void |
getBytes(int srcOff,
byte[] dst,
int dstOff,
int len)
Get a part of the buffer into a specified byte-array. |
byte[] |
getBytes(int off,
int len)
Get a part of the buffer. |
void |
remove(int len)
Remove len beginning at front (index 0). |
void |
remove(int off,
int len)
Remove len bytes starting at off from this Buffer, decreasing its size by the len. |
void |
setBuffer(byte[] buffer)
Sets the underlying byte-buffer containing the data (without setting the byte-count). |
void |
setBytes(byte[] part,
int dstOff)
|
void |
setBytes(byte[] part,
int srcOff,
int dstOff,
int len)
Set a part of the buffer. |
void |
setSize(int newSize)
Sets the size of this vector. |
int |
size()
Returns the number of bytes in this buffer. |
void |
trimToSize()
Trims the capacity of this buffer to be the buffer's current size. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int count
count<=buf.length
.
protected byte[] buf
Constructor Detail |
---|
public Buffer()
buf
array.
BufferedInputStream
public Buffer(int initialCapacity)
public Buffer(byte[] initialContent, int off, int len)
initialContent
- the byte-array containing the data.off
- the index where the relevant data start in initialContentlen
- the size of the buffer. len is also the number of bytes that are copied from initialContent.public Buffer(byte[] initialContent)
Method Detail |
---|
public byte[] getBytes()
public byte[] getBytes(int len)
public byte[] getBytes(int off, int len)
null
for length 0
.public void getBytes(int srcOff, byte[] dst, int dstOff, int len)
dst
- the byte-array to be filled with the part desired. Its dimension must be at least len.dstOff
- the destination offset in dst.srcOff
- the source offset in the Buffer array.len
- the number of bytes to be copied.
java.lang.ArrayIndexOutOfBoundsException
- if the part to be get exceeds the current dimension.
java.lang.IllegalArgumentException
- if the offset or length are negative, or the length of dst is less than len.System.arraycopy(Object,int,Object,int,int)
public void setBytes(byte[] part, int srcOff, int dstOff, int len)
part
- the bytes to be set as new part of the BuffersrcOff
- the source offset in the part array.dstOff
- the destination offset in the Buffer.len
- the number of bytes to be copied.
java.lang.ArrayIndexOutOfBoundsException
- if the part to be set exceeds the current dimension.
java.lang.IllegalArgumentException
- if the offset or length are negative.System.arraycopy(Object,int,Object,int,int)
public void setBytes(byte[] part, int dstOff)
public final int size()
public final void setSize(int newSize)
null
items are added to the end of
the vector. If the new size is less than the current size, all
components at index newSize
and greater are discarded.
newSize
- the new size of this vector.public final void trimToSize()
public void ensureCapacity(int minCapacity)
minCapacity
- the desired minimum capacity.
java.lang.IllegalArgumentException
- if desired minimum capacity is negative.public void append(byte[] b)
public void append(byte[] b, int off, int len)
public void append(int val, int len)
public void remove(int len)
public void remove(int off, int len)
public final byte[] getBuffer()
public final void setBuffer(byte[] buffer)
setSize(int)
|
Orbital library 1.3.0: 11 Apr 2009 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |