| Modifier and Type | Field and Description |
|---|---|
protected java.net.InetAddress |
baseAddress
The base address of the CIDR notation
|
protected int |
cidrMask
The mask used in the CIDR notation
|
| Constructor and Description |
|---|
CIDR() |
| Modifier and Type | Method and Description |
|---|---|
private static java.net.InetAddress |
addressStringToInet(java.lang.String addr)
Convert an IPv4 or IPv6 textual representation into an
InetAddress.
|
abstract boolean |
contains(java.net.InetAddress inetAddress)
Compares the given InetAddress against the CIDR and returns true if
the ip is in the subnet-ip-range and false if not.
|
boolean |
equals(java.lang.Object o) |
java.net.InetAddress |
getBaseAddress() |
abstract java.net.InetAddress |
getEndAddress() |
static byte[] |
getIpV4FromIpV6(java.net.Inet6Address address)
Compute a byte representation of IpV4 from a IpV6
|
static byte[] |
getIpV6FromIpV4(java.net.Inet4Address address)
Compute a byte representation of IpV6 from a IpV4
|
int |
getMask() |
private static int |
getNetMask(java.lang.String netMask)
Get the Subnet's Netmask in Decimal format.
i.e.: getNetMask("255.255.255.0") returns the integer CIDR mask |
int |
hashCode() |
static CIDR |
newCIDR(java.net.InetAddress baseAddress,
int cidrMask)
Create CIDR using the CIDR Notation
|
static CIDR |
newCIDR(java.net.InetAddress baseAddress,
java.lang.String scidrMask)
Create CIDR using the normal Notation
|
static CIDR |
newCIDR(java.lang.String cidr)
Create CIDR using the CIDR or normal Notation
i.e.: CIDR subnet = newCIDR ("10.10.10.0/24"); or CIDR subnet = newCIDR ("1fff:0:0a88:85a3:0:0:ac1f:8001/24"); or CIDR subnet = newCIDR ("10.10.10.0/255.255.255.0"); |
private static int |
parseInt(java.lang.String intstr,
int def) |
java.lang.String |
toString() |
protected java.net.InetAddress baseAddress
protected int cidrMask
public static CIDR newCIDR(java.net.InetAddress baseAddress, int cidrMask) throws java.net.UnknownHostException
java.net.UnknownHostExceptionpublic static CIDR newCIDR(java.net.InetAddress baseAddress, java.lang.String scidrMask) throws java.net.UnknownHostException
java.net.UnknownHostExceptionpublic static CIDR newCIDR(java.lang.String cidr) throws java.net.UnknownHostException
java.net.UnknownHostExceptionpublic java.net.InetAddress getBaseAddress()
public int getMask()
public java.lang.String toString()
toString in class java.lang.Objectpublic abstract java.net.InetAddress getEndAddress()
public abstract boolean contains(java.net.InetAddress inetAddress)
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectprivate static java.net.InetAddress addressStringToInet(java.lang.String addr)
throws java.net.UnknownHostException
java.net.UnknownHostExceptionprivate static int getNetMask(java.lang.String netMask)
netMask - a network maskprivate static int parseInt(java.lang.String intstr,
int def)
intstr - a string containing an integer.def - the default if the string does not contain a valid
integer.public static byte[] getIpV4FromIpV6(java.net.Inet6Address address)
java.lang.IllegalArgumentException - if the IpV6 cannot be mapped to IpV4public static byte[] getIpV6FromIpV4(java.net.Inet4Address address)
java.lang.IllegalArgumentException - if the IpV6 cannot be mapped to IpV4