|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.simpleframework.util.buffer.FilterAllocator
org.simpleframework.util.buffer.BufferAllocator
public class BufferAllocator
The BufferAllocator object is used to provide a means
to allocate buffers using a single underlying buffer. This uses a
buffer from a existing allocator to create the region of memory to
use to allocate all other buffers. As a result this allows a single
buffer to acquire the bytes in a number of associated buffers. This
has the advantage of allowing bytes to be read in sequence without
joining data from other buffers or allocating multiple regions.
| Field Summary |
|---|
| Fields inherited from class org.simpleframework.util.buffer.FilterAllocator |
|---|
capacity, limit, source |
| Constructor Summary | |
|---|---|
BufferAllocator(Allocator source)
Constructor for the BufferAllocator object. |
|
BufferAllocator(Allocator source,
long capacity)
Constructor for the BufferAllocator object. |
|
BufferAllocator(Allocator source,
long capacity,
long limit)
Constructor for the BufferAllocator object. |
|
| Method Summary | |
|---|---|
Buffer |
allocate()
This method is used to allocate a default buffer. |
Buffer |
allocate(long size)
This method is used to allocate a default buffer. |
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. |
String |
encode()
This method is used to acquire the buffered bytes as a string. |
String |
encode(String charset)
This method is used to acquire the buffered bytes as a string. |
long |
length()
This is used to provide the number of bytes that have been written to the buffer. |
InputStream |
open()
This method is used so that a 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 BufferAllocator(Allocator source)
BufferAllocator object. This is
used to instantiate the allocator with a default buffer size of
half a kilobyte. This ensures that it can be used for general
purpose byte storage and for minor I/O tasks.
source - this is where the underlying buffer is allocated
public BufferAllocator(Allocator source,
long capacity)
BufferAllocator object. This is
used to instantiate the allocator with a specified buffer size.
This is typically used when a very specific buffer capacity is
required, for example a request body with a known length.
source - this is where the underlying buffer is allocatedcapacity - the initial capacity of the allocated buffers
public BufferAllocator(Allocator source,
long capacity,
long limit)
BufferAllocator object. This is
used to instantiate the allocator with a specified buffer size.
This is typically used when a very specific buffer capacity is
required, for example a request body with a known length.
source - this is where the underlying buffer is allocatedcapacity - the initial capacity of the allocated bufferslimit - this is the maximum buffer size created by this| Method Detail |
|---|
public InputStream open()
throws IOException
open in interface BufferIOException
public String encode()
throws IOException
encode in interface BufferIOException
public String encode(String charset)
throws IOException
encode in interface Buffercharset - this is the charset to encode the data with
IOException
public Buffer append(byte[] array)
throws IOException
append in interface Bufferarray - this is the byte array to append to this buffer
IOException
public Buffer append(byte[] array,
int off,
int size)
throws IOException
append in interface Bufferarray - this is the byte array to append to this buffersize - the number of bytes to be read from the arrayoff - this is the offset to begin reading the bytes from
IOException
public void clear()
throws IOException
clear in interface BufferIOException
public void close()
throws IOException
close in interface Closeableclose in interface Allocatorclose in interface Bufferclose in class FilterAllocatorIOException
public Buffer allocate()
throws IOException
allocate in interface Allocatorallocate in interface Bufferallocate in class FilterAllocatorIOException
public Buffer allocate(long size)
throws IOException
allocate in interface Allocatorallocate in class FilterAllocatorsize - the initial capacity of the allocated buffer
IOExceptionpublic long length()
length in interface Buffer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||