Package org.dspace.statistics.util
Class IPTable
- java.lang.Object
-
- org.dspace.statistics.util.IPTable
-
public class IPTable extends Object
A Spare v4 IPTable implementation that uses nested HashMaps to optimize IP address matching over ranges of IP addresses.- Author:
- mdiggory at atmire.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIPTable.IPFormatExceptionException Class to deal with IPFormat errors.
-
Constructor Summary
Constructors Constructor Description IPTable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String ip)Can be full v4 IP, subnet or range string.booleancontains(String ip)Check whether a given address is contained in this netblock.booleanisEmpty()Return whether IPTable is empty (having no entries)Set<String>toSet()Convert to a Set.
-
-
-
Method Detail
-
add
public void add(String ip) throws IPTable.IPFormatException
Can be full v4 IP, subnet or range string.- A full address is a complete dotted-quad:
"1.2.3.4". - A subnet is a dotted-triplet:
"1.2.3". It means an entire Class C subnet: "1.2.3.0-1.2.3.255". - A range is two dotted-quad addresses separated by hyphen:
"1.2.3.4-1.2.3.14". Only the final octet may be different.
- Parameters:
ip- IP address(es)- Throws:
IPTable.IPFormatException- Exception Class to deal with IPFormat errors.
- A full address is a complete dotted-quad:
-
contains
public boolean contains(String ip) throws IPTable.IPFormatException
Check whether a given address is contained in this netblock.- Parameters:
ip- the address to be tested- Returns:
- true if
ipis within this table's limits. Returns false ifiplooks like an IPv6 address. - Throws:
IPTable.IPFormatException- Exception Class to deal with IPFormat errors.
-
isEmpty
public boolean isEmpty()
Return whether IPTable is empty (having no entries)- Returns:
- true if empty, false otherwise
-
-