Ejemplo n.º 1
0
        /*
         * 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();
                }
            }
        }
Ejemplo n.º 2
0
        /*
         * 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();
            }
        }
Ejemplo n.º 3
0
 /*
 * 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();
 }
Ejemplo n.º 4
0
        /*
        * 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();
			}
		}
Ejemplo n.º 5
0
 /*
  * 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());
 }
Ejemplo n.º 6
0
        /*
        * 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();
                }
            }
        }