com.ericsson.otp.erlang
Class OtpErlangPort

java.lang.Object
  extended by com.ericsson.otp.erlang.OtpErlangObject
      extended by com.ericsson.otp.erlang.OtpErlangPort
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class OtpErlangPort
extends OtpErlangObject

Provides a Java representation of Erlang ports.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.ericsson.otp.erlang.OtpErlangObject
OtpErlangObject.Hash
 
Field Summary
 
Fields inherited from class com.ericsson.otp.erlang.OtpErlangObject
hashCodeValue
 
Constructor Summary
OtpErlangPort(OtpInputStream buf)
          Create an Erlang port from a stream containing a port encoded in Erlang external format.
OtpErlangPort(java.lang.String node, int id, int creation)
          Create an Erlang port from its components.
 
Method Summary
 int creation()
          Get the creation number from the port.
protected  int doHashCode()
           
 void encode(OtpOutputStream buf)
          Convert this port to the equivalent Erlang external representation.
 boolean equals(java.lang.Object o)
          Determine if two ports are equal.
 int id()
          Get the id number from the port.
 java.lang.String node()
          Get the node name from the port.
 java.lang.String toString()
          Get the string representation of the port.
 
Methods inherited from class com.ericsson.otp.erlang.OtpErlangObject
clone, decode, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OtpErlangPort

public OtpErlangPort(OtpInputStream buf)
              throws OtpErlangDecodeException
Create an Erlang port from a stream containing a port encoded in Erlang external format.

Parameters:
buf - the stream containing the encoded port.
Throws:
OtpErlangDecodeException - if the buffer does not contain a valid external representation of an Erlang port.

OtpErlangPort

public OtpErlangPort(java.lang.String node,
                     int id,
                     int creation)
Create an Erlang port from its components.

Parameters:
node - the nodename.
id - an arbitrary number. Only the low order 28 bits will be used.
creation - another arbitrary number. Only the low order 2 bits will be used.
Method Detail

id

public int id()
Get the id number from the port.

Returns:
the id number from the port.

creation

public int creation()
Get the creation number from the port.

Returns:
the creation number from the port.

node

public java.lang.String node()
Get the node name from the port.

Returns:
the node name from the port.

toString

public java.lang.String toString()
Get the string representation of the port. Erlang ports are printed as #Port<node.id>.

Specified by:
toString in class OtpErlangObject
Returns:
the string representation of the port.

encode

public void encode(OtpOutputStream buf)
Convert this port to the equivalent Erlang external representation.

Specified by:
encode in class OtpErlangObject
Parameters:
buf - an output stream to which the encoded port should be written.

equals

public boolean equals(java.lang.Object o)
Determine if two ports are equal. Ports are equal if their components are equal.

Specified by:
equals in class OtpErlangObject
Parameters:
o - the other port to compare to.
Returns:
true if the ports are equal, false otherwise.

doHashCode

protected int doHashCode()
Overrides:
doHashCode in class OtpErlangObject