Package org.jgroups.stack
Class IpAddress
- java.lang.Object
-
- org.jgroups.stack.IpAddress
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable
,Address
,Streamable
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
Fields Modifier and Type Field Description protected static org.apache.commons.logging.Log
log
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Object
clone()
int
compare(IpAddress other)
Deprecated.Use#compareTo(org.jgroups.Address)
insteadint
compareTo(java.lang.Object o)
implements the java.lang.Comparable interfaceint
compareToUnique(java.lang.Object o)
Deprecated.Use#compareTo(org.jgroups.Address)
insteadboolean
equals(java.lang.Object obj)
byte[]
getAdditionalData()
Returns the additional_data.java.net.InetAddress
getIpAddress()
int
getPort()
int
hashCode()
boolean
isMulticastAddress()
Checks whether this is an address that represents multiple destinations; e.g., a class D address in the Internet.void
readExternal(java.io.ObjectInput in)
void
readFrom(java.io.DataInputStream in)
Read the state of the current object (including superclasses) from instream Note that the input stream must not be closedvoid
setAdditionalData(byte[] additional_data)
Sets the additional_data.int
size()
Returns serialized size of this addressjava.lang.String
toString()
void
writeExternal(java.io.ObjectOutput out)
void
writeTo(java.io.DataOutputStream out)
Write the entire state of the current object (including superclasses) to outstream.
-
-
-
Constructor Detail
-
IpAddress
public IpAddress()
-
IpAddress
public IpAddress(java.lang.String i, int p) throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
-
IpAddress
public IpAddress(java.net.InetAddress i, int p)
-
IpAddress
public IpAddress(int port)
-
IpAddress
public IpAddress(int port, boolean set_default_host)
-
IpAddress
public IpAddress(java.net.InetSocketAddress sock_addr)
-
-
Method Detail
-
getIpAddress
public final java.net.InetAddress getIpAddress()
-
getPort
public final int getPort()
-
isMulticastAddress
public final 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 interfaceAddress
- Returns:
- true if this is a multicast address, false if it is a unicast address
-
getAdditionalData
public final byte[] getAdditionalData()
Returns the additional_data.- Returns:
- byte[]
-
setAdditionalData
public final void setAdditionalData(byte[] additional_data)
Sets the additional_data.- Parameters:
additional_data
- The additional_data to set
-
compare
public final int compare(IpAddress other)
Deprecated.Use#compareTo(org.jgroups.Address)
insteadEstablishes 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 final int compareTo(java.lang.Object o)
implements the java.lang.Comparable interface- Specified by:
compareTo
in interfacejava.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
-
compareToUnique
public final int compareToUnique(java.lang.Object o)
Deprecated.Use#compareTo(org.jgroups.Address)
insteadThis method compares both addresses' dotted-decimal notation in string format if the hashcode and ports are identical. Ca 30% slower thancompareTo(Object)
if used excessively.- Parameters:
o
-- Returns:
-
equals
public final boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.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 interfacejava.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
writeTo
public void writeTo(java.io.DataOutputStream out) throws java.io.IOException
Description copied from interface:Streamable
Write the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed- Specified by:
writeTo
in interfaceStreamable
- Throws:
java.io.IOException
-
readFrom
public void readFrom(java.io.DataInputStream in) throws java.io.IOException
Description copied from interface:Streamable
Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed- Specified by:
readFrom
in interfaceStreamable
- Throws:
java.io.IOException
-
size
public int size()
Description copied from interface:Address
Returns serialized size of this address
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Overrides:
clone
in classjava.lang.Object
- Throws:
java.lang.CloneNotSupportedException
-
-