Top Fields Constructors Methods
org.apache.hc.core5.http.nio.support.classic

public final Class SharedInputBuffer

extends AbstractSharedBuffer
implements ContentInputBuffer
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.support.classic.ContentInputBuffer
Annotations
@Contract
threading:SAFE
Imports
java.io.IOException, .InterruptedIOException, java.nio.ByteBuffer, java.util.concurrent.atomic.AtomicInteger, java.util.concurrent.locks.ReentrantLock, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.nio.CapacityChannel

Since
5.0

Field Summary

Modifier and TypeField and Description
private volatile CapacityChannel
private final AtomicInteger
private final int
Inherited from org.apache.hc.core5.http.nio.support.classic.AbstractSharedBuffer:
abortedconditionendStreamlock

Constructor Summary

AccessConstructor and Description
public
SharedInputBuffer(final ReentrantLock lock, final int initialBufferSize)

public
SharedInputBuffer(final int bufferSize)

Method Summary

Modifier and TypeMethod and Description
private void
public int
fill(final ByteBuffer src)

private void
public void
public int
read()

Implements org.apache.hc.core5.http.nio.support.classic.ContentInputBuffer.read.

Reads one byte from this buffer.
public int
read(final byte[]
the buffer into which the data is read.
b
,
final int
the start offset in array b at which the data is written.
off
,
final int
the maximum number of bytes to read.
len
)

Implements org.apache.hc.core5.http.nio.support.classic.ContentInputBuffer.read.

Reads up to len bytes of data from this buffer into an array of bytes.
public void
updateCapacity(final CapacityChannel capacityChannel)

Inherited from org.apache.hc.core5.http.nio.support.classic.AbstractSharedBuffer:
abortcapacityhasDataisEndStreamlengthreset

Field Detail

capacityChannelback to summary
private volatile CapacityChannel capacityChannel
capacityIncrementback to summary
private final AtomicInteger capacityIncrement
initialBufferSizeback to summary
private final int initialBufferSize

Constructor Detail

SharedInputBufferback to summary
public SharedInputBuffer(final ReentrantLock lock, final int initialBufferSize)
SharedInputBufferback to summary
public SharedInputBuffer(final int bufferSize)

Method Detail

awaitInputback to summary
private void awaitInput() throws InterruptedIOException
fillback to summary
public int fill(final ByteBuffer src)
incrementCapacityback to summary
private void incrementCapacity() throws IOException
markEndStreamback to summary
public void markEndStream()
readback to summary
public int read() throws IOException

Implements org.apache.hc.core5.http.nio.support.classic.ContentInputBuffer.read.

Doc from org.apache.hc.core5.http.nio.support.classic.ContentInputBuffer.read.

Reads one byte from this buffer. If the buffer is empty this method can throw a runtime exception. The exact type of runtime exception thrown by this method depends on implementation. This method returns -1 if the end of content stream has been reached.

Returns:int

one byte

Annotations
@Override
readback to summary
public int read(final byte[] b, final int off, final int len) throws IOException

Implements org.apache.hc.core5.http.nio.support.classic.ContentInputBuffer.read.

Doc from org.apache.hc.core5.http.nio.support.classic.ContentInputBuffer.read.

Reads up to len bytes of data from this buffer into an array of bytes. The exact number of bytes read depends how many bytes are stored in the buffer.

If off is negative, or len is negative, or off+len is greater than the length of the array b, this method can throw a runtime exception. The exact type of runtime exception thrown by this method depends on implementation. This method returns -1 if the end of content stream has been reached.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
updateCapacityback to summary
public void updateCapacity(final CapacityChannel capacityChannel) throws IOException