Package org.n52.janmayen.net
Class IPAddressRange
- java.lang.Object
-
- org.n52.janmayen.net.IPAddressRange
-
-
Constructor Summary
Constructors Constructor Description IPAddressRange(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
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanapply(IPAddress input)Deprecated.com.google.common.collect.Range<IPAddress>asRange()booleancontains(IPAddress ip)Checks if a given IP address is in this range.booleanequals(Object obj)IPAddressgetAddress()IPAddressgetHigh()IPAddressgetLow()IPAddressgetMask()Get the mask described by this prefix.(package private) static IPAddressgetMaskForPrefix(int prefix, int numBits)intgetPrefix()(package private) static intgetPrefixForMask(IPAddress mask)inthashCode()booleanisIPv4()Checks if this address range is IPv4.booleanisIPv6()Checks if this address range is IPv6.booleantest(IPAddress input)StringtoString()
-
-
-
Constructor Detail
-
IPAddressRange
public IPAddressRange(String string)
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
public IPAddressRange(IPAddress address, IPAddress mask)
Creates a new address range from an address an a subnet mask.- Parameters:
address- the addressmask- the subnet mask
-
IPAddressRange
public IPAddressRange(IPAddress address, int prefix)
Creates a new address range from the an address and an prefix.- Parameters:
address- the addressprefix- the prefix
-
-
Method Detail
-
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
public IPAddress getAddress()
- Returns:
- the IP address
-
getPrefix
public int getPrefix()
- Returns:
- the subnet mask
-
getMask
public IPAddress getMask()
Get the mask described by this prefix.- Returns:
- the mask
-
getHigh
public IPAddress getHigh()
- Returns:
- the highest IP address in this range
-
getLow
public IPAddress getLow()
- Returns:
- the lowest IP address in this range
-
contains
public boolean contains(IPAddress ip)
Checks if a given IP address is in this range.- Parameters:
ip- the address- Returns:
- whether this range contains the address
-
asRange
public com.google.common.collect.Range<IPAddress> asRange()
- Returns:
- this address range as a
Range
-
apply
@Deprecated public boolean apply(IPAddress input)
Deprecated.- Specified by:
applyin interfacecom.google.common.base.Predicate<IPAddress>
-
test
public boolean test(IPAddress input)
-
equals
public boolean equals(Object obj)
-
getPrefixForMask
static int getPrefixForMask(IPAddress mask)
-
getMaskForPrefix
static IPAddress getMaskForPrefix(int prefix, int numBits)
-
-