/** * Create a list from a stream containing an list encoded in Erlang external * format. * * @param buf * the stream containing the encoded list. * * @exception OtpErlangDecodeException * if the buffer does not contain a valid external * representation of an Erlang list. */ public OtpErlangList(OtpInputStream buf) { int arity = buf.read_list_head(); if (arity > 0) { elems = new OtpErlangObject[arity]; for (int i = 0; i < arity; i++) { elems[i] = buf.read_any(); } /* discard the terminating nil (empty list) or read tail */ if (buf.peek1() == OtpExternal.nilTag) { buf.read_nil(); } else { lastTail = buf.read_any(); } } else { elems = NO_ELEMENTS; } }