public class IPRange extends Object
segment1.segment2.segment3.segment4
.Modifier and Type | Class and Description |
---|---|
(package private) static class |
IPRange.IPToken |
Modifier and Type | Field and Description |
---|---|
static IPRange |
LOCALHOST
Validates for Localhost "127.0.0.1".
|
static IPRange |
NETWORK_10
Validates for the "10.*.*.*" network
|
static IPRange |
NETWORK_192_168
Validates for the "192.168.*.*" network
|
Constructor and Description |
---|
IPRange(int segment1,
int segment2,
int segment3,
int segment4)
Constructor of a single IP address.
|
IPRange(int segment1Start,
int segment1end,
int segment2Start,
int segment2end,
int segment3Start,
int segment3end,
int segment4Start,
int segment4end)
Constructor for an IP range.
|
IPRange(String ipRange)
Parse a string to an ip range.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
String |
getIpmask()
Gets the ip mask.
|
protected IPRange.IPToken |
getSegment1() |
protected IPRange.IPToken |
getSegment2() |
protected IPRange.IPToken |
getSegment3() |
protected IPRange.IPToken |
getSegment4() |
boolean |
isInsideIpRange(InetAddress ip)
Evaluates if the an IP4 adress is inside the range.
|
boolean |
isInsideIpRange(String ip)
Validates a string to an IP4 adress and validates that is inside the defined range.
|
String |
toString() |
public static IPRange LOCALHOST
public static IPRange NETWORK_192_168
public static IPRange NETWORK_10
public IPRange(int segment1, int segment2, int segment3, int segment4)
segment1
- a value between 0 and 255 (both inclusive) "segment1.segment2.segment3.segment4"segment2
- a value between 0 and 255 (both inclusive) "segment1.segment2.segment3.segment4"segment3
- a value between 0 and 255 (both inclusive) "segment1.segment2.segment3.segment4"segment4
- a value between 0 and 255 (both inclusive) "segment1.segment2.segment3.segment4"public IPRange(int segment1Start, int segment1end, int segment2Start, int segment2end, int segment3Start, int segment3end, int segment4Start, int segment4end)
segment1Start
- the start value for segment1 between 0 and 255 (both inclusive).segment1end
- the end value for segment1 between 0 and 255 (both inclusive).segment2Start
- the start value for segment2 between 0 and 255 (both inclusive).segment2end
- the end value for segment2 between 0 and 255 (both inclusive).segment3Start
- the start value for segment3 between 0 and 255 (both inclusive).segment3end
- the end value for segment3 between 0 and 255 (both inclusive).segment4Start
- the start value for segment4 between 0 and 255 (both inclusive).segment4end
- the end value for segment1 between 0 and 255 (both inclusive).public IPRange(String ipRange) throws PropertyException
ipRange
- a string of four segments divide by dot. Where each segment is either a value between 0 and 255 (inclusive), or an asterix, or an range of two numbers divided by dash, where start value is lower or equal end value and the value is between 0 and 255 (inclusive).PropertyException
- if the ipmask string did not parse.public String getIpmask()
public boolean isInsideIpRange(String ip) throws NullPointerException
ip
- the ip address or hostname.true
if the ip address is valid and is inside the range defined, otherwise false
.NullPointerException
- if the ip address is null
.public boolean isInsideIpRange(InetAddress ip) throws NullPointerException
ip
- the InetAddress.true
if the ip address is inside the range defined, otherwise false
.NullPointerException
- if the ip is null
.protected IPRange.IPToken getSegment1()
protected IPRange.IPToken getSegment2()
protected IPRange.IPToken getSegment3()
protected IPRange.IPToken getSegment4()