public final class IPv4Address extends IPAddress<IPv4Address>
| Modifier and Type | Field and Description | 
|---|---|
static IPv4Address | 
LOCALHOST
An IPv4 address object for localhost,  
127.0.0.1. | 
static IPv4Address | 
MAX_VALUE
The maximum IPv4 address object,  
255.255.255.255. | 
static IPv4Address | 
MIN_VALUE
The minimum IPv4 address object,  
0.0.0.0. | 
| Modifier and Type | Method and Description | 
|---|---|
IPv4Range | 
asRange()
Returns an IP range containing only this IP address. 
 | 
int | 
bits()
Returns the number of bits required to store the IP address, always  
32. | 
int | 
compareTo(IPv4Address other)  | 
boolean | 
equals(Object o)
Tests whether or not another object is equal to this IP address. 
 | 
static IPv4Address | 
getNetmask(int prefixLength)
Returns an IPv4 address for a specific net mask. 
 | 
int | 
hashCode()
Returns a hash code value for this IP address. 
 | 
boolean | 
hasNext()
Returns whether or not there is a next IP address. 
 | 
boolean | 
hasPrevious()
Returns whether or not there is a previous IP address. 
 | 
static Predicate<CharSequence> | 
ifValidIPv4Address(Predicate<? super IPv4Address> predicate)
Returns a predicate that checks whether or not  
CharSequences are valid IPv4 addresses that match a specific predicate. | 
IPv4Subnet | 
inSubnet(int prefixLength)
Returns a subnet of a specific prefix length that contains this IP address. 
 | 
static boolean | 
isIPv4Address(CharSequence s)
Tests whether or not a  
CharSequence is a valid IPv4 address. | 
static boolean | 
isIPv4Address(CharSequence s,
             int start,
             int end)
Tests whether or not a portion of a  
CharSequence is a valid IPv4 address. | 
boolean | 
isLinkLocalAddress()
Returns whether or not this IP address is a link local address. 
 | 
boolean | 
isLoopbackAddress()
Returns whether or not this IP address is a loopback address. 
 | 
boolean | 
isMulticastAddress()
Returns whether or not this IP address is an IP multicast address. 
 | 
boolean | 
isSiteLocalAddress()
Returns whether or not this IP address is a site local address. 
 | 
boolean | 
isValidNetmask()
Returns whether or not this IPv4 address would be a valid netmask. 
 | 
boolean | 
isWildcardAddress()
Returns whether or not this IP address is a wildcard address. 
 | 
IPv4Address | 
next()
Returns the next IP address if it exists. 
 | 
IPv4Address | 
previous()
Returns the previous IP address if it exists. 
 | 
IPv4Range | 
to(IPv4Address end)
Returns an IP range starting at this IP address and ending in another IP address. 
 | 
byte[] | 
toByteArray()
Returns a byte array representation of this IP address. 
 | 
IPv6Address | 
toIPv6()
Returns an IPv6 representation of this IPv4 address. 
 | 
static Optional<IPv4Address> | 
tryValueOfIPv4(CharSequence address)
Attempts to return an IPv4 address represented by a  
CharSequence. | 
static Optional<IPv4Address> | 
tryValueOfIPv4(CharSequence address,
              int start,
              int end)
Attempts to return an IPv4 address represented by a portion of a  
CharSequence. | 
static IPv4Address | 
valueOf(byte[] address)
Returns an IPv4 address from a byte array representation of the address. 
 | 
static IPv4Address | 
valueOf(CharSequence address)
Returns an IPv4 address represented by a  
CharSequence. | 
static IPv4Address | 
valueOf(CharSequence address,
       int start,
       int end)
Returns an IPv4 address represented by a portion of a  
CharSequence. | 
static IPv4Address | 
valueOf(Inet4Address address)
Returns an IPv4 address represented by a  
Inet4Address. | 
static IPv4Address | 
valueOf(int octet1,
       int octet2,
       int octet3,
       int octet4)
Returns an IPv4 address from four octets. 
 | 
ifValidIPAddress, isIPAddress, isIPAddress, toInetAddress, toString, tryValueOf, tryValueOf, valueOfpublic static final IPv4Address LOCALHOST
127.0.0.1.public static final IPv4Address MIN_VALUE
0.0.0.0.public static final IPv4Address MAX_VALUE
255.255.255.255.public int bits()
32.bits in class IPAddress<IPv4Address>public byte[] toByteArray()
IPAddressIPAddress.bits() divided by Byte.SIZE.
 Furthermore, the result is in network byte order; the highest order byte is in the first element.toByteArray in class IPAddress<IPv4Address>public IPv6Address toIPv6()
::ffff:d.d.d.d, where d.d.d.d represents this IPv4 address.public boolean equals(Object o)
IPAddressIPAddress.toByteArray().
 
 Implementations do not necessary need to use IPAddress.toByteArray(), as long as equal IP addresses also have equal byte array representations.
equals in class IPAddress<IPv4Address>public int hashCode()
IPAddress
 Implementations do not necessarily need to use IPAddress.toByteArray(), as long as the general contract as specified by
 Object.hashCode() is not violated.
hashCode in class IPAddress<IPv4Address>public int compareTo(IPv4Address other)
public boolean isMulticastAddress()
1110.
 In other words, this method returns whether or not the IP address is in range 224.0.0.0 through 239.255.255.255.isMulticastAddress in class IPAddress<IPv4Address>true if this IP address is an IP multicast address, or false otherwise.Inet4Address.isMulticastAddress()public boolean isWildcardAddress()
isWildcardAddress in class IPAddress<IPv4Address>true if this IP address is a wildcard address, or false otherwise.Inet4Address.isAnyLocalAddress()public boolean isLoopbackAddress()
127.0.0.0/8 subnet.isLoopbackAddress in class IPAddress<IPv4Address>true if this IP address is a loopback address, or false otherwise.Inet4Address.isLoopbackAddress()public boolean isLinkLocalAddress()
169.254.0.0/16 subnet.isLinkLocalAddress in class IPAddress<IPv4Address>true if this IP address is a link local address, or false otherwise.Inet4Address.isLinkLocalAddress()public boolean isSiteLocalAddress()
10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16 subnets.isSiteLocalAddress in class IPAddress<IPv4Address>true if this IP address is a site local address, or false otherwise.Inet4Address.isSiteLocalAddress()public boolean hasNext()
IPAddresshasNext in class IPAddress<IPv4Address>true if there is a next IP address, or false otherwise.public IPv4Address next()
IPAddressnext in class IPAddress<IPv4Address>IPAddress.hasNext()public boolean hasPrevious()
IPAddresshasPrevious in class IPAddress<IPv4Address>true if there is a previous IP address, or false otherwise.public IPv4Address previous()
IPAddressprevious in class IPAddress<IPv4Address>IPAddress.hasPrevious()public IPv4Range to(IPv4Address end)
IPAddressto in class IPAddress<IPv4Address>end - The end of the IP range, inclusive.public IPv4Range asRange()
IPAddressasRange in class IPAddress<IPv4Address>public IPv4Subnet inSubnet(int prefixLength)
IPAddressinSubnet in class IPAddress<IPv4Address>prefixLength - The prefix length of the subnet to return.public static IPv4Address valueOf(int octet1, int octet2, int octet3, int octet4)
valueOf(192, 168, 0, 1) will return an IPv4 address that represents 192.168.0.1.octet1 - The first octet.octet2 - The second octet.octet3 - The third octet.octet4 - The fourth octet.IllegalArgumentException - If any of the octets is not between 0 and 255, inclusive.public static IPv4Address valueOf(byte[] address)
address - The array to return an IPv4 address for.NullPointerException - If the given array is null.IllegalArgumentException - If the length of the given array is not 4.public static IPv4Address valueOf(CharSequence address)
CharSequence.address - The IPv4 address as a CharSequence.NullPointerException - If the given CharSequence is null.IllegalArgumentException - If the given CharSequence does not represent a valid IPv4 address.public static IPv4Address valueOf(CharSequence address, int start, int end)
CharSequence.address - The IPv4 address as a CharSequence.start - The index in the CharSequence where the IPv4 address starts, inclusive.end - The index in the CharSequence where the IPv4 address ends, exclusive.NullPointerException - If the given CharSequence is null.IndexOutOfBoundsException - If the start index is negative, or if the end index is larger than the length of the CharSequence,
                                       or if the start index is larger than the end index.IllegalArgumentException - If the given CharSequence does not represent a valid IPv4 address.public static Optional<IPv4Address> tryValueOfIPv4(CharSequence address)
CharSequence.address - The possible IPv4 address as a CharSequence.Optional with the IPv4 address that represents the given address, or Optional.empty() if the given
         CharSequence is nullor does not represent a valid IPv4 address.public static Optional<IPv4Address> tryValueOfIPv4(CharSequence address, int start, int end)
CharSequence.address - The possible IPv4 address as a CharSequence.start - The index in the CharSequence where the IPv4 address starts, inclusive.end - The index in the CharSequence where the IPv4 address ends, exclusive.Optional with the IPv4 address that represents the given address, or Optional.empty() if the given
         CharSequence is nullor does not represent a valid IPv4 address.IndexOutOfBoundsException - If the start index is negative, or if the end index is larger than the length of the CharSequence,
                                       or if the start index is larger than the end index (unless if the CharSequence is null).public static IPv4Address valueOf(Inet4Address address)
Inet4Address.address - The IPv4 address as a Inet4Address.NullPointerException - If the given Inet4Address is null.public static IPv4Address getNetmask(int prefixLength)
prefixLength - The prefix length of the subnet for the net mask.
            For instance, 0 represents a net mask for /0 which is 0.0.0.0,
            8 represents a net mask for a class A network /8 which is 255.0.0.0,
            16 represents a net mask for a class B network /16 which is 255.255.0.0,
            24 represents a net mask for a class C network /24 which is 255.255.255.0, etc.IllegalArgumentException - If the number of bits is not between 0 and 32, inclusive.public boolean isValidNetmask()
1s.true if this IPv4 address would be a valid netmask, or false otherwise.public static boolean isIPv4Address(CharSequence s)
CharSequence is a valid IPv4 address.s - The CharSequence to test.true if the CharSequence is a valid IP address, or false otherwise.public static boolean isIPv4Address(CharSequence s, int start, int end)
CharSequence is a valid IPv4 address.s - The CharSequence to test.start - The index in the CharSequence to start checking at, inclusive.end - The index in the CharSequence to end checking at, exclusive.true if the CharSequence is a valid IP address, or false otherwise.IndexOutOfBoundsException - If the start index is negative, or if the end index is larger than the length of the CharSequence,
                                       or if the start index is larger than the end index (unless if the CharSequence is null).public static Predicate<CharSequence> ifValidIPv4Address(Predicate<? super IPv4Address> predicate)
CharSequences are valid IPv4 addresses that match a specific predicate.
 This predicate can handle null values, which do not match the predicate.predicate - The predicate to check if CharSequences are valid IP addresses.CharSequences are valid IP addresses that match the given predicate.isIPv4Address(CharSequence)Copyright © 2019–2023. All rights reserved.