Package io.pravega.common.util
Class AbstractBufferView.AbstractReader
- java.lang.Object
-
- io.pravega.common.util.AbstractBufferView.AbstractReader
-
- All Implemented Interfaces:
BufferView.Reader
- Enclosing class:
- AbstractBufferView
protected abstract static class AbstractBufferView.AbstractReader extends java.lang.Object implements BufferView.Reader
Base implementation ofBufferView.Reader. Subclasses ofAbstractBufferViewshould implement their ownBufferView.Readerinstances based on this class.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.pravega.common.util.BufferView.Reader
BufferView.Reader.OutOfBoundsException
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ArrayViewreadFully(int bufferSize)Copies all the remaining bytes from thisBufferView.Readerinto a newArrayView.intreadInt()Reads 4 bytes (and advances the reader position by 4) and composes a 32-bit Integer (Big-Endian).longreadLong()Reads 8 bytes (and advances the reader position by 4) and composes a 64-bit Long (Big-Endian).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.pravega.common.util.BufferView.Reader
available, readByte, readBytes, readSlice
-
-
-
-
Method Detail
-
readInt
public int readInt()
Reads 4 bytes (and advances the reader position by 4) and composes a 32-bit Integer (Big-Endian). Default implementation forBufferView.Reader.readInt(). Derived classes should make every effort to override this implementation with one that is as efficient as possible (if theBufferViewimplementation allows it).- Specified by:
readIntin interfaceBufferView.Reader- Returns:
- The read int.
- Throws:
BufferView.Reader.OutOfBoundsException- IfBufferView.Reader.available()is less thanInteger.BYTES.
-
readLong
public long readLong()
Reads 8 bytes (and advances the reader position by 4) and composes a 64-bit Long (Big-Endian). Default implementation forBufferView.Reader.readLong(). Derived classes should make every effort to override this implementation with one that is as efficient as possible (if theBufferViewimplementation allows it).- Specified by:
readLongin interfaceBufferView.Reader- Returns:
- The read int.
- Throws:
BufferView.Reader.OutOfBoundsException- IfBufferView.Reader.available()is less thanLong.BYTES.
-
readFully
public ArrayView readFully(int bufferSize)
Description copied from interface:BufferView.ReaderCopies all the remaining bytes from thisBufferView.Readerinto a newArrayView. The reader position will be set to the end of theBufferView.- Specified by:
readFullyin interfaceBufferView.Reader- Parameters:
bufferSize- The maximum number of bytes to copy at each iteration. Set toInteger.MAX_VALUEto attempt to copy the whole buffer at once.- Returns:
- A new
ByteArraySegmentwith the remaining contents ofBufferView.Reader.
-
-