sg.edu.nus.peer.info
Class PeerInfo

java.lang.Object
  extended by sg.edu.nus.peer.info.PeerInfo
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class PeerInfo
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This class is defined the format of the feedback information to the peers who is registering or signing in the system. According to such feedback information, then the peers can select a proper super peer to join the system.

Version:
1.0 2006-1-14
Author:
Xu Linhao
See Also:
Serialized Form

Constructor Summary
PeerInfo(java.lang.String peerID, java.lang.String ip, int port, java.lang.String type)
          Wrap a peer's information that will be used by other peers to access this peer.
 
Method Summary
 java.lang.Object clone()
          Clone self.
 boolean equals(PeerInfo p)
          Determine if two instances of the PeerInfo are equal.
 boolean equalsIgnoreType(PeerInfo p)
          Determine if two instances of PeerInfo are equal without considering both type and identifier.
 java.lang.String getInetAddress()
          Get the IP address.
 java.lang.String getKey()
          Returns a 160-bits key by using SHA hash function.
 java.lang.String getPeerID()
          Get the peer identifier.
 java.lang.String getPeerType()
          Get the peer type.
 int getPort()
          Get the port used for monitoring network events.
 void setInetAddress(java.lang.String ip)
          Set the IP address.
 void setPeerID(java.lang.String id)
          Set the peer identifier.
 void setPeerType(java.lang.String type)
          Set the peer type.
 void setPort(int port)
          Set the port.
 java.lang.Object[] toObjectArray()
          Get an array of all members.
 java.lang.Object[] toObjectArrayWithoutType()
          Get an array of all members without type.
 java.lang.String toString()
          Override toString() function of java.lang.Object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PeerInfo

public PeerInfo(java.lang.String peerID,
                java.lang.String ip,
                int port,
                java.lang.String type)
Wrap a peer's information that will be used by other peers to access this peer.

Parameters:
peerID - the identifier of the peer
ip - the IP address of the peer
port - the port used for monitoring network events
type - the peer type
Method Detail

clone

public java.lang.Object clone()
Clone self.

Overrides:
clone in class java.lang.Object
Returns:
The instance of PeerInfo.

getKey

public java.lang.String getKey()
Returns a 160-bits key by using SHA hash function.

Returns:
a 160-bits key by using SHA hash function

getPeerID

public java.lang.String getPeerID()
Get the peer identifier.

Returns:
the peer identifier

setPeerID

public void setPeerID(java.lang.String id)
Set the peer identifier.

Parameters:
id - the peer identifier

getInetAddress

public java.lang.String getInetAddress()
Get the IP address.

Returns:
the IP address

setInetAddress

public void setInetAddress(java.lang.String ip)
Set the IP address.

Parameters:
ip - the IP address

getPort

public int getPort()
Get the port used for monitoring network events.

Returns:
the port used for monitoring network events

setPort

public void setPort(int port)
Set the port.

Parameters:
port - the port

getPeerType

public java.lang.String getPeerType()
Get the peer type.

Returns:
the peer type

setPeerType

public void setPeerType(java.lang.String type)
Set the peer type.

Parameters:
type - the peer type

equals

public boolean equals(PeerInfo p)
Determine if two instances of the PeerInfo are equal.

Parameters:
p - the instance of the PeerInfo to be compared
Returns:
if equal, return true; otherwise, return false

equalsIgnoreType

public boolean equalsIgnoreType(PeerInfo p)
Determine if two instances of PeerInfo are equal without considering both type and identifier.

Parameters:
p - the instance of the PeerInfo to be compared
Returns:
if equal, return true

toObjectArray

public java.lang.Object[] toObjectArray()
Get an array of all members.

Returns:
an array of all members

toObjectArrayWithoutType

public java.lang.Object[] toObjectArrayWithoutType()
Get an array of all members without type.

Returns:
an array of all members

toString

public java.lang.String toString()
Override toString() function of java.lang.Object.

Overrides:
toString in class java.lang.Object
Returns:
A string that describes the content of the body.