|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ericsson.otp.erlang.OtpOutputStream
Provides a stream for encoding Erlang terms to external format, for transmission or storage.
Note that this class is not synchronized, if you need synchronization you must provide it yourself.
Field Summary | |
static int |
defaultIncrement
The default increment used when growing the stream. |
static int |
defaultInitialSize
The default initial size of the stream. |
Constructor Summary | |
OtpOutputStream()
Create a stream with the default initial size. |
|
OtpOutputStream(int size)
Create a stream with the specified initial size. |
|
OtpOutputStream(OtpErlangObject o)
Create a stream containing the encoded version of the given Erlang term. |
Method Summary | |
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(OtpErlangObject o)
Write an arbitrary Erlang term to the stream. |
void |
write_atom(java.lang.String atom)
Write a string to the stream as an Erlang atom. |
void |
write_binary(byte[] bin)
Write an array of bytes to the stream as an Erlang binary. |
void |
write_boolean(boolean b)
Write a boolean value to the stream as the Erlang atom 'true' or 'false'. |
void |
write_byte(byte b)
Write a single byte to the stream as an Erlang integer. |
void |
write_char(char c)
Write a character to the stream as an Erlang 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 Erlang list header to the stream. |
void |
write_long(long l)
Write a long to the stream. |
void |
write_nil()
Write an empty Erlang list to the stream. |
void |
write_pid(java.lang.String node,
int id,
int serial,
int creation)
Write an Erlang PID to the stream. |
void |
write_port(java.lang.String node,
int id,
int creation)
Write an Erlang port to the stream. |
void |
write_ref(java.lang.String node,
int[] ids,
int creation)
Write a new style (R6 and later) Erlang ref to the stream. |
void |
write_ref(java.lang.String node,
int id,
int creation)
Write an old style Erlang ref to the stream. |
void |
write_short(short s)
Write a short to the stream. |
void |
write_string(java.lang.String s)
Write a string to the stream. |
void |
write_tuple_head(int arity)
Write an Erlang 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 |
writeN(byte[] bytes)
Write an array of bytes to the stream. |
void |
writeTo(java.io.OutputStream os)
Write the contents of the stream to an OutputStream. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int defaultInitialSize
public static final int defaultIncrement
Constructor Detail |
public OtpOutputStream()
public OtpOutputStream(int size)
public OtpOutputStream(OtpErlangObject o)
Method Detail |
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(java.io.OutputStream os) throws java.io.IOException
os
- the OutputStream to write to.public void write1(long n)
n
- the value to use.public void writeN(byte[] bytes)
buf
- 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 write2LE(long n)
n
- the value to use.public void write4LE(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(java.lang.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)
s
- 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(java.lang.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 3 bits
will be used.creation
- yet another arbitrary number. Only the low order
2 bits will be used.public void write_port(java.lang.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(java.lang.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(java.lang.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(java.lang.String s)
s
- the string to write.public void write_any(OtpErlangObject o)
o
- the Erlang term to write.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |