groupmgmt
Class Member

java.lang.Object
  extended bygroupmgmt.Member
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class Member
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

The Member is identified by its address and port.

Version:
July 2003
Author:
Christine Julien, Tom Elgin
See Also:
Serialized Form

Field Summary
private  java.net.InetAddress address
          The InetAddress of the Member.
private  int port
          The port of the Member.
 
Constructor Summary
Member(java.net.InetAddress address, int port)
          Create a Member.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compare another Member to this one.
 boolean equals(java.lang.Object o)
          Returns true if the specified object is a Member and has the same address and port number.
 java.net.InetAddress getAddress()
          Returns the IP address of the host represented by this Member.
 int getPort()
          Returns the port of the host represented by this Member.
 int hashCode()
          Returns a hash value based on the IP and port of this Member
 java.lang.String toString()
          Get a String representation of this Member.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

address

private java.net.InetAddress address
The InetAddress of the Member.


port

private int port
The port of the Member.

Constructor Detail

Member

public Member(java.net.InetAddress address,
              int port)
Create a Member.

Parameters:
address - The InetAddress of the Member.
port - The port number of the Member.
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Compare another Member to this one. Returns -1 if this Member's address is less than the specified Member, -1 if the addresses are the same but this Member's port is less, 0 if the addresses and ports are equal, 1 if the addresses are equal but this Member's port is greater, or 1 if this Member's address is greater than that of the specified Member. Addresses are compared as Strings, so "10.10.10.9" is higher than "10.10.10.10". Ports are compared as integers.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The Object to compare this Member to.
Returns:
The result of the comparison.
Throws:
java.lang.ClassCastException - If the specified object is not a Member.

equals

public boolean equals(java.lang.Object o)
Returns true if the specified object is a Member and has the same address and port number.

Returns:
True if the specified object matches this one.

hashCode

public int hashCode()
Returns a hash value based on the IP and port of this Member

Returns:
The hash value.

getAddress

public java.net.InetAddress getAddress()
Returns the IP address of the host represented by this Member.


getPort

public int getPort()
Returns the port of the host represented by this Member.


toString

public java.lang.String toString()
Get a String representation of this Member.

Returns:
The IP address and port in brackets - [address:port].