Package com.ericsson.otp.erlang
Class OtpErlangRef
- java.lang.Object
- 
- com.ericsson.otp.erlang.OtpErlangObject
- 
- com.ericsson.otp.erlang.OtpErlangRef
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable
 
 public class OtpErlangRef extends OtpErlangObject Provides a Java representation of Erlang refs. There are two styles of Erlang refs, old style (one id value) and new style (array of id values). This class manages both types.- See Also:
- Serialized Form
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class com.ericsson.otp.erlang.OtpErlangObjectOtpErlangObject.Hash
 
- 
 - 
Field Summary- 
Fields inherited from class com.ericsson.otp.erlang.OtpErlangObjecthashCodeValue
 
- 
 - 
Constructor SummaryConstructors Constructor Description OtpErlangRef(int tag, java.lang.String node, int[] ids, int creation)Create a new(er) style Erlang ref from its components.OtpErlangRef(OtpInputStream buf)Create an Erlang ref from a stream containing a ref encoded in Erlang external format.OtpErlangRef(OtpLocalNode self)Deprecated.use OtpLocalNode:createRef() insteadOtpErlangRef(java.lang.String node, int[] ids, int creation)Create a new style Erlang ref from its components.OtpErlangRef(java.lang.String node, int id, int creation)Create an old style Erlang ref from its components.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()intcreation()Get the creation number from the ref.protected intdoHashCode()Compute the hashCode value for a given ref.voidencode(OtpOutputStream buf)Convert this ref to the equivalent Erlang external representation.booleanequals(java.lang.Object o)Determine if two refs are equal.intid()Get the id number from the ref.int[]ids()Get the array of id numbers from the ref.booleanisNewRef()Determine whether this is a new style ref.java.lang.Stringnode()Get the node name from the ref.protected inttag()java.lang.StringtoString()Get the string representation of the ref.- 
Methods inherited from class com.ericsson.otp.erlang.OtpErlangObjectbind, decode, hashCode, match
 
- 
 
- 
- 
- 
Constructor Detail- 
OtpErlangRef@Deprecated public OtpErlangRef(OtpLocalNode self) Deprecated.use OtpLocalNode:createRef() insteadCreate a unique Erlang ref belonging to the local node.- Parameters:
- self- the local node.
 
 - 
OtpErlangRefpublic OtpErlangRef(OtpInputStream buf) throws OtpErlangDecodeException Create an Erlang ref from a stream containing a ref encoded in Erlang external format.- Parameters:
- buf- the stream containing the encoded ref.
- Throws:
- OtpErlangDecodeException- if the buffer does not contain a valid external representation of an Erlang ref.
 
 - 
OtpErlangRefpublic OtpErlangRef(java.lang.String node, int id, int creation)Create an old style Erlang ref from its components.- Parameters:
- node- the nodename.
- id- an arbitrary number. Only the low order 18 bits will be used.
- creation- another arbitrary number.
 
 - 
OtpErlangRefpublic OtpErlangRef(java.lang.String node, int[] ids, int creation)Create a new style Erlang ref from its components.- Parameters:
- node- the nodename.
- ids- an array of arbitrary numbers. Only the low order 18 bits of the first number will be used. If the array contains only one number, an old style ref will be written instead. At most three numbers will be read from the array.
- creation- node incarnation number. Avoid values 0 to 3.
 
 - 
OtpErlangRefpublic OtpErlangRef(int tag, java.lang.String node, int[] ids, int creation)Create a new(er) style Erlang ref from its components.- Parameters:
- tag- the external format to be compliant with. OtpExternal.newRefTag where only a subset of the bits are used (see other constructor) OtpExternal.newerRefTag where all bits of ids and creation are used. newerPortTag can only be decoded by OTP-19 and newer.
- node- the nodename.
- ids- an array of arbitrary numbers. At most three numbers will be read from the array.
- creation- another arbitrary number.
 
 
- 
 - 
Method Detail- 
tagprotected int tag() 
 - 
idpublic int id() Get the id number from the ref. Old style refs have only one id number. If this is a new style ref, the first id number is returned.- Returns:
- the id number from the ref.
 
 - 
idspublic int[] ids() Get the array of id numbers from the ref. If this is an old style ref, the array is of length 1. If this is a new style ref, the array has length 3-5.- Returns:
- the array of id numbers from the ref.
 
 - 
isNewRefpublic boolean isNewRef() Determine whether this is a new style ref.- Returns:
- true if this ref is a new style ref, false otherwise.
 
 - 
creationpublic int creation() Get the creation number from the ref.- Returns:
- the creation number from the ref.
 
 - 
nodepublic java.lang.String node() Get the node name from the ref.- Returns:
- the node name from the ref.
 
 - 
toStringpublic java.lang.String toString() Get the string representation of the ref. Erlang refs are printed as #Ref<node.id>- Specified by:
- toStringin class- OtpErlangObject
- Returns:
- the string representation of the ref.
 
 - 
encodepublic void encode(OtpOutputStream buf) Convert this ref to the equivalent Erlang external representation.- Specified by:
- encodein class- OtpErlangObject
- Parameters:
- buf- an output stream to which the encoded ref should be written.
 
 - 
equalspublic boolean equals(java.lang.Object o) Determine if two refs are equal. Refs are equal if their components are equal. New refs and old refs are considered equal if the node, creation and first id number are equal.- Specified by:
- equalsin class- OtpErlangObject
- Parameters:
- o- the other ref to compare to.
- Returns:
- true if the refs are equal, false otherwise.
 
 - 
doHashCodeprotected int doHashCode() Compute the hashCode value for a given ref. This function is compatible with equal.- Overrides:
- doHashCodein class- OtpErlangObject
- Returns:
- the hashCode of the node.
 
 - 
clonepublic java.lang.Object clone() - Overrides:
- clonein class- OtpErlangObject
 
 
- 
 
-