Class NetMaskSet
java.lang.Object
org.apache.catalina.util.NetMaskSet
This class maintains a Set of NetMask objects and allows to check if a given IP address is matched by any of the
NetMasks, making it easy to create Allow and Deny lists of CIDR networks and hosts.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCreates a NetMask object from the input string and adds it to the set.booleanAdds a NetMask object to the set if the set does not contain itvoidclear()removes all entries from the setbooleanTests if the provided IP address matches any of theNetMasks in the set.booleancontains(InetAddress inetAddress) Tests if the provided InetAddress matches any of theNetMasks in the set.booleanisEmpty()Tests if the set is empty.toString()Provides a string representation of this NetMaskSet.
-
Constructor Details
-
NetMaskSet
public NetMaskSet()
-
-
Method Details
-
contains
-
contains
Tests if the provided IP address matches any of theNetMasks in the set.- Parameters:
ipAddress- an IP address to check- Returns:
trueif the passed IP address is matched by any of theNetMasks in the set- Throws:
UnknownHostException- if the passed input is not a valid IP address
-
add
Adds a NetMask object to the set if the set does not contain it- Parameters:
netmask- The NetMask to add- Returns:
- true if the object was added
-
add
Creates a NetMask object from the input string and adds it to the set.- Parameters:
input- The string from which to construct the NetMask- Returns:
- true if the object was added
- Throws:
IllegalArgumentException- if the input is not a valid CIDR format.
-
clear
public void clear()removes all entries from the set -
isEmpty
public boolean isEmpty()Tests if the set is empty.- Returns:
trueif the set is empty, otherwisefalse
-
addAll
-
toString
-