sds.data
Class Reference

java.lang.Object
  extended by sds.data.Reference
All Implemented Interfaces:
java.io.Serializable

public final class Reference
extends java.lang.Object
implements java.io.Serializable

Mean for identifying distributed objects and providing messages delivery contact information

Author:
ncottin
See Also:
Serialized Form

Field Summary
static long DEFAULT_VALUE
           
static int NO_PORT
           
 
Constructor Summary
Reference()
           Creates an uninitialized reference
Reference(Reference other)
           Creates and initializes this reference with another reference
 
Method Summary
 boolean equals(java.lang.Object other)
           
 boolean fromString(java.lang.String value)
           Initializes from a string representation
 java.lang.String getAddress()
           
 long getId()
           Gets this reference's identifier
 long getNonce()
           
 int getPort()
           The port assigned to the referenced distributed object.
 int hashCode()
           
 boolean isInvokable()
           Checks whether this reference points to a client-oriented or a server-oriented distributed object
 void setAddress(java.lang.String address)
           Initializes the IP address with a given address
 void setId(long id)
           Assigns an identifier to this reference
 void setNonce(long nonce)
           
 void setPort(int port)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_VALUE

public static final long DEFAULT_VALUE
See Also:
Constant Field Values

NO_PORT

public static final int NO_PORT
See Also:
Constant Field Values
Constructor Detail

Reference

public Reference()

Creates an uninitialized reference


Reference

public Reference(Reference other)

Creates and initializes this reference with another reference

Parameters:
other - A null reference leaves this reference uninitialized. This reference duplicates the given reference otherwise
Method Detail

fromString

public boolean fromString(java.lang.String value)

Initializes from a string representation

Parameters:
value -
Returns:
True only if successfully decoded from string. False implies that the current reference values are left unchanged

getId

public long getId()

Gets this reference's identifier

Returns:
Any value

setId

public void setId(long id)

Assigns an identifier to this reference

Parameters:
id - A positive id

getNonce

public long getNonce()
Returns:
The nonce randomly assigned to this reference

setNonce

public void setNonce(long nonce)
Parameters:
nonce - Any random value

getAddress

public java.lang.String getAddress()
Returns:
the address

setAddress

public void setAddress(java.lang.String address)

Initializes the IP address with a given address

Parameters:
address - The host IP address. Should neither be null nor empty to initialize this reference with

getPort

public int getPort()

The port assigned to the referenced distributed object. This port is valid only when referencing a running server-oriented object

Returns:
A strictly positive port refers to a running server-oriented distributed object. A negative value (such as NO_PORT) indicates either a client-oriented or a non-running server-oriented distributed object

setPort

public void setPort(int port)
Parameters:
port - The port number. Must be strictly positive to be valid

isInvokable

public boolean isInvokable()

Checks whether this reference points to a client-oriented or a server-oriented distributed object

Returns:
True only of this reference belongs to a server-oriented distributed object (i.e. contains a non-null and non-empty IP address and a valid port number)

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object