public abstract class BinaryInput extends Object
BinaryMarshaller
to unmarshal parameters and results passed by
value.Modifier and Type | Method and Description |
---|---|
static BinaryInput |
create(byte[] buffer)
Creates a new buffer backed by a byte array.
|
static BinaryInput |
create(org.graalvm.nativeimage.c.type.CCharPointer address,
int length)
Creates a new buffer wrapping an off-heap memory segment starting at an
address
having length bytes. |
abstract int |
read()
Reads a single byte.
|
abstract int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes into a byte array starting at offset off . |
boolean |
readBoolean()
Reads a single byte and returns
true if that byte is non-zero, false if that
byte is zero. |
byte |
readByte()
Reads and returns a single byte.
|
char |
readChar()
Reads two bytes and returns a
char value. |
double |
readDouble()
Reads eight bytes and returns a
double value. |
float |
readFloat()
Reads four bytes and returns a
float value. |
void |
readFully(byte[] b,
int off,
int len)
Reads
len bytes into a byte array starting at offset off . |
int |
readInt()
Reads four bytes and returns an
int value. |
long |
readLong()
Reads eight bytes and returns a
long value. |
short |
readShort()
Reads two bytes and returns a
short value. |
Object |
readTypedValue()
Reads a single value, using the data type encoded in the marshalled data.
|
String |
readUTF()
Reads a string using a modified UTF-8 encoding in a machine-independent manner.
|
public final boolean readBoolean() throws IndexOutOfBoundsException
true
if that byte is non-zero, false
if that
byte is zero.IndexOutOfBoundsException
- if there are not enough bytes to read.public final byte readByte() throws IndexOutOfBoundsException
IndexOutOfBoundsException
- if there are not enough bytes to read.public final short readShort() throws IndexOutOfBoundsException
short
value.IndexOutOfBoundsException
- if there are not enough bytes to read.public final char readChar() throws IndexOutOfBoundsException
char
value.IndexOutOfBoundsException
- if there are not enough bytes to read.public final int readInt() throws IndexOutOfBoundsException
int
value.IndexOutOfBoundsException
- if there are not enough bytes to read.public final long readLong() throws IndexOutOfBoundsException
long
value.IndexOutOfBoundsException
- if there are not enough bytes to read.public final float readFloat() throws IndexOutOfBoundsException
float
value. It does this by reading an int
value and converting the int
value to a float
using
Float.intBitsToFloat(int)
.IndexOutOfBoundsException
- if there are not enough bytes to read.public final double readDouble() throws IndexOutOfBoundsException
double
value. It does this by reading a long
value and converting the long
value to a double
using
Double.longBitsToDouble(long)
.IndexOutOfBoundsException
- if there are not enough bytes to read.public abstract int read()
int
in the range 0
to
255
. If no byte is available because the end of the stream has been reached, the
value -1
is returned.public abstract int read(byte[] b, int off, int len)
len
bytes into a byte array starting at offset off
.public final void readFully(byte[] b, int off, int len) throws IndexOutOfBoundsException
len
bytes into a byte array starting at offset off
.IndexOutOfBoundsException
- if there are not enough bytes to readpublic final String readUTF() throws IndexOutOfBoundsException, IllegalArgumentException
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.public final Object readTypedValue() throws IndexOutOfBoundsException, IllegalArgumentException
String
, a null
, or
an array of these types.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.public static BinaryInput create(byte[] buffer)
public static BinaryInput create(org.graalvm.nativeimage.c.type.CCharPointer address, int length)
address
having length
bytes.