public class ConfOutputStream extends Object
Note that this class is not synchronized, if you need synchronization you must provide it yourself.
Modifier and Type | Field and Description |
---|---|
static int |
defaultInitialSize
The default initial size of the stream.
|
Constructor and Description |
---|
ConfOutputStream()
Create a stream with the default initial size.
|
ConfOutputStream(ConfEObject o)
Create a stream containing the encoded version of the given E term.
|
ConfOutputStream(int size)
Create a stream with the specified initial size.
|
Modifier and Type | Method and Description |
---|---|
int |
count()
Get the number of bytes in the stream.
|
int |
getPos()
Get the current position in the stream.
|
void |
poke4BE(int offset,
long n)
Write the low four bytes of a value to the stream in bif endian order, at
the specified position.
|
void |
reset()
Reset the stream so that it can be reused.
|
int |
size()
Get the current capacity of the stream.
|
byte[] |
toByteArray()
Get the contents of the stream in a byte array.
|
void |
write_any(ConfEObject o)
Write an arbitrary E term to the stream.
|
void |
write_atom(String atom)
Write a string to the stream as an E atom.
|
void |
write_binary(byte[] bin)
Write an array of bytes to the stream as an E binary.
|
void |
write_boolean(boolean b)
Write a boolean value to the stream as the E atom 'true' or 'false'.
|
void |
write_byte(byte b)
Write a single byte to the stream as an E integer.
|
void |
write_char(char c)
Write a character to the stream as an E integer.
|
void |
write_double(double d)
Write a double value to the stream.
|
void |
write_float(float f)
Write a float value to the stream.
|
void |
write_int(int i)
Write an integer to the stream.
|
void |
write_list_head(int arity)
Write an E list header to the stream.
|
void |
write_long(long l)
Write a long to the stream.
|
void |
write_nil()
Write an empty E list to the stream.
|
void |
write_pid(String node,
int id,
int serial,
int creation)
Write an E PID to the stream.
|
void |
write_port(String node,
int id,
int creation)
Write an E port to the stream.
|
void |
write_ref(String node,
int[] ids,
int creation)
Write a new style (R6 and later) E ref to the stream.
|
void |
write_ref(String node,
int id,
int creation)
Write an old style E ref to the stream.
|
void |
write_short(short s)
Write a short to the stream.
|
void |
write_string(String s)
Write a string to the stream.
|
void |
write_tuple_head(int arity)
Write an E tuple header to the stream.
|
void |
write_uint(int ui)
Write a positive integer to the stream.
|
void |
write_ulong(long ul)
Write a positive long to the stream.
|
void |
write_ushort(short us)
Write a positive short to the stream.
|
void |
write(byte b)
Write one byte to the stream.
|
void |
write(byte[] buf)
Write an array of bytes to the stream.
|
void |
write1(long n)
Write the low byte of a value to the stream.
|
void |
write2BE(long n)
Write the low two bytes of a value to the stream in big endian order.
|
void |
write2LE(long n)
Write the low two bytes of a value to the stream in little endian order.
|
void |
write4BE(long n)
Write the low four bytes of a value to the stream in big endian order.
|
void |
write4LE(long n)
Write the low four bytes of a value to the stream in little endian order.
|
void |
write8LE(long n)
Write the low eight bytes of a value to the stream in little endian
order.
|
void |
writeLE(long n,
int b)
Write any number of bytes in little endian format.
|
void |
writeN(byte[] bytes)
Write an array of bytes to the stream.
|
void |
writeTo(OutputStream os)
Write the contents of the stream to an OutputStream.
|
void |
writeTo(SocketChannel channel,
SelectionKey key) |
public static final int defaultInitialSize
public ConfOutputStream()
public ConfOutputStream(int size)
public ConfOutputStream(ConfEObject o)
public void reset()
public int getPos()
public byte[] toByteArray()
public void write(byte b)
b
- the byte to write.public void write(byte[] buf)
buf
- the array of bytes to write.public void writeTo(OutputStream os) throws IOException
os
- the OutputStream to write to.IOException
- if there is an error writing to the OutputStream.public void writeTo(SocketChannel channel, SelectionKey key) throws IOException
IOException
public void write1(long n)
n
- the value to use.public void writeN(byte[] bytes)
bytes
- the array of bytes to write.public int size()
public int count()
public void write2BE(long n)
n
- the value to use.public void write4BE(long n)
n
- the value to use.public void writeLE(long n, int b)
n
- the value to use.b
- the number of bytes to write from the little end.public void write2LE(long n)
n
- the value to use.public void write4LE(long n)
n
- the value to use.public void write8LE(long n)
n
- the value to use.public void poke4BE(int offset, long n)
getPos()
, when is is necessary to insert data into the stream before it
is known what the actual value should be. For example:
int pos = s.getPos(); s.write4BE(0); // make space for length data, // but final value is not yet known [ ...more write statements...] // later... when we know the length value s.poke4BE(pos, length);
offset
- the position in the stream.n
- the value to use.public void write_atom(String atom)
atom
- the string to write.public void write_binary(byte[] bin)
bin
- the array of bytes to write.public void write_boolean(boolean b)
b
- the boolean value to write.public void write_byte(byte b)
b
- the byte to use.public void write_char(char c)
c
- the character to use.public void write_double(double d)
d
- the double to use.public void write_float(float f)
f
- the float to use.public void write_long(long l)
l
- the long to use.public void write_ulong(long ul)
ul
- the long to use.public void write_int(int i)
i
- the integer to use.public void write_uint(int ui)
ui
- the integer to use.public void write_short(short s)
s
- the short to use.public void write_ushort(short us)
us
- the short to use.public void write_list_head(int arity)
arity
- the number of elements in the list.public void write_nil()
public void write_tuple_head(int arity)
arity
- the number of elements in the tuple.public void write_pid(String node, int id, int serial, int creation)
node
- the nodename.id
- an arbitrary number. Only the low order 15 bits will be used.serial
- another arbitrary number. Only the low order 13 bits will be
used.creation
- yet another arbitrary number. Only the low order 2 bits will
be used.public void write_port(String node, int id, int creation)
node
- the nodename.id
- an arbitrary number. Only the low order 28 bits will be used.creation
- another arbitrary number. Only the low order 2 bits will be
used.public void write_ref(String node, int id, int creation)
node
- the nodename.id
- an arbitrary number. Only the low order 18 bits will be used.creation
- another arbitrary number. Only the low order 2 bits will be
used.public void write_ref(String node, int[] ids, int creation)
node
- the nodename.ids
- an array of arbitrary numbers. Only the low order 18 bits of
the first number will be used. If the array contains only one
number, an old style ref will be written instead. At most
three numbers will be read from the array.creation
- another arbitrary number. Only the low order 2 bits will be
used.public void write_string(String s)
s
- the string to write.public void write_any(ConfEObject o)
o
- the E term to write.