com.ericsson.otp.erlang
Class OtpErlangPid

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

public class OtpErlangPid
extends OtpErlangObject
implements java.io.Serializable, java.lang.Cloneable

Provides a Java representation of Erlang PIDs. PIDs represent Erlang processes and consist of a nodename and a number of integers.

See Also:
Serialized Form

Constructor Summary
OtpErlangPid(OtpInputStream buf)
          Create an Erlang PID from a stream containing a PID encoded in Erlang external format.
OtpErlangPid(OtpLocalNode self)
          Deprecated. use OtpLocalNode:createPid() instead
OtpErlangPid(java.lang.String node, int id, int serial, int creation)
          Create an Erlang pid from its components.
 
Method Summary
 int creation()
          Get the creation number from the PID.
 void encode(OtpOutputStream buf)
          Convert this PID to the equivalent Erlang external representation.
 boolean equals(java.lang.Object o)
          Determine if two PIDs are equal.
 int hashCode()
          Return the hashCode for this Pid.
 int id()
          Get the id number from the PID.
 java.lang.String node()
          Get the node name from the PID.
 int serial()
          Get the serial number from the PID.
 java.lang.String toString()
          Get the string representation of the PID.
 
Methods inherited from class com.ericsson.otp.erlang.OtpErlangObject
clone, decode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OtpErlangPid

public OtpErlangPid(OtpLocalNode self)
Deprecated. use OtpLocalNode:createPid() instead

Create a unique Erlang PID belonging to the local node.
Parameters:
self - the local node.

OtpErlangPid

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

OtpErlangPid

public OtpErlangPid(java.lang.String node,
                    int id,
                    int serial,
                    int creation)
Create an Erlang pid from its components.
Parameters:
node - the nodename.
id - an arbitrary number. Only the low order 15 bits will be used.
serial - another arbitrary number. Only the low order 3 bits will be used.
creation - yet another arbitrary number. Only the low order 2 bits will be used.
Method Detail

serial

public int serial()
Get the serial number from the PID.
Returns:
the serial number from the PID.

id

public int id()
Get the id number from the PID.
Returns:
the id number from the PID.

creation

public int creation()
Get the creation number from the PID.
Returns:
the creation number from the PID.

node

public java.lang.String node()
Get the node name from the PID.
Returns:
the node name from the PID.

toString

public java.lang.String toString()
Get the string representation of the PID. Erlang PIDs are printed as #Pid<node.id.serial>
Overrides:
toString in class OtpErlangObject
Returns:
the string representation of the PID.

encode

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

hashCode

public int hashCode()
Return the hashCode for this Pid.
Overrides:
hashCode in class java.lang.Object
Returns:
the hashCode for this Pid.

equals

public boolean equals(java.lang.Object o)
Determine if two PIDs are equal. PIDs are equal if their components are equal.
Overrides:
equals in class OtpErlangObject
Parameters:
port - the other PID to compare to.
Returns:
true if the PIDs are equal, false otherwise.