Class FilterAllocator
java.lang.Object
org.simpleframework.common.buffer.FilterAllocator
- All Implemented Interfaces:
Allocator
- Direct Known Subclasses:
BufferAllocator
The
FilterAllocator
object is used to provide a means
to provide a general set of constraints around buffer allocation.
It can ensure that a minimum capacity is used for default allocation
and that an upper limit is used for allocation. In general this can
be used in conjunction with another Allocator
which may
not have such constraints. It ensures that a set of requirements can
be observed when allocating buffers.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFilterAllocator
(Allocator source) Constructor for theFilterAllocator
object.FilterAllocator
(Allocator source, long capacity) Constructor for theFilterAllocator
object.FilterAllocator
(Allocator source, long capacity, long limit) Constructor for theFilterAllocator
object. -
Method Summary
-
Field Details
-
source
This is the allocator the underlying buffer is allocated with. -
capacity
protected long capacityThis is the default initial minimum capacity of the buffer. -
limit
protected long limitThis is the maximum number of bytes that can be allocated.
-
-
Constructor Details
-
FilterAllocator
Constructor for theFilterAllocator
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.- Parameters:
source
- this is where the underlying buffer is allocated
-
FilterAllocator
Constructor for theFilterAllocator
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.- Parameters:
source
- this is where the underlying buffer is allocatedcapacity
- the initial capacity of the allocated buffers
-
FilterAllocator
Constructor for theFilterAllocator
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.- Parameters:
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 Details
-
allocate
This method is used to allocate a default buffer. This will allocate a buffer of predetermined size, allowing it to grow to an upper limit to accommodate extra data. If the buffer requested is larger than the limit an exception is thrown.- Specified by:
allocate
in interfaceAllocator
- Returns:
- this returns an allocated buffer with a default size
- Throws:
IOException
-
allocate
This method is used to allocate a default buffer. This will allocate a buffer of predetermined size, allowing it to grow to an upper limit to accommodate extra data. If the buffer requested is larger than the limit an exception is thrown.- Specified by:
allocate
in interfaceAllocator
- Parameters:
size
- the initial capacity of the allocated buffer- Returns:
- this returns an allocated buffer with a default size
- Throws:
IOException
-