Remove IpSubnet.main()

- Should be run as a test case
This commit is contained in:
Trustin Lee 2012-05-30 15:40:51 -07:00
parent 65c526c1c8
commit 54047c69cf

View File

@ -53,7 +53,7 @@ import java.net.UnknownHostException;
*/
public class IpSubnet implements IpSet, Comparable<IpSubnet> {
/** Internal representation */
private CIDR cidr;
private final CIDR cidr;
/** Create IpSubnet for ALL (used for ALLOW or DENY ALL) */
public IpSubnet() {
@ -137,26 +137,4 @@ public class IpSubnet implements IpSet, Comparable<IpSubnet> {
public int compareTo(IpSubnet o) {
return cidr.toString().compareTo(o.cidr.toString());
}
/**
* Simple test functions
*
* @param args where args[0] is the netmask (standard or CIDR notation) and optional args[1] is
* the inetAddress to test with this IpSubnet
*/
public static void main(String[] args) throws Exception {
if (args.length != 0) {
IpSubnet ipSubnet = null;
try {
ipSubnet = new IpSubnet(args[0]);
} catch (UnknownHostException e) {
return;
}
System.out.println("IpSubnet: " + ipSubnet.toString() + " from " + ipSubnet.cidr.getBaseAddress() + " to "
+ ipSubnet.cidr.getEndAddress() + " mask " + ipSubnet.cidr.getMask());
if (args.length > 1) {
System.out.println("Is IN: " + args[1] + " " + ipSubnet.contains(args[1]));
}
}
}
}