org.javagroups.stack
Class IpAddress

java.lang.Object
  extended byorg.javagroups.stack.IpAddress
All Implemented Interfaces:
Address, java.lang.Cloneable, java.lang.Comparable, java.io.Externalizable, java.io.Serializable

public class IpAddress
extends java.lang.Object
implements Address

Network-dependent address (Internet). Generated by the bottommost layer of the protocol stack (UDP). Contains an InetAddress and port.

Author:
Bela Ban
See Also:
Serialized Form

Field Summary
protected static java.util.HashMap sAddrCache
           
 
Constructor Summary
IpAddress()
           
IpAddress(java.net.InetAddress i, int p)
           
IpAddress(int port)
           
IpAddress(java.lang.String i, int p)
           
 
Method Summary
 int compare(IpAddress other)
          Establishes an order between 2 addresses.
 int compareTo(java.lang.Object o)
          implements the java.lang.Comparable interface
 boolean equals(java.lang.Object obj)
           
 byte[] getAdditionalData()
          Returns the additional_data.
 java.net.InetAddress getIpAddress()
           
protected static java.net.InetAddress getIpAddress(byte[] addr)
           
 int getPort()
           
 int hashCode()
           
 boolean isMulticastAddress()
          Checks whether this is an address that represents multiple destinations, e.g.
 void readExternal(java.io.ObjectInput in)
           
 void setAdditionalData(byte[] additional_data)
          Sets the additional_data.
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

sAddrCache

protected static java.util.HashMap sAddrCache
Constructor Detail

IpAddress

public IpAddress()

IpAddress

public IpAddress(java.lang.String i,
                 int p)

IpAddress

public IpAddress(java.net.InetAddress i,
                 int p)

IpAddress

public IpAddress(int port)
Method Detail

getIpAddress

public java.net.InetAddress getIpAddress()

getPort

public int getPort()

isMulticastAddress

public boolean isMulticastAddress()
Description copied from interface: Address
Checks whether this is an address that represents multiple destinations, e.g. a class D address in the internet

Specified by:
isMulticastAddress in interface Address
Returns:
true if this is a multicast address, false if it is a unicast address

getAdditionalData

public byte[] getAdditionalData()
Returns the additional_data.

Returns:
byte[]

setAdditionalData

public void setAdditionalData(byte[] additional_data)
Sets the additional_data.

Parameters:
additional_data - The additional_data to set

compare

public int compare(IpAddress other)
Establishes an order between 2 addresses. Assumes other contains non-null IpAddress. Excludes channel_name from comparison.

Returns:
0 for equality, value less than 0 if smaller, greater than 0 if greater.

compareTo

public int compareTo(java.lang.Object o)
implements the java.lang.Comparable interface

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - - the Object to be compared
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.ClassCastException - - if the specified object's type prevents it from being compared to this Object.
See Also:
Comparable

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()

toString

public java.lang.String toString()

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

getIpAddress

protected static java.net.InetAddress getIpAddress(byte[] addr)


Copyright © 2001,2002 www.javagroups.com . All Rights Reserved.