|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectIpList
class IpList
Loads and provides quick access to a map of IP addresses. Reads a file containing IP addresses and ranges, as well as excluded addresses, and provides a way to check if a given IP address matches.
| Nested Class Summary | |
|---|---|
private class |
IpList.IpAddr
Data class to keep track of the four numeric components of an IP address. |
private class |
IpList.IpRange
Data structure to keep track of a range of IP addresses and whether they are "positive" or "negative". |
| Field Summary | |
|---|---|
private ArrayList<IpList.IpRange> |
ranges
List of IpRanges. |
| Constructor Summary | |
|---|---|
IpList(String path)
Constructs and loads an IP map from the specified file. |
|
| Method Summary | |
|---|---|
boolean |
isApproved(String ipAddrStr)
Parses the given IP address and checks whether it falls within one of the positive ranges of the map, and doesn't fall in one of the excluded ranges. |
private void |
processEntry(String line,
boolean isPositive)
Used by readMap to parse a single entry in the IP map file. |
private void |
readRanges(String path)
Reads the contents the given file into the IP map. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private ArrayList<IpList.IpRange> ranges
| Constructor Detail |
|---|
public IpList(String path)
throws IOException
path - Path to the file to load the IP map from.
IOException - If the IP map file couldn't be opened.| Method Detail |
|---|
public boolean isApproved(String ipAddrStr)
ipAddrStr - A string of the form "a.b.c.d" where each component
is a decimal number from 0-255.
private void readRanges(String path)
throws IOException
path - Path to the file to load
IOException - If the file couldn't be read from.
private void processEntry(String line,
boolean isPositive)
line - The line of text to parseisPositive - true if this is an "exclude" line
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||