/* * Create a tuple from a stream containing an tuple encoded in Erlang * external format. * * @param buf the stream containing the encoded tuple. * * @exception DecodeException if the buffer does not * contain a valid external representation of an Erlang tuple. **/ public Tuple(OtpInputStream buf) { int arity = buf.read_tuple_head(); if (arity > 0) { this.elems = new Object[arity]; for (int i = 0; i < arity; i++) { elems[i] = buf.read_any(); } } }
/* * Create a list from a stream containing an list encoded in Erlang * external format. * * @param buf the stream containing the encoded list. * * @exception DecodeException if the buffer does not * contain a valid external representation of an Erlang list. **/ public List(OtpInputStream buf) { this.elems = null; int arity = buf.read_list_head(); if (arity > 0) { this.elems = new Object[arity]; for (int i = 0; i < arity; i++) { elems[i] = buf.read_any(); } /*discard the terminating nil (empty list) */ buf.read_nil(); } }
/* * Read binary data in the Erlang external format, and produce a * corresponding Erlang data type object. This method is normally * used when Erlang terms are received in messages, however it * can also be used for reading terms from disk. * * @param buf an input stream containing one or more encoded Erlang * terms. * * @return an object representing one of the Erlang data * types. * * @exception DecodeException if the stream does not * contain a valid representation of an Erlang term. **/ public static Object decode(OtpInputStream buf) { return buf.read_any(); }
/* * Read binary data in the Erlang external format, and produce a * corresponding Erlang data type object. This method is normally * used when Erlang terms are received in messages, however it * can also be used for reading terms from disk. * * @param buf an input stream containing one or more encoded Erlang * terms. * * @return an object representing one of the Erlang data * types. * * @exception DecodeException if the stream does not * contain a valid representation of an Erlang term. **/ public static Object decode(OtpInputStream buf) { return(buf.read_any()); }