Package org.jgroups.stack
Class IpAddress
- java.lang.Object
-
- org.jgroups.stack.IpAddress
-
- All Implemented Interfaces:
java.lang.Comparable<Address>,Address,Constructable<IpAddress>,PhysicalAddress,SizeStreamable,Streamable
public class IpAddress extends java.lang.Object implements PhysicalAddress, Constructable<IpAddress>
Network-dependent address (Internet). Generated by the bottommost layer of the protocol stack (UDP). Contains an InetAddress and port.- Author:
- Bela Ban
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Address o)implements the java.lang.Comparable interfaceIpAddresscopy()java.util.function.Supplier<? extends IpAddress>create()Creates an instance of the class implementing this interfacebooleanequals(java.lang.Object obj)static java.net.InetAddressgetByName(java.lang.String host)java.net.InetAddressgetIpAddress()static java.net.InetAddressgetLocalHost()intgetPort()inthashCode()java.lang.StringprintHostAddress()java.lang.StringprintIpAddress()java.lang.StringprintIpAddress2()voidreadFrom(java.io.DataInput in)Read the state of the current object (including superclasses) from instream Note that the input stream must not be closedintserializedSize()Returns the size (in bytes) of the marshalled objectprotected voidsetAddress(java.net.InetAddress i, int p)java.lang.StringtoString()voidwriteTo(java.io.DataOutput out)Write the entire state of the current object (including superclasses) to outstream.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jgroups.Address
isMulticast, isSiteAddress, isSiteMaster
-
Methods inherited from interface org.jgroups.PhysicalAddress
getSocketAddress
-
-
-
-
Constructor Detail
-
IpAddress
public IpAddress()
-
IpAddress
public IpAddress(java.lang.String addr_port) throws java.lang.Exceptione.g. 192.168.1.5:7800- Throws:
java.lang.Exception
-
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 p)
-
IpAddress
public IpAddress(java.net.InetSocketAddress sock_addr)
-
-
Method Detail
-
create
public java.util.function.Supplier<? extends IpAddress> create()
Description copied from interface:ConstructableCreates an instance of the class implementing this interface- Specified by:
createin interfaceConstructable<IpAddress>
-
getByName
public static java.net.InetAddress getByName(java.lang.String host) throws java.net.UnknownHostException- Throws:
java.net.UnknownHostException
-
getLocalHost
public static java.net.InetAddress getLocalHost()
-
getIpAddress
public java.net.InetAddress getIpAddress()
- Specified by:
getIpAddressin interfacePhysicalAddress
-
getPort
public int getPort()
- Specified by:
getPortin interfacePhysicalAddress
-
compareTo
public int compareTo(Address o)
implements the java.lang.Comparable interface- Specified by:
compareToin interfacejava.lang.Comparable<Address>- 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)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
printIpAddress
public java.lang.String printIpAddress()
- Specified by:
printIpAddressin interfacePhysicalAddress
-
printIpAddress2
public java.lang.String printIpAddress2()
-
printHostAddress
public java.lang.String printHostAddress()
-
writeTo
public void writeTo(java.io.DataOutput out) throws java.io.IOExceptionDescription copied from interface:StreamableWrite the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed- Specified by:
writeToin interfaceStreamable- Throws:
java.io.IOException
-
readFrom
public void readFrom(java.io.DataInput in) throws java.io.IOExceptionDescription copied from interface:StreamableRead the state of the current object (including superclasses) from instream Note that the input stream must not be closed- Specified by:
readFromin interfaceStreamable- Throws:
java.io.IOException
-
serializedSize
public int serializedSize()
Description copied from interface:SizeStreamableReturns the size (in bytes) of the marshalled object- Specified by:
serializedSizein interfaceSizeStreamable
-
copy
public IpAddress copy()
-
setAddress
protected void setAddress(java.net.InetAddress i, int p)
-
-