net.sf.mmm.util.filter.base
Class FilterRuleChain<V>

java.lang.Object
  extended by net.sf.mmm.util.filter.base.FilterRuleChain<V>
Type Parameters:
V - is the generic type of the value to check.
All Implemented Interfaces:
Filter<V>

public class FilterRuleChain<V>
extends Object
implements Filter<V>

This class implements a Filter that is based on a chain of FilterRules.

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

Field Summary
private  boolean defaultResult
           
private  String id
           
private  FilterRuleChain<V> parent
          The parent that is extended by this chain or null.
private  FilterRule<V>[] rules
          the rules
 
Constructor Summary
FilterRuleChain()
          The non-arg constructor.
FilterRuleChain(boolean defaultResult, FilterRule<V>... rules)
          The constructor.
FilterRuleChain(String id, FilterRuleChain<V> parent, boolean defaultResult, FilterRule<V>... rules)
          The constructor.
 
Method Summary
 boolean accept(V value)
          This method determines if the given value should be accepted.
private  Boolean acceptRecursive(V value)
          This method implements accept(Object) recursively.
 FilterRuleChain<V> extend(boolean newDefaultResult, FilterRule<V>... additionalRules)
          This method extends this chain with additionalRules.
 boolean getDefaultResult()
          This method gets the default result used if none of the rules matched.
 String getId()
          This method gets the ID used to identify this chain.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

private String id
See Also:
getId()

parent

private FilterRuleChain<V> parent
The parent that is extended by this chain or null.


rules

private FilterRule<V>[] rules
the rules


defaultResult

private boolean defaultResult
See Also:
getDefaultResult()
Constructor Detail

FilterRuleChain

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


FilterRuleChain

public FilterRuleChain(boolean defaultResult,
                       FilterRule<V>... rules)
The constructor.

Parameters:
rules - is the chain of rules.
defaultResult - is the result if none of the rules match.

FilterRuleChain

public FilterRuleChain(String id,
                       FilterRuleChain<V> parent,
                       boolean defaultResult,
                       FilterRule<V>... rules)
The constructor.

Parameters:
id - is the ID.
parent - is the parent-chain to extend or null for a root-chain.
rules - is the chain of rules.
defaultResult - is the result if none of the rules match.
Method Detail

getDefaultResult

public boolean getDefaultResult()
This method gets the default result used if none of the rules matched.

Returns:
the default result.

accept

public boolean accept(V value)
This method determines if the given value should be accepted. This method checks all rules in the chain and returns the result of the first matching rule. If no rule matches, getDefaultResult() is returned.

Specified by:
accept in interface Filter<V>
Parameters:
value - is the value to check.
Returns:
true if the given value is acceptable, false if it should be filtered.

acceptRecursive

private Boolean acceptRecursive(V value)
This method implements accept(Object) recursively.

Parameters:
value - is the value to filter.
Returns:
true if the value is accepted, false if the value is NOT accepted, or null if no decision is made.

extend

public FilterRuleChain<V> extend(boolean newDefaultResult,
                                 FilterRule<V>... additionalRules)
This method extends this chain with additionalRules.

Parameters:
newDefaultResult - is the result of the new extended chain if none of the rules match.
additionalRules - are the rules to add.
Returns:
the chain that also checks the additionalRules if none of this rules match.

getId

public String getId()
This method gets the ID used to identify this chain.

Returns:
the ID or null if undefined.

toString

public String toString()

Overrides:
toString in class Object


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