Top Description Fields Constructors Methods
io.netty5.handler.stream

public Class ChunkedNioStream

extends Object
implements ChunkedInput<Buffer>
Class Inheritance
All Implemented Interfaces
io.netty5.handler.stream.ChunkedInput, java.lang.AutoCloseable
Imports
io.netty5.buffer.Buffer, .BufferAllocator, java.nio.ByteBuffer, java.nio.channels.ReadableByteChannel

A ChunkedInput that fetches data from a ReadableByteChannel chunk by chunk. Please note that the ReadableByteChannel must operate in blocking mode. Non-blocking mode channels are not supported.

Field Summary

Modifier and TypeField and Description
private final ByteBuffer
byteBuffer

Associated ByteBuffer

private final int
private final ReadableByteChannel
private long

Constructor Summary

AccessConstructor and Description
public
ChunkedNioStream(ReadableByteChannel in)

Creates a new instance that fetches data from the specified channel.

public
ChunkedNioStream(ReadableByteChannel in, int
the number of bytes to fetch on each readChunk(BufferAllocator) call
chunkSize
)

Creates a new instance that fetches data from the specified channel.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.
public boolean
isEndOfInput()

Implements io.netty5.handler.stream.ChunkedInput.isEndOfInput.

Return true if and only if there is no data left in the stream and the stream has reached at its end.
public long
length()

Implements io.netty5.handler.stream.ChunkedInput.length.

Returns the length of the input.
public long
progress()

Implements io.netty5.handler.stream.ChunkedInput.progress.

Returns current transfer progress.
public Buffer
readChunk(BufferAllocator
BufferAllocator if buffer allocation is necessary.
allocator
)

Implements io.netty5.handler.stream.ChunkedInput.readChunk.

Fetches a chunked data from the stream.
public long
transferredBytes()

Returns the number of transferred bytes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

byteBufferback to summary
private final ByteBuffer byteBuffer

Associated ByteBuffer

chunkSizeback to summary
private final int chunkSize
inback to summary
private final ReadableByteChannel in
offsetback to summary
private long offset

Constructor Detail

ChunkedNioStreamback to summary
public ChunkedNioStream(ReadableByteChannel in)

Creates a new instance that fetches data from the specified channel.

ChunkedNioStreamback to summary
public ChunkedNioStream(ReadableByteChannel in, int chunkSize)

Creates a new instance that fetches data from the specified channel.

Parameters
chunkSize:int

the number of bytes to fetch on each readChunk(BufferAllocator) call

Method Detail

closeback to summary
public void close() throws Exception

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
Exceptions
Exception:
if this resource cannot be closed
isEndOfInputback to summary
public boolean isEndOfInput() throws Exception

Implements io.netty5.handler.stream.ChunkedInput.isEndOfInput.

Doc from io.netty5.handler.stream.ChunkedInput.isEndOfInput.

Return true if and only if there is no data left in the stream and the stream has reached at its end.

Annotations
@Override
lengthback to summary
public long length()

Implements io.netty5.handler.stream.ChunkedInput.length.

Doc from io.netty5.handler.stream.ChunkedInput.length.

Returns the length of the input.

Returns:long

the length of the input if the length of the input is known. a negative value if the length of the input is unknown.

Annotations
@Override
progressback to summary
public long progress()

Implements io.netty5.handler.stream.ChunkedInput.progress.

Doc from io.netty5.handler.stream.ChunkedInput.progress.

Returns current transfer progress.

Annotations
@Override
readChunkback to summary
public Buffer readChunk(BufferAllocator allocator) throws Exception

Implements io.netty5.handler.stream.ChunkedInput.readChunk.

Doc from io.netty5.handler.stream.ChunkedInput.readChunk.

Fetches a chunked data from the stream. Once this method returns the last chunk and thus the stream has reached at its end, any subsequent isEndOfInput() call must return true.

Parameters
allocator:BufferAllocator

BufferAllocator if buffer allocation is necessary.

Returns:Buffer

the fetched chunk. null if there is no data left in the stream. Please note that null does not necessarily mean that the stream has reached at its end. In a slow stream, the next chunk might be unavailable just momentarily.

Annotations
@Override
transferredBytesback to summary
public long transferredBytes()

Returns the number of transferred bytes.