Package io.grpc.internal
Class ReadableBuffers.BufferInputStream
java.lang.Object
java.io.InputStream
io.grpc.internal.ReadableBuffers.BufferInputStream
- All Implemented Interfaces:
Detachable
,HasByteBuffer
,KnownLength
,Closeable
,AutoCloseable
- Enclosing class:
ReadableBuffers
private static final class ReadableBuffers.BufferInputStream
extends InputStream
implements KnownLength, HasByteBuffer, Detachable
An
InputStream
that is backed by a ReadableBuffer
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the total number of bytes that can be read (or skipped over) from this object until all bytes have been read out.boolean
Indicates whether or notHasByteBuffer.getByteBuffer()
operation is supported.void
close()
detach()
Detaches the underlying data source from this instance and transfers to anInputStream
.Gets aByteBuffer
containing some bytes of the content next to be read, ornull
if has reached end of the content.void
mark
(int readlimit) boolean
int
read()
int
read
(byte[] dest, int destOffset, int length) void
reset()
long
skip
(long n) Methods inherited from class java.io.InputStream
read
-
Field Details
-
buffer
-
-
Constructor Details
-
BufferInputStream
-
-
Method Details
-
available
Description copied from interface:KnownLength
Returns the total number of bytes that can be read (or skipped over) from this object until all bytes have been read out.- Specified by:
available
in interfaceKnownLength
- Overrides:
available
in classInputStream
- Throws:
IOException
-
read
public int read()- Specified by:
read
in classInputStream
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
mark
in classInputStream
-
reset
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-
byteBufferSupported
public boolean byteBufferSupported()Description copied from interface:HasByteBuffer
Indicates whether or notHasByteBuffer.getByteBuffer()
operation is supported.- Specified by:
byteBufferSupported
in interfaceHasByteBuffer
-
getByteBuffer
Description copied from interface:HasByteBuffer
Gets aByteBuffer
containing some bytes of the content next to be read, ornull
if has reached end of the content. The number of bytes contained in the returned buffer is implementation specific. Calling this method does not change the position of the input stream. The returned buffer's content should not be modified, but the position, limit, and mark may be changed. Operations for changing the position, limit, and mark of the returned buffer does not affect the position, limit, and mark of this input stream. This is an optional method, so callers should first checkHasByteBuffer.byteBufferSupported()
.- Specified by:
getByteBuffer
in interfaceHasByteBuffer
-
detach
Description copied from interface:Detachable
Detaches the underlying data source from this instance and transfers to anInputStream
. Detaching data from an already-detached instance gives an InputStream with zero bytes of data.- Specified by:
detach
in interfaceDetachable
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-