Package de.mhus.lib.core.net
Class Subnet
- java.lang.Object
-
- de.mhus.lib.core.net.Subnet
-
public class Subnet extends Object
https://stackoverflow.com/questions/4209760/validate-an-ip-address-with-mask- Author:
- c3oe.de, based on snippets from Scott Plante, John Kugelmann
-
-
Constructor Summary
Constructors Constructor Description Subnet(InetAddress subnetAddress, int bits)For use via format "192.168.0.0/24" or "2001:db8:85a3:880:0:0:0:0/57"Subnet(InetAddress subnetAddress, InetAddress mask)For use via format "192.168.0.0/255.255.255.0" or single address
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SubnetcreateInstance(String subnetMask)Subnet factory method.booleanequals(Object obj)inthashCode()booleanisInNet(String address)booleanisInNet(InetAddress address)StringtoString()
-
-
-
Constructor Detail
-
Subnet
public Subnet(InetAddress subnetAddress, int bits)
For use via format "192.168.0.0/24" or "2001:db8:85a3:880:0:0:0:0/57"- Parameters:
subnetAddress-bits-
-
Subnet
public Subnet(InetAddress subnetAddress, InetAddress mask)
For use via format "192.168.0.0/255.255.255.0" or single address- Parameters:
subnetAddress-mask-
-
-
Method Detail
-
createInstance
public static Subnet createInstance(String subnetMask) throws UnknownHostException
Subnet factory method.- Parameters:
subnetMask- format: "192.168.0.0/24" or "192.168.0.0/255.255.255.0" or single address or "2001:db8:85a3:880:0:0:0:0/57"- Returns:
- a new instance
- Throws:
UnknownHostException- thrown if unsupported subnet mask.
-
isInNet
public boolean isInNet(String address)
-
isInNet
public boolean isInNet(InetAddress address)
-
-