Class IpAddress

java.lang.Object
org.jgroups.stack.IpAddress
All Implemented Interfaces:
Externalizable, Serializable, Cloneable, Comparable, Address, Streamable

public class IpAddress extends 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:
  • Field Details

    • log

      protected static final org.apache.commons.logging.Log log
  • Constructor Details

  • Method Details

    • getIpAddress

      public final 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 interface Address
      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.
      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 final int compareTo(Object o)
      implements the java.lang.Comparable interface
      Specified by:
      compareTo in interface 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:
      ClassCastException - - if the specified object's type prevents it from being compared to this Object.
      See Also:
    • compareToUnique

      public final int compareToUnique(Object o)
      Deprecated.
      This method compares both addresses' dotted-decimal notation in string format if the hashcode and ports are identical. Ca 30% slower than compareTo(Object) if used excessively.
      Parameters:
      o -
      Returns:
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException
    • writeTo

      public void writeTo(DataOutputStream out) throws 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 interface Streamable
      Throws:
      IOException
    • readFrom

      public void readFrom(DataInputStream in) throws 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 interface Streamable
      Throws:
      IOException
    • size

      public int size()
      Description copied from interface: Address
      Returns serialized size of this address
      Specified by:
      size in interface Address
    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException