Package com.ericsson.otp.erlang
Class OtpErlangBitstr
- java.lang.Object
- 
- com.ericsson.otp.erlang.OtpErlangObject
- 
- com.ericsson.otp.erlang.OtpErlangBitstr
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable
 - Direct Known Subclasses:
- OtpErlangBinary
 
 public class OtpErlangBitstr extends OtpErlangObject Provides a Java representation of Erlang bitstrs. An Erlang bitstr is an Erlang binary with a length not an integral number of bytes (8-bit). Anything can be represented as a sequence of bytes can be made into an Erlang bitstr.- See Also:
- Serialized Form
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class com.ericsson.otp.erlang.OtpErlangObjectOtpErlangObject.Hash
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected byte[]binprotected intpad_bits- 
Fields inherited from class com.ericsson.otp.erlang.OtpErlangObjecthashCodeValue
 
- 
 - 
Constructor SummaryConstructors Constructor Description OtpErlangBitstr(byte[] bin)Create a bitstr from a byte arrayOtpErlangBitstr(byte[] bin, int pad_bits)Create a bitstr with pad bits from a byte array.OtpErlangBitstr(OtpInputStream buf)Create a bitstr from a stream containing a bitstr encoded in Erlang external format.OtpErlangBitstr(java.lang.Object o)Create a bitstr from an arbitrary Java Object.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]binaryValue()Get the byte array from a bitstr, padded with zero bits in the little end of the last byte.java.lang.Objectclone()protected intdoHashCode()voidencode(OtpOutputStream buf)Convert this bitstr to the equivalent Erlang external representation.booleanequals(java.lang.Object o)Determine if two bitstrs are equal.java.lang.ObjectgetObject()Get the java Object from the bitstr.intpad_bits()Get the number of pad bits in the last byte of the bitstr.intsize()Get the size in whole bytes of the bitstr, rest bits in the last byte not counted.java.lang.StringtoString()Get the string representation of this bitstr object.- 
Methods inherited from class com.ericsson.otp.erlang.OtpErlangObjectbind, decode, hashCode, match
 
- 
 
- 
- 
- 
Constructor Detail- 
OtpErlangBitstrpublic OtpErlangBitstr(byte[] bin) Create a bitstr from a byte array- Parameters:
- bin- the array of bytes from which to create the bitstr.
 
 - 
OtpErlangBitstrpublic OtpErlangBitstr(byte[] bin, int pad_bits)Create a bitstr with pad bits from a byte array.- Parameters:
- bin- the array of bytes from which to create the bitstr.
- pad_bits- the number of unused bits in the low end of the last byte.
 
 - 
OtpErlangBitstrpublic OtpErlangBitstr(OtpInputStream buf) throws OtpErlangDecodeException Create a bitstr from a stream containing a bitstr encoded in Erlang external format.- Parameters:
- buf- the stream containing the encoded bitstr.
- Throws:
- OtpErlangDecodeException- if the buffer does not contain a valid external representation of an Erlang bitstr.
 
 - 
OtpErlangBitstrpublic OtpErlangBitstr(java.lang.Object o) Create a bitstr 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 bitstr from.
 
 
- 
 - 
Method Detail- 
binaryValuepublic byte[] binaryValue() Get the byte array from a bitstr, padded with zero bits in the little end of the last byte.- Returns:
- the byte array containing the bytes for this bitstr.
 
 - 
sizepublic int size() Get the size in whole bytes of the bitstr, rest bits in the last byte not counted.- Returns:
- the number of bytes contained in the bintstr.
 
 - 
pad_bitspublic int pad_bits() Get the number of pad bits in the last byte of the bitstr. The pad bits are zero and in the little end.- Returns:
- the number of pad bits in the bitstr.
 
 - 
getObjectpublic java.lang.Object getObject() Get the java Object from the bitstr. If the bitstr contains a serialized Java object, then this method will recreate the object.- Returns:
- the java Object represented by this bitstr, or null if the bitstr does not represent a Java Object.
 
 - 
toStringpublic java.lang.String toString() Get the string representation of this bitstr object. A bitstr is printed as #Bin<N>, where N is the number of bytes contained in the object or #bin<N-M> if there are M pad bits.- Specified by:
- toStringin class- OtpErlangObject
- Returns:
- the Erlang string representation of this bitstr.
 
 - 
encodepublic void encode(OtpOutputStream buf) Convert this bitstr to the equivalent Erlang external representation.- Specified by:
- encodein class- OtpErlangObject
- Parameters:
- buf- an output stream to which the encoded bitstr should be written.
 
 - 
equalspublic boolean equals(java.lang.Object o) Determine if two bitstrs are equal. Bitstrs are equal if they have the same byte length and tail length, and the array of bytes is identical.- Specified by:
- equalsin class- OtpErlangObject
- Parameters:
- o- the bitstr to compare to.
- Returns:
- true if the bitstrs contain the same bits, false otherwise.
 
 - 
doHashCodeprotected int doHashCode() - Overrides:
- doHashCodein class- OtpErlangObject
 
 - 
clonepublic java.lang.Object clone() - Overrides:
- clonein class- OtpErlangObject
 
 
- 
 
-