Package io.grpc.internal
Class ReadableBuffers.BufferInputStream
- java.lang.Object
-
- java.io.InputStream
-
- io.grpc.internal.ReadableBuffers.BufferInputStream
-
- All Implemented Interfaces:
Detachable
,HasByteBuffer
,KnownLength
,java.io.Closeable
,java.lang.AutoCloseable
- Enclosing class:
- ReadableBuffers
private static final class ReadableBuffers.BufferInputStream extends java.io.InputStream implements KnownLength, HasByteBuffer, Detachable
AnInputStream
that is backed by aReadableBuffer
.
-
-
Field Summary
Fields Modifier and Type Field Description private ReadableBuffer
buffer
-
Constructor Summary
Constructors Constructor Description BufferInputStream(ReadableBuffer buffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
Returns the total number of bytes that can be read (or skipped over) from this object until all bytes have been read out.boolean
byteBufferSupported()
Indicates whether or notHasByteBuffer.getByteBuffer()
operation is supported.void
close()
java.io.InputStream
detach()
Detaches the underlying data source from this instance and transfers to anInputStream
.java.nio.ByteBuffer
getByteBuffer()
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
markSupported()
int
read()
int
read(byte[] dest, int destOffset, int length)
void
reset()
long
skip(long n)
-
-
-
Field Detail
-
buffer
private ReadableBuffer buffer
-
-
Constructor Detail
-
BufferInputStream
public BufferInputStream(ReadableBuffer buffer)
-
-
Method Detail
-
available
public int available() throws java.io.IOException
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 classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read()
- Specified by:
read
in classjava.io.InputStream
-
read
public int read(byte[] dest, int destOffset, int length) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException
- Overrides:
skip
in classjava.io.InputStream
- Throws:
java.io.IOException
-
mark
public void mark(int readlimit)
- Overrides:
mark
in classjava.io.InputStream
-
reset
public void reset() throws java.io.IOException
- Overrides:
reset
in classjava.io.InputStream
- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.InputStream
-
byteBufferSupported
public boolean byteBufferSupported()
Description copied from interface:HasByteBuffer
Indicates whether or notHasByteBuffer.getByteBuffer()
operation is supported.- Specified by:
byteBufferSupported
in interfaceHasByteBuffer
-
getByteBuffer
@Nullable public java.nio.ByteBuffer 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
public java.io.InputStream 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
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
-