public abstract class IPAddress<F extends IPAddress<F>> extends Object implements OFValueType<F>
Constructor and Description |
---|
IPAddress() |
Modifier and Type | Method and Description |
---|---|
abstract F |
and(F other)
Perform a low level AND operation on the bits of two IPAddress objects
|
abstract int |
asCidrMaskLength()
If this IPAddress represents a valid CIDR style netmask (see
isCidrMask()) returns the length of the prefix (the number of "1" bits).
|
abstract boolean |
equals(Object other) |
static IPAddress<?> |
fromInetAddress(InetAddress address)
Deprecated.
replaced by
of(InetAddress) |
abstract byte[] |
getBytes()
Returns the raw IP address of this
IPAddress object. |
abstract IPVersion |
getIpVersion()
Returns the Internet Protocol (IP) version of this object
|
abstract int |
hashCode() |
abstract boolean |
isBroadcast()
Checks if the IPAddress is the global broadcast address
255.255.255.255 in case of IPv4
|
abstract boolean |
isCidrMask()
Checks if this IPAddress represents a valid CIDR style netmask, i.e.,
it has a set of leading "1" bits followed by only "0" bits
|
abstract boolean |
isLinkLocal()
Returns
true if the IPAddress is a link local address. |
abstract boolean |
isLoopback()
Returns
true if the IPAddress is a loopback address. |
abstract boolean |
isMulticast()
Checks if the IPAddress is the multicast address
|
abstract boolean |
isUnspecified()
Returns
true if the IPAddress is unspecified. |
abstract F |
not()
Returns a new IPAddress object with the bits inverted
|
static IPAddress<?> |
of(InetAddress address)
Factory function for InetAddress values.
|
static IPAddress<?> |
of(String ip)
parse an IPv4Address or IPv6Address from their conventional string representation.
|
abstract F |
or(F other)
Perform a low level OR operation on the bits of two IPAddress objects
|
abstract InetAddress |
toInetAddress()
Returns an
InetAddress object representing this IP address. |
abstract String |
toString() |
abstract IPAddressWithMask<F> |
withMask(F mask)
Returns an
IPAddressWithMask<F> object that represents this
IP address masked by the given IP address mask. |
abstract IPAddressWithMask<F> |
withMaskOfLength(int cidrMaskLength)
Returns an
IPAddressWithMask<F> object that represents this
IP address masked by the CIDR subnet mask of the given prefix length. |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
applyMask, getLength
compareTo
putTo
public abstract IPVersion getIpVersion()
public abstract boolean isCidrMask()
public abstract int asCidrMaskLength()
IllegalStateException
- if isCidrMask() == falsepublic abstract boolean isUnspecified()
true
if the IPAddress is unspecified.
The unspecified addresses, also known as the wildcard addresses, refer to:
IPv4Address
of 0.0.0.0
IPv6Address
of ::
public abstract boolean isLoopback()
true
if the IPAddress is a loopback address.
Loopback addresses refer to:
IPv4Address
within 127.0.0.0/8
IPv6Address
of ::1
public abstract boolean isLinkLocal()
true
if the IPAddress is a link local address.
Link local addresses refer to:
IPv4Address
within 169.254.0.0/16
IPv6Address
within fe80::/10
public abstract boolean isBroadcast()
public abstract boolean isMulticast()
public abstract F and(F other)
other
- IPAddresspublic abstract F or(F other)
other
- IPAddresspublic abstract F not()
@Nonnull public abstract IPAddressWithMask<F> withMask(@Nonnull F mask)
IPAddressWithMask<F>
object that represents this
IP address masked by the given IP address mask.mask
- the F
object that represents the maskIPAddressWithMask<F>
object that represents this
IP address masked by the given maskNullPointerException
- if the given mask was null
@Nonnull public abstract IPAddressWithMask<F> withMaskOfLength(int cidrMaskLength)
IPAddressWithMask<F>
object that represents this
IP address masked by the CIDR subnet mask of the given prefix length.cidrMaskLength
- the prefix length of the CIDR subnet mask
(i.e. the number of leading one-bits),
where
0 <= cidrMaskLength <= (F.getLength() * 8)
IPAddressWithMask<F>
object that
represents this IP address masked by the CIDR
subnet mask of the given prefix lengthIllegalArgumentException
- if the given prefix length was invalidIPv4Address.ofCidrMaskLength(int)
,
IPv6Address.ofCidrMaskLength(int)
public abstract byte[] getBytes()
IPAddress
object. The result
is in network byte order: the highest order byte of the address is in
getBytes()[0]
.
Similar to InetAddress.getAddress()
InetAddress.getAddress()
@Nonnull public abstract InetAddress toInetAddress()
InetAddress
object representing this IP address.
The resulting InetAddress
object:
Inet6Address
@Nonnull public static IPAddress<?> of(@Nonnull String ip)
IPv4Address.of(String)
and IPv6Address.of(String)
ip
- a string representation of an IP addressNullPointerException
- if ip is nullIllegalArgumentException
- if string is not a valid IP address@Nonnull public static IPAddress<?> of(@Nonnull InetAddress address)
address
- the InetAddress you wish to parse into an IPAddress object.NullPointerException
- if address is null@Deprecated @Nonnull public static IPAddress<?> fromInetAddress(@Nonnull InetAddress address)
of(InetAddress)
address
- the InetAddress you wish to parse into an IPAddress object.NullPointerException
- if address is nullCopyright © 2015. All rights reserved.