public class IpV4Subnet extends java.lang.Object implements IpSet, java.lang.Comparable<IpV4Subnet>
| Modifier and Type | Field and Description |
|---|---|
private int |
cidrMask |
private java.net.InetAddress |
inetAddress |
private int |
mask |
private int |
subnet |
private static int |
SUBNET_MASK |
| Constructor and Description |
|---|
IpV4Subnet()
Create IpV4Subnet for ALL (used for ALLOW or DENY ALL)
|
IpV4Subnet(java.net.InetAddress inetAddress,
int cidrNetMask)
Create IpV4Subnet using the CIDR Notation
|
IpV4Subnet(java.net.InetAddress inetAddress,
java.lang.String netMask)
Create IpV4Subnet using the normal Notation
|
IpV4Subnet(java.lang.String netAddress)
Create IpV4Subnet using the CIDR or normal Notation
i.e.: IpV4Subnet subnet = new IpV4Subnet("10.10.10.0/24"); or IpV4Subnet subnet = new IpV4Subnet("10.10.10.0/255.255.255.0"); |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(IpV4Subnet o)
Compare two IpV4Subnet
|
boolean |
contains(java.net.InetAddress inetAddress1)
Compares the given InetAddress against the Subnet and returns true if
the ip is in the subnet-ip-range and false if not.
|
boolean |
contains(java.lang.String ipAddr)
Compares the given IP-Address against the Subnet and returns true if
the ip is in the subnet-ip-range and false if not.
|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
private void |
setCidrNetMask(int cidrNetMask)
Sets the CIDR Netmask
i.e.: setCidrNetMask(24); |
private void |
setNetAddress(java.net.InetAddress inetAddress,
int cidrNetMask)
Sets the Network Address in CIDR Notation.
|
private void |
setNetAddress(java.net.InetAddress inetAddress,
java.lang.String netMask)
Sets the Network Address in Decimal Notation.
|
private void |
setNetAddress(java.lang.String netAddress)
Sets the Network Address in either CIDR or Decimal Notation.
i.e.: setNetAddress("1.1.1.1/24"); or setNetAddress("1.1.1.1/255.255.255.0"); |
private void |
setNetId(java.net.InetAddress inetAddress)
Sets the BaseAdress of the Subnet.
|
private void |
setNetId(java.lang.String netId)
Sets the BaseAdress of the Subnet.
i.e.: setNetId("192.168.1.0"); |
private void |
setNetMask(java.lang.String netMask)
Sets the Subnet's Netmask in Decimal format.
i.e.: setNetMask("255.255.255.0"); |
private static int |
toInt(java.net.InetAddress inetAddress1)
Compute integer representation of InetAddress
|
java.lang.String |
toString() |
private static final int SUBNET_MASK
private java.net.InetAddress inetAddress
private int subnet
private int mask
private int cidrMask
public IpV4Subnet()
public IpV4Subnet(java.lang.String netAddress)
throws java.net.UnknownHostException
netAddress - a network address as string.java.net.UnknownHostExceptionpublic IpV4Subnet(java.net.InetAddress inetAddress,
int cidrNetMask)
public IpV4Subnet(java.net.InetAddress inetAddress,
java.lang.String netMask)
private void setNetAddress(java.lang.String netAddress)
throws java.net.UnknownHostException
netAddress - a network address as string.java.net.UnknownHostExceptionprivate void setNetAddress(java.net.InetAddress inetAddress,
int cidrNetMask)
private void setNetAddress(java.net.InetAddress inetAddress,
java.lang.String netMask)
private void setNetId(java.lang.String netId)
throws java.net.UnknownHostException
netId - a network IDjava.net.UnknownHostExceptionprivate static int toInt(java.net.InetAddress inetAddress1)
private void setNetId(java.net.InetAddress inetAddress)
private void setNetMask(java.lang.String netMask)
netMask - a network maskprivate void setCidrNetMask(int cidrNetMask)
cidrNetMask - a netmask in CIDR notationpublic boolean contains(java.lang.String ipAddr)
throws java.net.UnknownHostException
ipAddr - an ipaddressjava.net.UnknownHostExceptionpublic boolean contains(java.net.InetAddress inetAddress1)
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(IpV4Subnet o)
compareTo in interface java.lang.Comparable<IpV4Subnet>