|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream java.io.ByteArrayOutputStream com.ericsson.otp.erlang.OtpOutputStream
public class 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 (increment at least this much). |
static int |
defaultInitialSize
The default initial size of the stream. |
Fields inherited from class java.io.ByteArrayOutputStream |
---|
buf, count |
Constructor Summary | |
---|---|
OtpOutputStream()
Create a stream with the default initial size (2048 bytes). |
|
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()
Deprecated. As of Jinterface 1.4, replaced by super.size(). |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this OtpOutputStream instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument. |
int |
getPos()
Get the current position in the stream. |
int |
length()
Get the current capacity of 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 |
trimToSize()
Trims the capacity of this OtpOutputStream instance to be the buffer's current size. |
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_big_integer(java.math.BigInteger v)
|
void |
write_binary(byte[] bin)
Write an array of bytes to the stream as an Erlang binary. |
void |
write_bitstr(byte[] bin,
int pad_bits)
Write an array of bytes to the stream as an Erlang bitstr. |
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_compressed(OtpErlangObject o)
Write an arbitrary Erlang term to the stream in compressed format. |
void |
write_compressed(OtpErlangObject o,
int level)
Write an arbitrary Erlang term to the stream in compressed format. |
void |
write_double(double d)
Write a double value to the stream. |
void |
write_external_fun(java.lang.String module,
java.lang.String function,
int arity)
|
void |
write_float(float f)
Write a float value to the stream. |
void |
write_fun(OtpErlangPid pid,
java.lang.String module,
long old_index,
int arity,
byte[] md5,
long index,
long uniq,
OtpErlangObject[] freeVars)
|
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_map_head(int arity)
|
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[] abuf)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
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 |
write8BE(long n)
Write the low eight (all) bytes of a value to the stream in big 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. |
Methods inherited from class java.io.ByteArrayOutputStream |
---|
close, reset, size, toByteArray, toString, toString, toString, writeTo |
Methods inherited from class java.io.OutputStream |
---|
flush |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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 int getPos()
public void trimToSize()
public void ensureCapacity(int minCapacity)
minCapacity
- the desired minimum capacitypublic void write(byte b)
b
- the byte to write.public void write(byte[] abuf)
write
in class java.io.OutputStream
public void write(int b)
write
in class java.io.ByteArrayOutputStream
public void write(byte[] b, int off, int len)
write
in class java.io.ByteArrayOutputStream
public void write1(long n)
n
- the value to use.public void writeN(byte[] bytes)
bytes
- the array of bytes to write.public int length()
@Deprecated public int count()
ByteArrayOutputStream.size()
public void write2BE(long n)
n
- the value to use.public void write4BE(long n)
n
- the value to use.public void write8BE(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)
size()
, 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.size(); 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_bitstr(byte[] bin, int pad_bits)
bin
- the array of bytes to write.pad_bits
- the number of zero pad bits at the low end of the last bytepublic 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_big_integer(java.math.BigInteger v)
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(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 13 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 28 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_compressed(OtpErlangObject o)
o
- the Erlang term to write.public void write_compressed(OtpErlangObject o, int level)
o
- the Erlang term to write.level
- the compression level (0..9)public void write_any(OtpErlangObject o)
o
- the Erlang term to write.public void write_fun(OtpErlangPid pid, java.lang.String module, long old_index, int arity, byte[] md5, long index, long uniq, OtpErlangObject[] freeVars)
public void write_external_fun(java.lang.String module, java.lang.String function, int arity)
public void write_map_head(int arity)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |