Package io.grpc.internal
Class AbstractReadableBuffer
- java.lang.Object
-
- io.grpc.internal.AbstractReadableBuffer
-
- All Implemented Interfaces:
ReadableBuffer,java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
CompositeReadableBuffer,NettyReadableBuffer,ReadableBuffers.ByteArrayWrapper,ReadableBuffers.ByteReadableBufferWrapper
public abstract class AbstractReadableBuffer extends java.lang.Object implements ReadableBuffer
Abstract base class forReadableBufferimplementations.
-
-
Constructor Summary
Constructors Constructor Description AbstractReadableBuffer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]array()Gets the backing array for this buffer.intarrayOffset()Gets the offset in the backing array of the current read position.booleanbyteBufferSupported()Indicates whether or notReadableBuffer.getByteBuffer()operation is supported for this buffer.protected voidcheckReadable(int length)voidclose()Closes this buffer and releases any resources.java.nio.ByteBuffergetByteBuffer()Gets aByteBufferthat contains some bytes of the content next to be read, ornullif this buffer has been exhausted.booleanhasArray()Indicates whether or not this buffer exposes a backing array.voidmark()Marks the current position in this buffer.booleanmarkSupported()Indicates whether or notReadableBuffer.mark()operation is supported for this buffer.intreadInt()Reads a 4-byte signed integer from this buffer using big-endian byte ordering.voidreset()Repositions this buffer to the position at the timeReadableBuffer.mark()was last called on this buffer.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.grpc.internal.ReadableBuffer
readableBytes, readBytes, readBytes, readBytes, readBytes, readUnsignedByte, skipBytes, touch
-
-
-
-
Method Detail
-
readInt
public final int readInt()
Description copied from interface:ReadableBufferReads a 4-byte signed integer from this buffer using big-endian byte ordering. Increments the read position by 4.- Specified by:
readIntin interfaceReadableBuffer
-
hasArray
public boolean hasArray()
Description copied from interface:ReadableBufferIndicates whether or not this buffer exposes a backing array.- Specified by:
hasArrayin interfaceReadableBuffer
-
array
public byte[] array()
Description copied from interface:ReadableBufferGets the backing array for this buffer. This is an optional method, so callers should first checkReadableBuffer.hasArray().- Specified by:
arrayin interfaceReadableBuffer
-
arrayOffset
public int arrayOffset()
Description copied from interface:ReadableBufferGets the offset in the backing array of the current read position. This is an optional method, so callers should first checkReadableBuffer.hasArray()- Specified by:
arrayOffsetin interfaceReadableBuffer
-
markSupported
public boolean markSupported()
Description copied from interface:ReadableBufferIndicates whether or notReadableBuffer.mark()operation is supported for this buffer.- Specified by:
markSupportedin interfaceReadableBuffer
-
mark
public void mark()
Description copied from interface:ReadableBufferMarks the current position in this buffer. A subsequent call to theReadableBuffer.reset()method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.- Specified by:
markin interfaceReadableBuffer
-
reset
public void reset()
Description copied from interface:ReadableBufferRepositions this buffer to the position at the timeReadableBuffer.mark()was last called on this buffer.- Specified by:
resetin interfaceReadableBuffer
-
byteBufferSupported
public boolean byteBufferSupported()
Description copied from interface:ReadableBufferIndicates whether or notReadableBuffer.getByteBuffer()operation is supported for this buffer.- Specified by:
byteBufferSupportedin interfaceReadableBuffer
-
getByteBuffer
public java.nio.ByteBuffer getByteBuffer()
Description copied from interface:ReadableBufferGets aByteBufferthat contains some bytes of the content next to be read, ornullif this buffer has been exhausted. The number of bytes contained in the returned buffer is implementation specific. The position of this buffer is unchanged after calling this method. 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 buffer. Buffers returned by this method have independent position, limit and mark. This is an optional method, so callers should first checkReadableBuffer.byteBufferSupported().- Specified by:
getByteBufferin interfaceReadableBuffer
-
close
public void close()
Description copied from interface:ReadableBufferCloses this buffer and releases any resources.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceReadableBuffer
-
checkReadable
protected final void checkReadable(int length)
-
-