public class IPv4Address extends Object implements Serializable
Constructor and Description |
---|
IPv4Address()
Constructs a new IPv4Address object.
|
IPv4Address(byte[] addr)
Constructs a new object based on the value stored in the passed array.
|
IPv4Address(InetAddress addr)
Creates a new IPv4Address from the passed InetAddress object.
|
IPv4Address(int ipv4Addr)
Constructs a new address object based on the 32-bit passed value.
|
IPv4Address(IPv4Address second)
Constructs a new address object based upon the value of the first object.
|
IPv4Address(String ipv4Addr)
Creates a new object by decomposing the passed string into it four
components.
|
Modifier and Type | Method and Description |
---|---|
static String |
addressToString(byte[] buf)
Converts the passed IPv4 address buffer to a dotted decimal IP address
string.
|
static String |
addressToString(int ipv4Addr)
Converts the passed 32-bit IPv4 address to a dotted decimal IP address
string.
|
boolean |
equals(Object obj)
Test to determine if the passed object is equal to self.
|
int |
getAddress()
Returns the 32-bit IPv4 address.
|
byte[] |
getAddressBytes()
Returns the IPv4 address in the form of an array of 4 bytes
|
int |
hashCode()
If you override equals() you need to make a hashCode implementation as well
|
void |
setAddress(byte[] addr)
Sets the object based on the value stored in the passed array.
|
void |
setAddress(InetAddress addr)
Sets the IPv4Address from the passed InetAddress object.
|
void |
setAddress(int ipv4Addr)
Sets the address object based on the 32-bit passed value.
|
void |
setAddress(IPv4Address second)
Sets the current address based upon the value of the passed object.
|
void |
setAddress(String ipv4Addr)
Sets the object by decomposing the passed string into it four components.
|
String |
toString()
Converts the object to a string and returns the string to the caller.
|
public IPv4Address()
public IPv4Address(IPv4Address second)
second
- The object to copy the address from.public IPv4Address(byte[] addr)
addr
- The IPv4Address dataIllegalArgumentException
- Thrown if the passed buffer is not in the correct format
for an IPv4Address.public IPv4Address(int ipv4Addr)
ipv4Addr
- The 32-bit IP address.public IPv4Address(String ipv4Addr)
ipv4Addr
- The dotted decimal address.IllegalArgumentException
- Thrown if the string is a malformed dotted decimal
address.public IPv4Address(InetAddress addr)
addr
- The Internet Address containing the IPv4 address.public static String addressToString(int ipv4Addr)
ipv4Addr
- The 32-bit addresspublic static String addressToString(byte[] buf)
buf
- The 4 byte bufferIllegalArgumentException
- Thrown if the buffer is not exactly 4 bytes in length.public int getAddress()
public byte[] getAddressBytes()
public void setAddress(IPv4Address second)
second
- The new address.public void setAddress(byte[] addr)
addr
- The IPv4Address dataIllegalArgumentException
- Thrown if the passed buffer is not in the correct format
for an IPv4Address.public void setAddress(int ipv4Addr)
ipv4Addr
- The 32-bit IP address.public void setAddress(String ipv4Addr)
ipv4Addr
- The dotted decimal address.IllegalArgumentException
- Thrown if the string is a malformed dotted decimal
address.public void setAddress(InetAddress addr)
addr
- The Internet Address containing the IPv4 address.public boolean equals(Object obj)
public int hashCode()
Copyright © 2002–2023 The OpenNMS Group, Inc.. All rights reserved.