|
|||||||||
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,
int capacity)
Constructor for the BufferAllocator object. |
|
BufferAllocator(Allocator source,
int capacity,
int limit)
Constructor for the BufferAllocator object. |
Method Summary | |
---|---|
Buffer |
allocate()
This method is used to allocate a default buffer. |
Buffer |
allocate(int 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. |
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 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 allocatedpublic BufferAllocator(Allocator source, int 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 bufferspublic BufferAllocator(Allocator source, int capacity, int 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 thisMethod Detail |
---|
public java.io.InputStream getInputStream() throws java.io.IOException
getInputStream
in interface Stream
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 buffersize
- the number of bytes to be read from the arrayoff
- this is the offset to begin reading the bytes from
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 java.io.Closeable
close
in interface Allocator
close
in interface Buffer
close
in class FilterAllocator
java.io.IOException
public Buffer allocate() throws java.io.IOException
allocate
in interface Allocator
allocate
in interface Buffer
allocate
in class FilterAllocator
java.io.IOException
public Buffer allocate(int size) throws java.io.IOException
allocate
in interface Allocator
allocate
in class FilterAllocator
size
- the initial capacity of the allocated buffer
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |