Package org.dspace.statistics.util
Class IPTable
java.lang.Object
org.dspace.statistics.util.IPTable
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 ClassesModifier and TypeClassDescriptionstatic classException Class to deal with IPFormat errors. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCan be full v4 IP, subnet or range string.booleanCheck whether a given address is contained in this netblock.static longipToLong(InetAddress ip) Convert an IP address to a long integerbooleanisEmpty()Return whether IPTable is empty (having no entries)static StringlongToIp(long ip) Convert a long integer into an IP address stringtoSet()Convert to a Set.toString()Represent this IP table as a string
-
Constructor Details
-
IPTable
public IPTable()
-
-
Method Details
-
add
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:
-
ipToLong
Convert an IP address to a long integer- Parameters:
ip- the IP address- Returns:
-
longToIp
Convert a long integer into an IP address string- Parameters:
ip- the IP address as a long integer- Returns:
-
contains
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.
-
toSet
Convert to a Set. This set contains all IPs in the range- Returns:
- this table's content as a Set
-
isEmpty
public boolean isEmpty()Return whether IPTable is empty (having no entries)- Returns:
- true if empty, false otherwise
-
toString
Represent this IP table as a string
-