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
- Direct Known Subclasses:
IpAddressUUID
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
-
-
Field Summary
Fields Modifier and Type Field Description protected java.net.InetAddressip_addrprotected intport-
Fields inherited from interface org.jgroups.Address
IP_ADDR, IP_ADDR_UUID, NULL, SITE_MASTER, SITE_UUID, UUID_ADDR
-
-
Constructor Summary
Constructors Constructor Description IpAddress()IpAddress(int port)IpAddress(int port, boolean set_default_host)IpAddress(java.lang.String addr_port)e.g.IpAddress(java.lang.String i, int p)IpAddress(java.net.InetAddress i, int p)IpAddress(java.net.InetSocketAddress sock_addr)
-
Method Summary
All 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)java.net.InetAddressgetIpAddress()intgetPort()inthashCode()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 voidsetAddressToLocalHost()java.lang.StringtoString()voidwriteTo(java.io.DataOutput out)Write the entire state of the current object (including superclasses) to outstream.
-
-
-
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 port)
-
IpAddress
public IpAddress(int port, boolean set_default_host)
-
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>
-
setAddressToLocalHost
protected void setAddressToLocalHost()
-
getIpAddress
public java.net.InetAddress getIpAddress()
-
getPort
public int getPort()
-
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()
-
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()
-
-