public class InetRange extends Object implements Cloneable
InetRange provides several methods to add either standalone addresses, or ranges (e.g. 100.200.300.0:100.200.300.255, which covers all addresses on on someones local network). It also provides methods for checking wether given address is in this range. Any number of ranges and standalone addresses can be added to the range.
Constructor and Description |
---|
InetRange()
Creates the empty range.
|
Modifier and Type | Method and Description |
---|---|
void |
add(InetAddress ip)
Adds another ip for this range.
|
void |
add(InetAddress from,
InetAddress to)
Adds another range of ips for this range.Any host with ip address
greater than or equal to the address of from and smaller than or equal
to the address of to will be included in the range.
|
boolean |
add(String s)
Adds another host or range to this range.
|
Object |
clone()
Creates a clone of this Object
|
boolean |
contains(InetAddress ip)
Checks wether the given ip is in the range.
|
boolean |
contains(String host)
Checks wether the givan host is in the range.
|
boolean |
contains(String host,
boolean attemptResolve)
Checks wether the given host is in the range.
|
String[] |
getAll()
Get all entries in the range as strings.
|
boolean |
remove(String s)
Removes an entry from this range.
|
String |
toString()
Get string representaion of this Range.
|
public boolean add(String s)
public void add(InetAddress ip)
ip
- IP os the host which should be added to this range.public void add(InetAddress from, InetAddress to)
from
- IP from where range starts(including).to
- IP where range ends(including).public boolean contains(String host)
host
- Host name to check.contains(String,boolean)
public boolean contains(String host, boolean attemptResolve)
Algorithm:
host
- Host name to check.attemptResolve
- Wether to lookup ip address which corresponds
to the host,if required.public boolean contains(InetAddress ip)
ip
- Address of the host to check.public String[] getAll()
remove(String)
public boolean remove(String s)
s
- Entry to remove.public String toString()
Copyright © 2024. All rights reserved.