Package com.google.protobuf
Class IterableByteBufferInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.google.protobuf.IterableByteBufferInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
class IterableByteBufferInputStream extends java.io.InputStream
-
-
Field Summary
Fields Modifier and Type Field Description private long
currentAddress
If the current ByteBuffer is unsafe-direct based, currentAddress is the start address of this ByteBuffer; otherwise should be zero.private byte[]
currentArray
If the current ByteBuffer is unsafe-direct based, currentArray is null; otherwise should be the array inside ByteBuffer.private int
currentArrayOffset
Current ByteBuffer's array offsetprivate java.nio.ByteBuffer
currentByteBuffer
The current ByteBuffer;private int
currentByteBufferPos
The current position for current ByteBufferprivate int
currentIndex
CurrentByteBuffer
's indexprivate int
dataSize
The number of ByteBuffers in the input data.private boolean
hasArray
Whether current ByteBuffer has an arrayprivate java.util.Iterator<java.nio.ByteBuffer>
iterator
TheIterator
with typeByteBuffer
ofinput
-
Constructor Summary
Constructors Constructor Description IterableByteBufferInputStream(java.lang.Iterable<java.nio.ByteBuffer> data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
getNextByteBuffer()
int
read()
int
read(byte[] output, int offset, int length)
private void
updateCurrentByteBufferPos(int numberOfBytesRead)
-
-
-
Field Detail
-
iterator
private java.util.Iterator<java.nio.ByteBuffer> iterator
TheIterator
with typeByteBuffer
ofinput
-
currentByteBuffer
private java.nio.ByteBuffer currentByteBuffer
The current ByteBuffer;
-
dataSize
private int dataSize
The number of ByteBuffers in the input data.
-
currentIndex
private int currentIndex
CurrentByteBuffer
's indexIf index equals dataSize, then all the data in the InputStream has been consumed
-
currentByteBufferPos
private int currentByteBufferPos
The current position for current ByteBuffer
-
hasArray
private boolean hasArray
Whether current ByteBuffer has an array
-
currentArray
private byte[] currentArray
If the current ByteBuffer is unsafe-direct based, currentArray is null; otherwise should be the array inside ByteBuffer.
-
currentArrayOffset
private int currentArrayOffset
Current ByteBuffer's array offset
-
currentAddress
private long currentAddress
If the current ByteBuffer is unsafe-direct based, currentAddress is the start address of this ByteBuffer; otherwise should be zero.
-
-
Method Detail
-
getNextByteBuffer
private boolean getNextByteBuffer()
-
updateCurrentByteBufferPos
private void updateCurrentByteBufferPos(int numberOfBytesRead)
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] output, int offset, int length) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
-