Class BinaryInput
java.lang.Object
org.graalvm.nativebridge.BinaryInput
A buffer used by the
BinaryMarshaller to unmarshal parameters and results passed by
value.- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionabstract ByteBufferasByteBuffer(int len) Returns a read onlyByteBufferbacked by theBinaryInputinternal buffer.static BinaryInputcreate(byte[] buffer) Creates a new buffer backed by a byte array.static BinaryInputcreate(byte[] buffer, int length) Creates a new buffer backed by a byte array only up to a given length.static BinaryInputcreate(org.graalvm.nativeimage.c.type.CCharPointer address, int length) Creates a new buffer wrapping an off-heap memory segment starting at anaddresshavinglengthbytes.abstract intread()Reads a single byte.final voidread(boolean[] b, int off, int len) Readslenbytes into a boolean array starting at offsetoff.abstract voidread(byte[] b, int off, int len) Readslenbytes into a byte array starting at offsetoff.final voidread(char[] b, int off, int len) Readslenchars into a char array starting at offsetoff.final voidread(double[] b, int off, int len) Readslendoubles into a double array starting at offsetoff.final voidread(float[] b, int off, int len) Readslenfloats into a float array starting at offsetoff.final voidread(int[] b, int off, int len) Readslenints into an int array starting at offsetoff.final voidread(long[] b, int off, int len) Readslenlongs into a long array starting at offsetoff.final voidread(short[] b, int off, int len) Readslenshorts into a short array starting at offsetoff.final booleanReads a single byte and returnstrueif that byte is non-zero,falseif that byte is zero.final bytereadByte()Reads and returns a single byte.final charreadChar()Reads two bytes and returns acharvalue.final doubleReads eight bytes and returns adoublevalue.final floatReads four bytes and returns afloatvalue.final intreadInt()Reads four bytes and returns anintvalue.final longreadLong()Reads eight bytes and returns alongvalue.final shortReads two bytes and returns ashortvalue.final ObjectReads a single value, using the data type encoded in the marshalled data.final StringreadUTF()Reads a string using a modified UTF-8 encoding in a machine-independent manner.
-
Field Details
-
length
protected final int length -
pos
protected int pos
-
-
Method Details
-
readBoolean
Reads a single byte and returnstrueif that byte is non-zero,falseif that byte is zero.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read.
-
readByte
Reads and returns a single byte.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read.
-
readShort
Reads two bytes and returns ashortvalue.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read.
-
readChar
Reads two bytes and returns acharvalue.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read.
-
readInt
Reads four bytes and returns anintvalue.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read.
-
readLong
Reads eight bytes and returns alongvalue.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read.
-
readFloat
Reads four bytes and returns afloatvalue. It does this by reading anintvalue and converting theintvalue to afloatusingFloat.intBitsToFloat(int).- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read.
-
readDouble
Reads eight bytes and returns adoublevalue. It does this by reading alongvalue and converting thelongvalue to adoubleusingDouble.longBitsToDouble(long).- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read.
-
read
public abstract int read()Reads a single byte. The byte value is returned as anintin the range0to255. If no byte is available because the end of the stream has been reached, the value-1is returned. -
read
Readslenbytes into a byte array starting at offsetoff.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read
-
readUTF
Reads a string using a modified UTF-8 encoding in a machine-independent manner.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read.IllegalArgumentException- if the bytes do not represent a valid modified UTF-8 encoding of a string.
-
readTypedValue
Reads a single value, using the data type encoded in the marshalled data.- Returns:
- The read value, such as a boxed Java primitive, a
String, anull, or an array of these types. - Throws:
IndexOutOfBoundsException- if there are not enough bytes to read.IllegalArgumentException- when the marshaled type is not supported or if the bytes do not represent a valid modified UTF-8 encoding of a string.
-
read
public final void read(boolean[] b, int off, int len) Readslenbytes into a boolean array starting at offsetoff.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read
-
read
public final void read(short[] b, int off, int len) Readslenshorts into a short array starting at offsetoff.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read
-
read
public final void read(char[] b, int off, int len) Readslenchars into a char array starting at offsetoff.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read
-
read
public final void read(int[] b, int off, int len) Readslenints into an int array starting at offsetoff.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read
-
read
public final void read(long[] b, int off, int len) Readslenlongs into a long array starting at offsetoff.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read
-
read
public final void read(float[] b, int off, int len) Readslenfloats into a float array starting at offsetoff.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read
-
read
public final void read(double[] b, int off, int len) Readslendoubles into a double array starting at offsetoff.- Throws:
IndexOutOfBoundsException- if there are not enough bytes to read
-
asByteBuffer
Returns a read onlyByteBufferbacked by theBinaryInputinternal buffer. The content of the buffer will start at theBinaryInput's current position. The buffer's capacity and limit will belen, its position will be zero, its mark will be undefined, and its byte order will beBIG_ENDIAN. After a successful call, theBinaryInput's current position is incremented by thelen.- Throws:
IndexOutOfBoundsException- if the BinaryInput has not enough remaining bytes.
-
create
Creates a new buffer backed by a byte array. -
create
Creates a new buffer backed by a byte array only up to a given length. -
create
Creates a new buffer wrapping an off-heap memory segment starting at anaddresshavinglengthbytes.
-