net.sf.mmm.util.filter.base
Class PatternFilterRule

java.lang.Object
  extended by net.sf.mmm.util.filter.base.PatternFilterRule
All Implemented Interfaces:
FilterRule<String>

public class PatternFilterRule
extends Object
implements FilterRule<String>

This is an implementation of the FilterRule interface that matches using a regex Pattern.

Since:
1.0.2
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
private  Pattern pattern
           
private  Boolean result
           
 
Constructor Summary
PatternFilterRule()
          The non-arg constructor.
PatternFilterRule(Pattern pattern, boolean resultOnMatch)
          The constructor.
PatternFilterRule(String pattern, boolean resultOnMatch)
          The constructor.
 
Method Summary
 Boolean accept(String string)
          This method checks if the given string is accepted, denied or ignored by this rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pattern

private Pattern pattern
See Also:
accept(String)

result

private Boolean result
See Also:
accept(String)
Constructor Detail

PatternFilterRule

public PatternFilterRule()
The non-arg constructor.
NOTE:
This constructor should not be called directly! It is only intended for reflective access (e.g. for JAXB).


PatternFilterRule

public PatternFilterRule(String pattern,
                         boolean resultOnMatch)
The constructor.

Parameters:
pattern - is the pattern a file has to match in order to activate this rule. Before this given string is compiled via Pattern.compile(String) the following manipulation is performed: If the pattern string does NOT start with the character ^ the implicit prefix .* is added. If the pattern does NOT end with the character $ the implicit suffix .* is appended.
resultOnMatch - is the result returned if the pattern matches.

PatternFilterRule

public PatternFilterRule(Pattern pattern,
                         boolean resultOnMatch)
The constructor.

Parameters:
pattern - is the pattern a file has to match in order to activate this rule.
resultOnMatch - is the result returned if the pattern matches.
Method Detail

accept

public Boolean accept(String string)
This method checks if the given string is accepted, denied or ignored by this rule.

Specified by:
accept in interface FilterRule<String>
Parameters:
string - is the string to check.
Returns:
true if the file should be accepted, false if the file should NOT be accepted or null if this rule does NOT make a decision about the given string.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.