public class OtpInputStream
extends java.io.ByteArrayInputStream
Note that this class is not synchronized, if you need synchronization you must provide it yourself.
Modifier and Type | Field and Description |
---|---|
static int |
DECODE_INT_LISTS_AS_STRINGS |
Constructor and Description |
---|
OtpInputStream(byte[] buf) |
OtpInputStream(byte[] buf,
int flags)
Create a stream from a buffer containing encoded Erlang terms.
|
OtpInputStream(byte[] buf,
int offset,
int length,
int flags)
Create a stream from a buffer containing encoded Erlang terms at the
given offset and length.
|
Modifier and Type | Method and Description |
---|---|
static long |
byte_array_to_long(byte[] b,
boolean unsigned) |
int |
getPos()
Get the current position in the stream.
|
int |
peek()
Alias for peek1()
|
int |
peek1()
Look ahead one position in the stream without consuming the byte found
there.
|
int |
peek1skip_version() |
OtpErlangObject |
read_any()
Read an arbitrary Erlang term from the stream.
|
java.lang.String |
read_atom()
Read an Erlang atom from the stream.
|
byte[] |
read_binary()
Read an Erlang binary from the stream.
|
byte[] |
read_bitstr(int[] pad_bits)
Read an Erlang bitstr from the stream.
|
boolean |
read_boolean()
Read an Erlang atom from the stream and interpret the value as a boolean.
|
byte |
read_byte()
Read one byte from the stream.
|
char |
read_char()
Read a character from the stream.
|
OtpErlangObject |
read_compressed()
Read a compressed term from the stream
|
double |
read_double()
Read an Erlang float from the stream.
|
OtpErlangExternalFun |
read_external_fun() |
float |
read_float()
Read an Erlang float from the stream.
|
OtpErlangFun |
read_fun() |
int |
read_int()
Read an integer from the stream.
|
byte[] |
read_integer_byte_array()
Read an integer from the stream.
|
int |
read_list_head()
Read a list header from the stream.
|
long |
read_long()
Read a long from the stream.
|
long |
read_long(boolean unsigned) |
int |
read_map_head() |
int |
read_nil()
Read an empty list from the stream.
|
OtpErlangPid |
read_pid()
Read an Erlang PID from the stream.
|
OtpErlangPort |
read_port()
Read an Erlang port from the stream.
|
OtpErlangRef |
read_ref()
Read an Erlang reference from the stream.
|
short |
read_short()
Read a short from the stream.
|
java.lang.String |
read_string()
Read a string from the stream.
|
int |
read_tuple_head()
Read a tuple header from the stream.
|
int |
read_uint()
Read an unsigned integer from the stream.
|
long |
read_ulong()
Read an unsigned long from the stream.
|
short |
read_ushort()
Read an unsigned short from the stream.
|
int |
read1()
Read a one byte integer from the stream.
|
int |
read1skip_version() |
int |
read2BE()
Read a two byte big endian integer from the stream.
|
int |
read2LE()
Read a two byte little endian integer from the stream.
|
int |
read4BE()
Read a four byte big endian integer from the stream.
|
int |
read4LE()
Read a four byte little endian integer from the stream.
|
long |
readBE(int n)
Read a bigendian integer from the stream.
|
long |
readLE(int n)
Read a little endian integer from the stream.
|
int |
readN(byte[] abuf)
Read an array of bytes from the stream.
|
int |
readN(byte[] abuf,
int off,
int len)
Read an array of bytes from the stream.
|
int |
setPos(int pos)
Set the current position in the stream.
|
public OtpInputStream(byte[] buf)
buf
- public OtpInputStream(byte[] buf, int flags)
flags
- public OtpInputStream(byte[] buf, int offset, int length, int flags)
flags
- public static long byte_array_to_long(byte[] b, boolean unsigned) throws OtpErlangDecodeException
OtpErlangDecodeException
public int getPos()
public int peek() throws OtpErlangDecodeException
OtpErlangDecodeException
public int peek1() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next byte cannot be read.public int peek1skip_version() throws OtpErlangDecodeException
OtpErlangDecodeException
public OtpErlangObject read_any() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the stream does not contain a known Erlang type at the
next position.public java.lang.String read_atom() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not an atom.public byte[] read_binary() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not a binary.public byte[] read_bitstr(int[] pad_bits) throws OtpErlangDecodeException
pad_bits
- an int array whose first element will be set to the number of
pad bits in the last byte.OtpErlangDecodeException
- if the next term in the stream is not a bitstr.public boolean read_boolean() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not an atom.public byte read_byte() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next byte cannot be read.public char read_char() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not an integer that can
be represented as a char.public OtpErlangObject read_compressed() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not a compressed term.public double read_double() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not a float.public OtpErlangExternalFun read_external_fun() throws OtpErlangDecodeException
OtpErlangDecodeException
public float read_float() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not a float.public OtpErlangFun read_fun() throws OtpErlangDecodeException
OtpErlangDecodeException
public int read_int() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream can not be represented as
an integer.public byte[] read_integer_byte_array() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not an integer.public int read_list_head() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not a list.public long read_long() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream can not be represented as a
long.public long read_long(boolean unsigned) throws OtpErlangDecodeException
OtpErlangDecodeException
public int read_map_head() throws OtpErlangDecodeException
OtpErlangDecodeException
public int read_nil() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not an empty list.public OtpErlangPid read_pid() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not an Erlang PID.public OtpErlangPort read_port() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not an Erlang port.public OtpErlangRef read_ref() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not an Erlang reference.public short read_short() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream can not be represented as a
short.public java.lang.String read_string() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not a string.public int read_tuple_head() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream is not a tuple.public int read_uint() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream can not be represented as a
positive integer.public long read_ulong() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream can not be represented as a
positive long.public short read_ushort() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next term in the stream can not be represented as a
positive short.public int read1() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next byte cannot be read.public int read1skip_version() throws OtpErlangDecodeException
OtpErlangDecodeException
public int read2BE() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next byte cannot be read.public int read2LE() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next byte cannot be read.public int read4BE() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next byte cannot be read.public int read4LE() throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next byte cannot be read.public long readBE(int n) throws OtpErlangDecodeException
n
- the number of bytes to readOtpErlangDecodeException
- if the next byte cannot be read.public long readLE(int n) throws OtpErlangDecodeException
n
- the number of bytes to readOtpErlangDecodeException
- if the next byte cannot be read.public int readN(byte[] abuf) throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next byte cannot be read.public int readN(byte[] abuf, int off, int len) throws OtpErlangDecodeException
OtpErlangDecodeException
- if the next byte cannot be read.public int setPos(int pos)
pos
- the position to move to in the stream. If pos indicates a
position beyond the end of the stream, the position is move to
the end of the stream instead. If pos is negative, the
position is moved to the beginning of the stream instead.