planet.generic.commonapi
Class NodeHandleImpl

java.lang.Object
  extended by java.util.Observable
      extended by planet.commonapi.NodeHandle
          extended by planet.generic.commonapi.NodeHandleImpl
All Implemented Interfaces:
java.io.Serializable

public class NodeHandleImpl
extends NodeHandle

NodeHandle for node. Being so simple his API, surely will be able to be reused for different nodes. It only mantain the Node Id and a flag that informs if the related Node is alive.

Author:
Jordi Pujol Date: 13/05/2004
See Also:
Serialized Form

Field Summary
 
Fields inherited from class planet.commonapi.NodeHandle
DECLARED_DEAD, DECLARED_LIVE, PROXIMITY_CHANGED
 
Constructor Summary
NodeHandleImpl(Id nodeId, boolean alive)
          Builds a new NodeHandle for a Node, only identify its Id and sets its alive flag.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Overwrites this method to reflect the comparison between the related Id's.
 Id getId()
          Gets the Id of the related node
 int getProximity()
          Always returns one as proximity between any two nodes.
 int hashCode()
          Overwrites this method to reflect the hash code of the related Id.
 boolean isAlive()
          Inform if the related node is alive.
 void setAlive(boolean alive)
          Updates the alive flag.
 java.lang.String toString()
          Returns the String representation of this NodeHandle
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeHandleImpl

public NodeHandleImpl(Id nodeId,
                      boolean alive)
Builds a new NodeHandle for a Node, only identify its Id and sets its alive flag.

Parameters:
nodeId - Id of the related Node
alive - true if the related Node is alive. false in other case.
Method Detail

getId

public Id getId()
Gets the Id of the related node

Specified by:
getId in class NodeHandle
Returns:
Id of the node
See Also:
NodeHandle.getId()

isAlive

public boolean isAlive()
Inform if the related node is alive.

Specified by:
isAlive in class NodeHandle
Returns:
true if the related node is alive. false in other case.
See Also:
NodeHandle.isAlive()

setAlive

public void setAlive(boolean alive)
Updates the alive flag.

Specified by:
setAlive in class NodeHandle
Parameters:
alive - New value for the alive flag.
See Also:
NodeHandle.setAlive(boolean)

toString

public java.lang.String toString()
Returns the String representation of this NodeHandle

Overrides:
toString in class java.lang.Object
Returns:
String representation with the nodeId and alive flag.
See Also:
Object.toString()

getProximity

public int getProximity()
Always returns one as proximity between any two nodes.

Specified by:
getProximity in class NodeHandle
Returns:
Always one
See Also:
NodeHandle.getProximity()

equals

public boolean equals(java.lang.Object obj)
Overwrites this method to reflect the comparison between the related Id's. That is:
return getId().equals(((NodeHandle)obj).getId());

Overrides:
equals in class java.lang.Object
Parameters:
obj - NodeHandle to be compared.
Returns:
true if and only if the related Id's are equals. false in other case.
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overwrites this method to reflect the hash code of the related Id. That is:
return getId().hashCode();

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code of the related Id.
See Also:
Object.hashCode()