Top Description Inners Fields Constructors Methods
org.apache.hc.core5.http.impl.nio

public Class ExpandableBuffer

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.hc.core5.http.impl.nio.SessionInputBufferImpl, org.apache.hc.core5.http.impl.nio.SessionOutputBufferImpl, org.apache.hc.core5.http.nio.support.classic.AbstractSharedBuffer, org.apache.hc.core5.http.impl.nio.BufferedData
Annotations
@Internal
Imports
java.nio.BufferOverflowException, .ByteBuffer, org.apache.hc.core5.annotation.Internal

A buffer that expand its capacity on demand. Internally, this class is backed by an instance of ByteBuffer.

This class is not thread safe.

Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private ByteBuffer
private ExpandableBuffer.Mode

Constructor Summary

AccessConstructor and Description
protected
ExpandableBuffer(final int
the buffer size.
bufferSize
)

Allocates buffer of the given size using the given allocator.

Method Summary

Modifier and TypeMethod and Description
protected ByteBuffer
protected int

Returns:

buffer length.
capacity
()

Returns available capacity of this buffer.

protected void
clear()

Clears buffer.

protected void
ensureAdjustedCapacity(final int
the required capacity.
requiredCapacity
)

Ensures the buffer can accommodate at least the required capacity adjusted to multiples of 1024.

protected void
ensureCapacity(final int
the required capacity.
requiredCapacity
)

Ensures the buffer can accommodate the exact required capacity.

protected void
expand()

Expands buffer's capacity.

private void
expandCapacity(final int capacity)

protected boolean

Returns:

true if there is data in the buffer, false otherwise.
hasData
()

Determines if the buffer contains data.

protected int

Returns:

buffer length.
length
()

Returns the length of this buffer.

protected ExpandableBuffer.Mode

Returns:

current input/output mode.
mode
()

Returns the current mode:

Mode#INPUT: the buffer is in the input mode.

protected void
setInputMode()

Sets the mode to input.

protected void
setOutputMode()

Sets the mode to output.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bufferback to summary
private ByteBuffer buffer
modeback to summary
private ExpandableBuffer.Mode mode

Constructor Detail

ExpandableBufferback to summary
protected ExpandableBuffer(final int bufferSize)

Allocates buffer of the given size using the given allocator.

Sets the mode to input.

Parameters
bufferSize:int

the buffer size.

Method Detail

bufferback to summary
protected ByteBuffer buffer()
capacityback to summary
protected int capacity()

Returns available capacity of this buffer.

Returns:int

buffer length.

clearback to summary
protected void clear()

Clears buffer.

Sets the mode to input.

ensureAdjustedCapacityback to summary
protected void ensureAdjustedCapacity(final int requiredCapacity)

Ensures the buffer can accommodate at least the required capacity adjusted to multiples of 1024.

Parameters
requiredCapacity:int

the required capacity.

ensureCapacityback to summary
protected void ensureCapacity(final int requiredCapacity)

Ensures the buffer can accommodate the exact required capacity.

Parameters
requiredCapacity:int

the required capacity.

expandback to summary
protected void expand() throws BufferOverflowException

Expands buffer's capacity.

Exceptions
BufferOverflowException:
in case we get over the maximum allowed value
expandCapacityback to summary
private void expandCapacity(final int capacity)
hasDataback to summary
protected boolean hasData()

Determines if the buffer contains data.

Sets the mode to output.

Returns:boolean

true if there is data in the buffer, false otherwise.

lengthback to summary
protected int length()

Returns the length of this buffer.

Sets the mode to output.

Returns:int

buffer length.

modeback to summary
protected ExpandableBuffer.Mode mode()

Returns the current mode:

Mode#INPUT: the buffer is in the input mode.

Mode#OUTPUT: the buffer is in the output mode.

Returns:ExpandableBuffer.Mode

current input/output mode.

setInputModeback to summary
protected void setInputMode()

Sets the mode to input. The buffer can now be written into.

setOutputModeback to summary
protected void setOutputMode()

Sets the mode to output. The buffer can now be read from.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.apache.hc.core5.http.impl.nio back to summary

public final Enum ExpandableBuffer.Mode

extends Enum<ExpandableBuffer.Mode>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ExpandableBuffer.Mode
public static final ExpandableBuffer.Mode

Constructor Summary

AccessConstructor and Description
private
Mode()

Method Summary

Modifier and TypeMethod and Description
public static ExpandableBuffer.Mode
public static ExpandableBuffer.Mode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INPUTback to summary
public static final ExpandableBuffer.Mode INPUT
OUTPUTback to summary
public static final ExpandableBuffer.Mode OUTPUT

Constructor Detail

Modeback to summary
private Mode()

Method Detail

valueOfback to summary
public static ExpandableBuffer.Mode valueOf(String name)
valuesback to summary
public static ExpandableBuffer.Mode[] values()