Package edu.cnu.mdi.component
Class IpAddressSupport
java.lang.Object
edu.cnu.mdi.component.IpAddressSupport
Validation and matching support for IPv4 addresses with optional wildcard octets.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic PatterncreatePattern(String filterString) Compiles a wildcard IPv4 address pattern into a matchingPattern.static booleanTests whether a string is a literal IPv4 address (no wildcards).static booleanvalidateSimpleWildcard(String ipPattern) Tests whether a string is a valid IPv4 address pattern, where each octet is either a literal[0, 255]value or a*wildcard (e.g.
-
Field Details
-
ANY_ADDRESS
- See Also:
-
BASIC_PATTERN
-
SIMPLE_STAR_PATTERN
-
-
Method Details
-
validate
Tests whether a string is a literal IPv4 address (no wildcards).- Parameters:
ipAddress- the string to test;nullis not valid- Returns:
trueifipAddressis four dot-separated octets, each in[0, 255]
-
validateSimpleWildcard
Tests whether a string is a valid IPv4 address pattern, where each octet is either a literal[0, 255]value or a*wildcard (e.g."129.57.*.*", orANY_ADDRESS).- Parameters:
ipPattern- the string to test;nullis not valid- Returns:
trueif every octet is a literal byte value or*
-
createPattern
Compiles a wildcard IPv4 address pattern into a matchingPattern.Returns
nullin two distinct cases that callers may need to tell apart:filterStringisnullor equalsANY_ADDRESS(meaning "match everything," so no filtering pattern is needed at all), orfilterStringfailsvalidateSimpleWildcard(java.lang.String)(meaning the input itself is invalid). Either way, treat anullresult as "no filter to apply" unless you specifically need to distinguish "no filter requested" from "invalid filter" — this method does not let you tell them apart.- Parameters:
filterString- the wildcard address pattern to compile, ornull/ANY_ADDRESSfor no filtering- Returns:
- a
Patternmatching literal IPv4 addresses consistent with the wildcard pattern, ornull(see above)
-