Class BinaryByteBufferInputStream
- java.lang.Object
-
- org.apache.ignite.internal.binary.streams.BinaryByteBufferInputStream
-
- All Implemented Interfaces:
BinaryPositionReadable,BinaryInputStream,BinaryStream
public class BinaryByteBufferInputStream extends Object implements BinaryInputStream
Input stream overByteBuffer.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]array()byte[]arrayCopy()intcapacity()static BinaryByteBufferInputStreamcreate(ByteBuffer buf)booleanhasArray()longoffheapPointer()intposition()voidposition(int pos)longrawOffheapPointer()intread(byte[] arr, int off, int cnt)Readscntof bytes into byte array.booleanreadBoolean()Read boolean value.boolean[]readBooleanArray(int cnt)Read boolean array.bytereadByte()Read byte value.byte[]readByteArray(int cnt)Read byte array.bytereadBytePositioned(int pos)Read byte at the given position.charreadChar()Read char value.char[]readCharArray(int cnt)Read char array.doublereadDouble()Read double value.double[]readDoubleArray(int cnt)Read double array.floatreadFloat()Read float value.float[]readFloatArray(int cnt)Read float array.intreadInt()Read int value.int[]readIntArray(int cnt)Read int array.intreadIntPositioned(int pos)Read integer at the given position.longreadLong()Read long value.long[]readLongArray(int cnt)Read long array.shortreadShort()Read short value.short[]readShortArray(int cnt)Read short array.shortreadShortPositioned(int pos)Read short at the given position.intremaining()Gets amount of remaining data in bytes.
-
-
-
Method Detail
-
create
public static BinaryByteBufferInputStream create(ByteBuffer buf)
- Parameters:
buf- Buffer to wrap.- Returns:
- Stream.
-
readByte
public byte readByte()
Read byte value.- Specified by:
readBytein interfaceBinaryInputStream- Returns:
- Byte value.
-
readByteArray
public byte[] readByteArray(int cnt)
Read byte array.- Specified by:
readByteArrayin interfaceBinaryInputStream- Parameters:
cnt- Expected item count.- Returns:
- Byte array.
-
read
public int read(byte[] arr, int off, int cnt)Readscntof bytes into byte array.- Specified by:
readin interfaceBinaryInputStream- Parameters:
arr- Expected item count.off- offsetcnt- number of bytes to read.- Returns:
- actual length read.
-
readBoolean
public boolean readBoolean()
Read boolean value.- Specified by:
readBooleanin interfaceBinaryInputStream- Returns:
- Boolean value.
-
readBooleanArray
public boolean[] readBooleanArray(int cnt)
Read boolean array.- Specified by:
readBooleanArrayin interfaceBinaryInputStream- Parameters:
cnt- Expected item count.- Returns:
- Boolean array.
-
readShort
public short readShort()
Read short value.- Specified by:
readShortin interfaceBinaryInputStream- Returns:
- Short value.
-
readShortArray
public short[] readShortArray(int cnt)
Read short array.- Specified by:
readShortArrayin interfaceBinaryInputStream- Parameters:
cnt- Expected item count.- Returns:
- Short array.
-
readChar
public char readChar()
Read char value.- Specified by:
readCharin interfaceBinaryInputStream- Returns:
- Char value.
-
readCharArray
public char[] readCharArray(int cnt)
Read char array.- Specified by:
readCharArrayin interfaceBinaryInputStream- Parameters:
cnt- Expected item count.- Returns:
- Char array.
-
readInt
public int readInt()
Read int value.- Specified by:
readIntin interfaceBinaryInputStream- Returns:
- Int value.
-
readIntArray
public int[] readIntArray(int cnt)
Read int array.- Specified by:
readIntArrayin interfaceBinaryInputStream- Parameters:
cnt- Expected item count.- Returns:
- Int array.
-
readFloat
public float readFloat()
Read float value.- Specified by:
readFloatin interfaceBinaryInputStream- Returns:
- Float value.
-
readFloatArray
public float[] readFloatArray(int cnt)
Read float array.- Specified by:
readFloatArrayin interfaceBinaryInputStream- Parameters:
cnt- Expected item count.- Returns:
- Float array.
-
readLong
public long readLong()
Read long value.- Specified by:
readLongin interfaceBinaryInputStream- Returns:
- Long value.
-
readLongArray
public long[] readLongArray(int cnt)
Read long array.- Specified by:
readLongArrayin interfaceBinaryInputStream- Parameters:
cnt- Expected item count.- Returns:
- Long array.
-
readDouble
public double readDouble()
Read double value.- Specified by:
readDoublein interfaceBinaryInputStream- Returns:
- Double value.
-
readDoubleArray
public double[] readDoubleArray(int cnt)
Read double array.- Specified by:
readDoubleArrayin interfaceBinaryInputStream- Parameters:
cnt- Expected item count.- Returns:
- Double array.
-
remaining
public int remaining()
Gets amount of remaining data in bytes.- Specified by:
remainingin interfaceBinaryInputStream- Returns:
- Remaining data.
-
readBytePositioned
public byte readBytePositioned(int pos)
Read byte at the given position.- Specified by:
readBytePositionedin interfaceBinaryPositionReadable- Parameters:
pos- Position.- Returns:
- Value.
-
readShortPositioned
public short readShortPositioned(int pos)
Read short at the given position.- Specified by:
readShortPositionedin interfaceBinaryPositionReadable- Parameters:
pos- Position.- Returns:
- Value.
-
readIntPositioned
public int readIntPositioned(int pos)
Read integer at the given position.- Specified by:
readIntPositionedin interfaceBinaryPositionReadable- Parameters:
pos- Position.- Returns:
- Value.
-
position
public int position()
- Specified by:
positionin interfaceBinaryStream- Returns:
- Position.
-
position
public void position(int pos)
- Specified by:
positionin interfaceBinaryStream- Parameters:
pos- Position.
-
rawOffheapPointer
public long rawOffheapPointer()
- Specified by:
rawOffheapPointerin interfaceBinaryStream- Returns:
- Offheap pointer if stream is offheap based; otherwise
0.
-
capacity
public int capacity()
- Specified by:
capacityin interfaceBinaryStream- Returns:
- Total capacity.
-
array
public byte[] array()
- Specified by:
arrayin interfaceBinaryStream- Returns:
- Underlying array.
-
arrayCopy
public byte[] arrayCopy()
- Specified by:
arrayCopyin interfaceBinaryStream- Returns:
- Copy of data in the stream.
-
offheapPointer
public long offheapPointer()
- Specified by:
offheapPointerin interfaceBinaryStream- Returns:
- Offheap pointer if stream is offheap based and "forceHeap" flag is not set; otherwise
0.
-
hasArray
public boolean hasArray()
- Specified by:
hasArrayin interfaceBinaryStream- Returns:
Trueis stream is array based.
-
-