Package org.jppf.net
Class IPv4AddressPattern
java.lang.Object
org.jppf.net.RangePattern
org.jppf.net.AbstractIPAddressPattern
org.jppf.net.IPv4AddressPattern
- Direct Known Subclasses:
IPv4AddressNetmask
Represents a pattern used for IP addresses include or exclude lists.
A pattern represents a single value or a range of values for each component of an IP address.
A pattern represents a single value or a range of values for each component of an IP address.
Examples:
- 192.168.1.10 represents a single IP address
- 192.168.1 represents all IP addresses in the range 192.168.1.0 - 192.168.1.255
- 192.168 represents all IP addresses in the range 192.168.0.0 - 192.168.255.255
- 192.168-170.10 represents all IP addresses where the first component is equal to 192, the second in the range 168 - 170, the third equal to 10, and the fourth in the range 0 - 255 (equivalent to 192.168-170.10.0-255)
- 192.168-170.10.1-32 represents all IP addresses where the first component is equal to 192, the second in the range 12 - 120, the third equal to 10, and the fourth in the range 1 - 32
Syntax rules:
1. An empty component is considered as a 0-255 range. Examples:
- .2.3.4 is equivalent to 0-255.2.3.4
- 1.2..4 is equivalent to 1.2.0-255.4
- 1.2.3. is equivalent to 1.2.3 and to 1.2.3.0-255
2. Ranges with missing bounds but still including the "-" sign are interpreted as a range with the lower bound equal to zero for a missing lower bound, and an upper bound equal to 255 if the upper bound is missing. Examples:
- -128 is equivalent to 0-128
- 12- is equivalent to 12-255
- - is equivalent to an empty value and to 0-255
3. Valid values for range bounds and single values are positive integers in the range 0 ... 255. A pattern containing any invalid value will be ignored.
4. A pattern describing more than 4 components or containing characters other than decimal digits, '-', '.' or spaces will be ignored.
- Author:
- Laurent Cohen
-
Field Summary
Fields inherited from class org.jppf.net.RangePattern
config, ranges -
Constructor Summary
ConstructorsConstructorDescriptionIPv4AddressPattern(String source) Initialize this object with the specified string pattern. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidMain method.booleanmatches(InetAddress ip) Determine whether the specified IP address matches this pattern.Methods inherited from class org.jppf.net.RangePattern
convertSource, matches, postProcess, preProcess, toString
-
Constructor Details
-
IPv4AddressPattern
Initialize this object with the specified string pattern.- Parameters:
source- the source pattern as a string.- Throws:
IllegalArgumentException- if the pattern is null or invalid.
-
-
Method Details
-
matches
Description copied from class:AbstractIPAddressPatternDetermine whether the specified IP address matches this pattern. No check is made to verify that the IP address is valid.- Overrides:
matchesin classAbstractIPAddressPattern- Parameters:
ip- the ip to match as a string.- Returns:
- true if the address matches this pattern, false otherwise.
-
main
Main method.- Parameters:
args- not used.
-