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.InetAddress
ip_addr
protected int
port
-
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 int
compareTo(Address o)
implements the java.lang.Comparable interfaceIpAddress
copy()
java.util.function.Supplier<? extends IpAddress>
create()
Creates an instance of the class implementing this interfaceboolean
equals(java.lang.Object obj)
java.net.InetAddress
getIpAddress()
int
getPort()
int
hashCode()
java.lang.String
printIpAddress()
java.lang.String
printIpAddress2()
void
readFrom(java.io.DataInput in)
Read the state of the current object (including superclasses) from instream Note that the input stream must not be closedint
serializedSize()
Returns the size (in bytes) of the marshalled objectprotected void
setAddressToLocalHost()
java.lang.String
toString()
void
writeTo(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.Exception
e.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:Constructable
Creates an instance of the class implementing this interface- Specified by:
create
in 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:
compareTo
in 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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
printIpAddress
public java.lang.String printIpAddress()
- Specified by:
printIpAddress
in interfacePhysicalAddress
-
printIpAddress2
public java.lang.String printIpAddress2()
-
writeTo
public void writeTo(java.io.DataOutput 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.DataInput 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
-
serializedSize
public int serializedSize()
Description copied from interface:SizeStreamable
Returns the size (in bytes) of the marshalled object- Specified by:
serializedSize
in interfaceSizeStreamable
-
copy
public IpAddress copy()
-
-