Package org.n52.janmayen.net
Class IPAddressRange
java.lang.Object
org.n52.janmayen.net.IPAddressRange
public class IPAddressRange
extends Object
implements Predicate<IPAddress>, com.google.common.base.Predicate<IPAddress>
Representation of an IPv4 address range based on an address and a subnet mask.
-
Constructor Summary
ConstructorsConstructorDescriptionIPAddressRange(String string) Creates a new address range from its string representation.IPAddressRange(IPAddress address, int prefix) Creates a new address range from the an address and an prefix.IPAddressRange(IPAddress address, IPAddress mask) Creates a new address range from an address an a subnet mask. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.com.google.common.collect.Range<IPAddress> asRange()booleanChecks if a given IP address is in this range.booleangetHigh()getLow()getMask()Get the mask described by this prefix.(package private) static IPAddressgetMaskForPrefix(int prefix, int numBits) int(package private) static intgetPrefixForMask(IPAddress mask) inthashCode()booleanisIPv4()Checks if this address range is IPv4.booleanisIPv6()Checks if this address range is IPv6.booleantoString()
-
Constructor Details
-
IPAddressRange
Creates a new address range from its string representation. This can be either a CIDR or subnet notation.
Examples:192.168.1.1/24 192.168.1.1/255.255.255.0 2001:db8:abcd:0012::0/64 2001:db8:abcd:0012::0/ffff:ffff:ffff:ffff::
- Parameters:
string- the string representation
-
IPAddressRange
Creates a new address range from an address an a subnet mask.- Parameters:
address- the addressmask- the subnet mask
-
IPAddressRange
Creates a new address range from the an address and an prefix.- Parameters:
address- the addressprefix- the prefix
-
-
Method Details
-
isIPv4
public boolean isIPv4()Checks if this address range is IPv4.- Returns:
- if it is IPv4
-
isIPv6
public boolean isIPv6()Checks if this address range is IPv6.- Returns:
- if it is IPv6
-
getAddress
- Returns:
- the IP address
-
getPrefix
public int getPrefix()- Returns:
- the subnet mask
-
getMask
Get the mask described by this prefix.- Returns:
- the mask
-
getHigh
- Returns:
- the highest IP address in this range
-
getLow
- Returns:
- the lowest IP address in this range
-
contains
Checks if a given IP address is in this range.- Parameters:
ip- the address- Returns:
- whether this range contains the address
-
asRange
- Returns:
- this address range as a
Range
-
apply
Deprecated.- Specified by:
applyin interfacecom.google.common.base.Predicate<IPAddress>
-
test
-
hashCode
public int hashCode() -
equals
-
toString
-
getPrefixForMask
-
getMaskForPrefix
-