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
public class ExpandableBuffer extends java.lang.Object implements BufferInfo, BufferInfo
A buffer that expand its capacity on demand usingByteBufferAllocator
interface. Internally, this class is backed by an instance ofByteBuffer
.This class is not thread safe.
- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description static int
INPUT_MODE
static int
OUTPUT_MODE
-
Constructor Summary
Constructors Constructor Description ExpandableBuffer(int buffersize, ByteBufferAllocator allocator)
Allocates buffer of the given size using the given allocator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
Returns available capacity of this buffer.int
capacity()
Returns the total capacity of this buffer.boolean
hasData()
Determines if the buffer contains data.int
length()
Returns the length of this buffer.java.lang.String
toString()
-
-
-
Field Detail
-
INPUT_MODE
public static final int INPUT_MODE
- See Also:
- Constant Field Values
-
OUTPUT_MODE
public static final int OUTPUT_MODE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ExpandableBuffer
public ExpandableBuffer(int buffersize, ByteBufferAllocator allocator)
Allocates buffer of the given size using the given allocator.- Parameters:
buffersize
- the buffer size.allocator
- allocator to be used to allocateByteBuffer
s.
-
-
Method Detail
-
capacity
public int capacity()
Returns the total capacity of this buffer.- Specified by:
capacity
in interfaceBufferInfo
- Specified by:
capacity
in interfaceBufferInfo
- Returns:
- total capacity.
-
hasData
public boolean hasData()
Determines if the buffer contains data.- Returns:
true
if there is data in the buffer,false
otherwise.
-
length
public int length()
Returns the length of this buffer.- Specified by:
length
in interfaceBufferInfo
- Specified by:
length
in interfaceBufferInfo
- Returns:
- buffer length.
-
available
public int available()
Returns available capacity of this buffer.- Specified by:
available
in interfaceBufferInfo
- Specified by:
available
in interfaceBufferInfo
- Returns:
- buffer length.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-