|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.mmm.util.filter.base.FilterRuleChainPlainParser
public class FilterRuleChainPlainParser
This class allows to parse a list of including and excluding regex
PatternFilterRules and build an according FilterRuleChain.
The rules (include/exclude patterns) are proceeded in the order of their
appearance in the list.
Here is an example of a configuration (rule list) parsed by this class:
# This file contains a filter-chain. Such chain is build of a list of # filter-rules. Each rule starts with a character that determines if an # inclusion (+) or an exclusion (-) is defined. This character must be followed # by a regex pattern. To make it easier for you a simple pre-processing is # performed on the pattern string before it is compiled as # java.util.regex.Pattern: # If the pattern does NOT start with "^" or ".*" the prefix ".*" is # automatically added. If the pattern does NOT end with "$" or ".*" the suffix # ".*" is automatically appended. # The pre-processing should safe you some typing and make it a little easier for # users of the GNU command "grep". # # The filter-rules in the chain are processed in the order of their occurrence. # The first rule that matches makes the decision according to the first # character (+/-). # A list starting with the '#' character indicates a comment and is therefore # ignored. The same applies for empty lines. # 1. rule says that all strings that start with "/doc/" will be accepted: +^/doc/ # 2. rule says that all strings that end ($) with ".pdf" ignoring the case (?i) # of the characters will be rejected: -(?i)\.pdf$ # 3. rule says that all string that start with "/data/" will be accepted: +^/data/ # 4. rule says that all string that end ($) with ".xml" or ".xsl" ignoring the # case (?i) of the characters will be rejected: -(?i)\.(xml|xsl)$ # 5. rule says that everything else is accepted +.*
FilterRuleChainXmlParser| Field Summary | |
|---|---|
private char |
acceptChar
|
private char |
commentChar
|
private char |
denyChar
|
| Constructor Summary | |
|---|---|
FilterRuleChainPlainParser()
The constructor. |
|
| Method Summary | |
|---|---|
char |
getAcceptChar()
This method gets the character used to identify an accept pattern. |
char |
getCommentChar()
This method gets the character used to identify a comment. |
char |
getDenyChar()
This method gets the character used to identify a deny pattern. |
FilterRuleChain<String> |
parse(BufferedReader reader,
boolean defaultResult)
This method parses the content of the given reader as
FilterRuleChain as described above. |
FilterRuleChain<String> |
parse(Reader reader,
boolean defaultResult)
This method parses the content of the given reader as
FilterRuleChain as described above. |
void |
setAcceptChar(char acceptChar)
|
void |
setCommentChar(char commentChar)
|
void |
setDenyChar(char denyChar)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private char acceptChar
getAcceptChar()private char denyChar
getDenyChar()private char commentChar
getCommentChar()| Constructor Detail |
|---|
public FilterRuleChainPlainParser()
| Method Detail |
|---|
public char getAcceptChar()
'+'.
public void setAcceptChar(char acceptChar)
acceptChar - the acceptChar to setpublic char getDenyChar()
'-'.
public void setDenyChar(char denyChar)
denyChar - the denyChar to setpublic char getCommentChar()
'#'.
public void setCommentChar(char commentChar)
commentChar - the commentChar to set
public FilterRuleChain<String> parse(Reader reader,
boolean defaultResult)
throws IOException
reader as
FilterRuleChain as described above.
reader - is where to read from. It will be closed at the end of this
method (on success and in an exceptional state).defaultResult - is the default-result of the chain.
IOException - if an I/O error occurred while parsing.
public FilterRuleChain<String> parse(BufferedReader reader,
boolean defaultResult)
throws IOException
reader as
FilterRuleChain as described above.
reader - is where to read from. It will be closed at the end of this
method (on success and in an exceptional state).defaultResult - is the default-result of the chain.
IOException - if an I/O error occurred while parsing.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||