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
AnInputStreamthat is backed by aReadableBuffer.
-
-
Field Summary
Fields Modifier and Type Field Description private ReadableBufferbuffer
-
Constructor Summary
Constructors Constructor Description BufferInputStream(ReadableBuffer buffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Returns the total number of bytes that can be read (or skipped over) from this object until all bytes have been read out.booleanbyteBufferSupported()Indicates whether or notHasByteBuffer.getByteBuffer()operation is supported.voidclose()java.io.InputStreamdetach()Detaches the underlying data source from this instance and transfers to anInputStream.java.nio.ByteBuffergetByteBuffer()Gets aByteBuffercontaining some bytes of the content next to be read, ornullif has reached end of the content.voidmark(int readlimit)booleanmarkSupported()intread()intread(byte[] dest, int destOffset, int length)voidreset()longskip(long n)
-
-
-
Field Detail
-
buffer
private ReadableBuffer buffer
-
-
Constructor Detail
-
BufferInputStream
public BufferInputStream(ReadableBuffer buffer)
-
-
Method Detail
-
available
public int available() throws java.io.IOExceptionDescription copied from interface:KnownLengthReturns the total number of bytes that can be read (or skipped over) from this object until all bytes have been read out.- Specified by:
availablein interfaceKnownLength- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read()
- Specified by:
readin classjava.io.InputStream
-
read
public int read(byte[] dest, int destOffset, int length) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
mark
public void mark(int readlimit)
- Overrides:
markin classjava.io.InputStream
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.InputStream- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
byteBufferSupported
public boolean byteBufferSupported()
Description copied from interface:HasByteBufferIndicates whether or notHasByteBuffer.getByteBuffer()operation is supported.- Specified by:
byteBufferSupportedin interfaceHasByteBuffer
-
getByteBuffer
@Nullable public java.nio.ByteBuffer getByteBuffer()
Description copied from interface:HasByteBufferGets aByteBuffercontaining some bytes of the content next to be read, ornullif 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:
getByteBufferin interfaceHasByteBuffer
-
detach
public java.io.InputStream detach()
Description copied from interface:DetachableDetaches 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:
detachin interfaceDetachable
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
-