Package org.jboss.netty.handler.ipfilter
Class PatternRule
- java.lang.Object
-
- org.jboss.netty.handler.ipfilter.PatternRule
-
- All Implemented Interfaces:
Comparable<Object>,IpFilterRule,IpSet
public class PatternRule extends Object implements IpFilterRule, Comparable<Object>
The Class PatternRule represents an IP filter rule using string patterns.
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 Constructor Description PatternRule(boolean allow, String pattern)Instantiates a new pattern rule.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Object o)booleancontains(InetAddress inetAddress)Compares the given InetAddress against the IpSet and returns true if the InetAddress is contained in this Rule and false if not.StringgetPattern()returns the pattern.booleanisAllowRule()booleanisDenyRule()
-
-
-
Constructor Detail
-
PatternRule
public PatternRule(boolean allow, String pattern)Instantiates a new pattern rule.- Parameters:
allow- indicates if this is an allow or block rulepattern- the filter pattern
-
-
Method Detail
-
getPattern
public String 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
public boolean contains(InetAddress inetAddress)
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
public int compareTo(Object o)
- Specified by:
compareToin interfaceComparable<Object>
-
-