|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.simpleframework.util.buffer.ArrayBuffer
public class ArrayBuffer
The ArrayBuffer
is intended to be a general purpose
byte buffer that stores bytes in an single internal byte array. The
intended use of this buffer is to provide a simple buffer object to
read and write bytes with. In particular this provides a high
performance buffer that can be used to read and write bytes fast.
This provides several convenience methods which make the use of the
buffer easy and useful. This buffer allows an initial capacity to be
specified however if there is a need for extra space to be added to
buffer then the append
methods will expand the capacity
of the buffer as needed.
ArrayAllocator
Constructor Summary | |
---|---|
ArrayBuffer()
Constructor for the ArrayBuffer object. |
|
ArrayBuffer(int size)
Constructor for the ArrayBuffer object. |
|
ArrayBuffer(int size,
int limit)
Constructor for the ArrayBuffer object. |
Method Summary | |
---|---|
Buffer |
allocate()
This method is used to allocate a segment of this buffer as a separate buffer object. |
Buffer |
append(byte[] array)
This method is used to append bytes to the end of the buffer. |
Buffer |
append(byte[] array,
int off,
int size)
This method is used to append bytes to the end of the buffer. |
void |
clear()
This will clear all data from the buffer. |
void |
close()
This method is used to ensure the buffer can be closed. |
java.lang.String |
encode()
This method is used to acquire the buffered bytes as a string. |
java.lang.String |
encode(java.lang.String charset)
This method is used to acquire the buffered bytes as a string. |
java.io.InputStream |
getInputStream()
This method is used so that the buffer can be represented as a stream of bytes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ArrayBuffer()
ArrayBuffer
object. The initial
capacity of the default buffer object is set to 16, the capacity
will be expanded when the append methods are used and there is
not enough space to accommodate the extra bytes.
public ArrayBuffer(int size)
ArrayBuffer
object. The initial
capacity of the buffer object is set to given size, the capacity
will be expanded when the append methods are used and there is
not enough space to accommodate the extra bytes.
size
- the initial capacity of this buffer instancepublic ArrayBuffer(int size, int limit)
ArrayBuffer
object. The initial
capacity of the buffer object is set to given size, the capacity
will be expanded when the append methods are used and there is
not enough space to accommodate the extra bytes.
size
- the initial capacity of this buffer instancelimit
- this is the maximum allowable buffer capacityMethod Detail |
---|
public java.io.InputStream getInputStream()
getInputStream
in interface Stream
public Buffer allocate() throws java.io.IOException
allocate
in interface Buffer
java.io.IOException
public java.lang.String encode() throws java.io.IOException
encode
in interface Buffer
java.io.IOException
public java.lang.String encode(java.lang.String charset) throws java.io.IOException
encode
in interface Buffer
charset
- this is the charset to encode the data with
java.io.IOException
public Buffer append(byte[] array) throws java.io.IOException
append
in interface Buffer
array
- this is the byte array to append to this buffer
java.io.IOException
public Buffer append(byte[] array, int off, int size) throws java.io.IOException
append
in interface Buffer
array
- this is the byte array to append to this bufferoff
- this is the offset to begin reading the bytes fromsize
- the number of bytes to be read from the array
java.io.IOException
public void clear() throws java.io.IOException
clear
in interface Buffer
java.io.IOException
public void close() throws java.io.IOException
close
in interface Buffer
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |