Package org.jboss.netty.handler.ipfilter
Class PatternRule
java.lang.Object
org.jboss.netty.handler.ipfilter.PatternRule
- All Implemented Interfaces:
Comparable<Object>,IpFilterRule,IpSet
The Class PatternRule represents an IP filter rule using string patterns.
Rule Syntax:
Example: allow localhost:
new PatternRule(true, "n:localhost")
Example: allow local lan:
new PatternRule(true, "i:192.168.0.*")
Example: block all
new PatternRule(false, "n:*")
Rule Syntax:
Rule ::= [n|i]:address n stands for computer name, i for ip address address ::= <regex> | localhost regex is a regular expression with '*' as multi character and '?' as single character wild card
Example: allow localhost:
new PatternRule(true, "n:localhost")
Example: allow local lan:
new PatternRule(true, "i:192.168.0.*")
Example: block all
new PatternRule(false, "n:*")
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleancontains(InetAddress inetAddress) Compares the given InetAddress against the IpSet and returns true if the InetAddress is contained in this Rule and false if not.returns the pattern.booleanboolean
-
Constructor Details
-
PatternRule
Instantiates a new pattern rule.- Parameters:
allow- indicates if this is an allow or block rulepattern- the filter pattern
-
-
Method Details
-
getPattern
returns the pattern.- Returns:
- the pattern
-
isAllowRule
public boolean isAllowRule()- Specified by:
isAllowRulein interfaceIpFilterRule- Returns:
- True if this Rule is an ALLOW rule
-
isDenyRule
public boolean isDenyRule()- Specified by:
isDenyRulein interfaceIpFilterRule- Returns:
- True if this Rule is a DENY rule
-
contains
Description copied from interface:IpSetCompares the given InetAddress against the IpSet and returns true if the InetAddress is contained in this Rule and false if not. -
compareTo
- Specified by:
compareToin interfaceComparable<Object>
-