- java.lang.Object
-
- ch.qos.logback.core.util.IpAddressMatcher
-
public class IpAddressMatcher extends Object
Matches anInetAddressagainst a single IP address or a CIDR network range.Accepted forms:
- Single address:
192.168.1.10,2001:db8::1 - CIDR range:
192.168.1.0/24,2001:db8::/32
- Since:
- 1.6.2
- Author:
- Ceki Gülcü
- Single address:
-
-
Constructor Summary
Constructors Constructor Description IpAddressMatcher(String addressOrCidr)Creates a matcher for the given address or CIDR specification.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetSpecification()The original specification used to construct this matcher.booleanmatches(String address)Returnstrueif the given address string matches this matcher.booleanmatches(InetAddress address)Returnstrueif the given address matches this matcher.StringtoString()
-
-
-
Constructor Detail
-
IpAddressMatcher
public IpAddressMatcher(String addressOrCidr)
Creates a matcher for the given address or CIDR specification.- Parameters:
addressOrCidr- a single IP oraddress/prefixLength- Throws:
IllegalArgumentException- if the specification is invalid
-
-
Method Detail
-
matches
public boolean matches(InetAddress address)
Returnstrueif the given address matches this matcher.- Parameters:
address- the address to test; may benull- Returns:
trueifaddressmatches
-
matches
public boolean matches(String address)
Returnstrueif the given address string matches this matcher.- Parameters:
address- an IP address string- Returns:
trueif the address matches- Throws:
IllegalArgumentException- ifaddresscannot be parsed
-
getSpecification
public String getSpecification()
The original specification used to construct this matcher.
-
-