Package org.apache.http.nio.util
Class ExpandableBuffer
java.lang.Object
org.apache.http.nio.util.ExpandableBuffer
- All Implemented Interfaces:
BufferInfo,BufferInfo
- Direct Known Subclasses:
SessionInputBufferImpl,SessionOutputBufferImpl,SharedInputBuffer,SharedOutputBuffer,SimpleInputBuffer,SimpleOutputBuffer
A buffer that expand its capacity on demand using
ByteBufferAllocator
interface. Internally, this class is backed by an instance of
ByteBuffer.
This class is not thread safe.
- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionExpandableBuffer(int buffersize, ByteBufferAllocator allocator) Allocates buffer of the given size using the given allocator. -
Method Summary
-
Field Details
-
INPUT_MODE
public static final int INPUT_MODE- See Also:
-
OUTPUT_MODE
public static final int OUTPUT_MODE- See Also:
-
-
Constructor Details
-
ExpandableBuffer
Allocates buffer of the given size using the given allocator.- Parameters:
buffersize- the buffer size.allocator- allocator to be used to allocateByteBuffers.
-
-
Method Details
-
capacity
public int capacity()Returns the total capacity of this buffer.- Specified by:
capacityin interfaceBufferInfo- Specified by:
capacityin interfaceBufferInfo- Returns:
- total capacity.
-
hasData
public boolean hasData()Determines if the buffer contains data.- Returns:
trueif there is data in the buffer,falseotherwise.
-
length
public int length()Returns the length of this buffer.- Specified by:
lengthin interfaceBufferInfo- Specified by:
lengthin interfaceBufferInfo- Returns:
- buffer length.
-
available
public int available()Returns available capacity of this buffer.- Specified by:
availablein interfaceBufferInfo- Specified by:
availablein interfaceBufferInfo- Returns:
- buffer length.
-
toString
-