com.ericsson.otp.erlang
Class OtpErlangBinary

java.lang.Object
  |
  +--com.ericsson.otp.erlang.OtpErlangObject
        |
        +--com.ericsson.otp.erlang.OtpErlangBitstr
              |
              +--com.ericsson.otp.erlang.OtpErlangBinary
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class OtpErlangBinary
extends OtpErlangBitstr
implements java.io.Serializable, java.lang.Cloneable

Provides a Java representation of Erlang binaries. Anything that can be represented as a sequence of bytes can be made into an Erlang binary.

See Also:
Serialized Form

Fields inherited from class com.ericsson.otp.erlang.OtpErlangBitstr
bin, pad_bits
 
Constructor Summary
OtpErlangBinary(byte[] bin)
          Create a binary from a byte array
OtpErlangBinary(java.lang.Object o)
          Create a binary from an arbitrary Java Object.
OtpErlangBinary(OtpInputStream buf)
          Create a binary from a stream containing a binary encoded in Erlang external format.
 
Method Summary
 java.lang.Object clone()
           
 void encode(OtpOutputStream buf)
          Convert this binary to the equivalent Erlang external representation.
 boolean equals(java.lang.Object o)
          Determine if two binaries are equal.
 
Methods inherited from class com.ericsson.otp.erlang.OtpErlangBitstr
binaryValue, getObject, pad_bits, size, toString
 
Methods inherited from class com.ericsson.otp.erlang.OtpErlangObject
decode
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OtpErlangBinary

public OtpErlangBinary(byte[] bin)
Create a binary from a byte array
Parameters:
bin - the array of bytes from which to create the binary.

OtpErlangBinary

public OtpErlangBinary(OtpInputStream buf)
                throws OtpErlangDecodeException
Create a binary from a stream containing a binary encoded in Erlang external format.
Parameters:
buf - the stream containing the encoded binary.
Throws:
OtpErlangDecodeException - if the buffer does not contain a valid external representation of an Erlang binary.

OtpErlangBinary

public OtpErlangBinary(java.lang.Object o)
Create a binary from an arbitrary Java Object. The object must implement java.io.Serializable or java.io.Externalizable.
Parameters:
o - the object to serialize and create this binary from.
Method Detail

encode

public void encode(OtpOutputStream buf)
Convert this binary to the equivalent Erlang external representation.
Overrides:
encode in class OtpErlangBitstr
Parameters:
buf - an output stream to which the encoded binary should be written.

equals

public boolean equals(java.lang.Object o)
Determine if two binaries are equal. Binaries are equal if they have the same length and the array of bytes is identical.
Overrides:
equals in class OtpErlangBitstr
Parameters:
o - the binary to compare to.
Returns:
true if the byte arrays contain the same bytes, false otherwise.

clone

public java.lang.Object clone()
Overrides:
clone in class OtpErlangBitstr