gishur.core
Class ClassFilter

java.lang.Object
  |
  +--gishur.core.Filter
        |
        +--gishur.core.ClassFilter

public class ClassFilter
extends Filter

A Filter, that accepts (rejects) an Object, if it is (not) an instance of a (any) class stored. One can add classes via the constructors or an add-method. The method setAcceptMode(boolean) switches the behaviour of the filter.

Version:
1.0
Author:
Thomas Wolf

Constructor Summary
ClassFilter(java.lang.Class cls)
          Single class Constructor.
 
Method Summary
 boolean acceptMode()
          If the returned value is true, the filter accepts Objects that are instances of at least one class stored at this filter.
 void add(java.lang.Class cls)
          Adds a Class object to the list of classes accepted / rejected by this filter (depends on acceptMode()).
 void add(java.lang.Class[] cls)
          Adds an array of classes to the list of classes accepted / rejected by this filter (depends on acceptMode()).
 void add(java.util.Enumeration enum)
          Adds an Enumeration of classes to the list of classes accepted / rejected by this filter (depends on acceptMode()).
protected  boolean check(java.lang.Object obj)
          This method should be overwritten in order to perform the filtering.
 void setAcceptMode(boolean mode)
          Sets the mode of the ClassFilter; if the given value is true, the filter accepts Objects that are instances of at least one class stored at this filter.
 java.lang.String toString()
          Overrides java.lang.Object.toString().
 
Methods inherited from class gishur.core.Filter
addFilter, nextFilter, removeFilter, valid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassFilter

public ClassFilter(java.lang.Class cls)
Single class Constructor.
Parameters:
cls - class that is allowed
Method Detail

toString

public java.lang.String toString()
Overrides java.lang.Object.toString().
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

add

public void add(java.lang.Class cls)
Adds a Class object to the list of classes accepted / rejected by this filter (depends on acceptMode()).
Parameters:
cls - Class to add.

add

public void add(java.lang.Class[] cls)
Adds an array of classes to the list of classes accepted / rejected by this filter (depends on acceptMode()).
Parameters:
cls - array of classes to add.

add

public void add(java.util.Enumeration enum)
Adds an Enumeration of classes to the list of classes accepted / rejected by this filter (depends on acceptMode()).
Parameters:
enum - Enumeration of classes to add.

setAcceptMode

public void setAcceptMode(boolean mode)
Sets the mode of the ClassFilter; if the given value is true, the filter accepts Objects that are instances of at least one class stored at this filter. If the given value is false, the filter accepts Objects that are not instances of any of the classes stored at this filter.
Parameters:
mode - the mode to set
See Also:
acceptMode()

acceptMode

public boolean acceptMode()
If the returned value is true, the filter accepts Objects that are instances of at least one class stored at this filter. If the returned value is false, the filter accepts Objects that are not instances of any of the classes stored at this filter.
Returns:
the actual accept mode.
See Also:
setAcceptMode(boolean)

check

protected boolean check(java.lang.Object obj)
This method should be overwritten in order to perform the filtering.
Overrides:
check in class Filter
Parameters:
obj - the Object to be tested
Returns:
true, if the given Object is not filtered-out