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 longcurrentAddressIf the current ByteBuffer is unsafe-direct based, currentAddress is the start address of this ByteBuffer; otherwise should be zero.private byte[]currentArrayIf the current ByteBuffer is unsafe-direct based, currentArray is null; otherwise should be the array inside ByteBuffer.private intcurrentArrayOffsetCurrent ByteBuffer's array offsetprivate java.nio.ByteBuffercurrentByteBufferThe current ByteBuffer;private intcurrentByteBufferPosThe current position for current ByteBufferprivate intcurrentIndexCurrentByteBuffer's indexprivate intdataSizeThe number of ByteBuffers in the input data.private booleanhasArrayWhether current ByteBuffer has an arrayprivate java.util.Iterator<java.nio.ByteBuffer>iteratorTheIteratorwith typeByteBufferofinput
-
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 booleangetNextByteBuffer()intread()intread(byte[] output, int offset, int length)private voidupdateCurrentByteBufferPos(int numberOfBytesRead)
-
-
-
Field Detail
-
iterator
private java.util.Iterator<java.nio.ByteBuffer> iterator
TheIteratorwith typeByteBufferofinput
-
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:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] output, int offset, int length) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
-