com.ericsson.otp.erlang
Class OtpErlangBinary

java.lang.Object
  |
  +--com.ericsson.otp.erlang.OtpErlangObject
        |
        +--com.ericsson.otp.erlang.OtpErlangBinary

public class OtpErlangBinary
extends OtpErlangObject

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


Constructor Summary
OtpErlangBinary(byte[] bin)
          Create a binary from a byte array
OtpErlangBinary(OtpInputStream buf)
          Create a binary from a stream containinf a binary encoded in Erlang external format.
 
Method Summary
 byte[] binaryValue()
          Get the byte array from a binary.
 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.
 boolean equals(OtpErlangBinary bin)
          Determine if two binaries are equal.
 int size()
          Get the size of the binary.
 java.lang.String toString()
          Get the string representation of this binary object.
 
Methods inherited from class com.ericsson.otp.erlang.OtpErlangObject
decode
 
Methods inherited from class java.lang.Object
clone, 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 containinf 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.
Method Detail

binaryValue

public byte[] binaryValue()
Get the byte array from a binary.
Returns:
the byte array containing the bytes for this binary.

size

public int size()
Get the size of the binary.
Returns:
the number of bytes contained in the binary.

toString

public java.lang.String toString()
Get the string representation of this binary object. A binary is printed as #Bin<N>, where N is the number of bytes contained in the object.
Overrides:
toString in class OtpErlangObject
Returns:
the Erlang string representation of this binary.

encode

public void encode(OtpOutputStream buf)
Convert this binary to the equivalent Erlang external representation.
Overrides:
encode in class OtpErlangObject
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 OtpErlangObject
Parameters:
o - the object to compare to.
Returns:
true if o is a binary and the byte arrays contain the same bytes, false otherwise.

equals

public boolean equals(OtpErlangBinary bin)
Determine if two binaries are equal. Binaries are equal if they have the same length and the array of bytes is identical.
Parameters:
t - the binary to compare to.
Returns:
true if the byte arrays contain the same bytes, false otherwise.