Class AbstractEventFilter
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.event.filter.AbstractEventFilter
-
- All Implemented Interfaces:
EventFilter
- Direct Known Subclasses:
ClassEventFilter
,TypeEventFilter
public abstract class AbstractEventFilter extends Object implements EventFilter
An abstract base class for event filters.
This class can be used as base class by simple event filters that do not need to bother with specialties like null values or non event objects. The class can be configured whether it should accept null values or not. It can be initialized with a base class that must be derived from
BuilderEvent
. All objects accepted by this filter must then be of this class or one of its subclassesIn this class a base implementation of the
accept()
method is provided, which casts the passed in object to an event object and then delegates to the abstractacceptEvent()
method.- Version:
- $Id: AbstractEventFilter.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractEventFilter()
Creates a new instance ofAbstractEventFilter
.protected
AbstractEventFilter(Class<?> baseClass)
Creates a new instance ofAbstractEventFilter
and initializes it with the base class.protected
AbstractEventFilter(Class<?> baseClass, boolean acceptNull)
Creates a new instance ofAbstractEventFilter
and initializes it with the base class and theacceptNull
flag.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
accept(Object obj)
Tests whether the passed in object is accepted by this filter.protected abstract boolean
acceptEvent(BuilderEvent event)
Tests if the passed in event object is accepted by this filter.Class<?>
getBaseClass()
Returns the base class.boolean
isAcceptNull()
Returns theacceptNull
flag.void
setAcceptNull(boolean acceptNull)
Sets theacceptNull
flag.void
setBaseClass(Class<?> baseClass)
Sets the base class.
-
-
-
Constructor Detail
-
AbstractEventFilter
protected AbstractEventFilter()
Creates a new instance ofAbstractEventFilter
. The base class is set toBuilderEvent
; null values won't be accepted.
-
AbstractEventFilter
protected AbstractEventFilter(Class<?> baseClass)
Creates a new instance ofAbstractEventFilter
and initializes it with the base class. null values won't be accepted.- Parameters:
baseClass
- the base class (must no be null)
-
AbstractEventFilter
protected AbstractEventFilter(Class<?> baseClass, boolean acceptNull)
Creates a new instance ofAbstractEventFilter
and initializes it with the base class and theacceptNull
flag.- Parameters:
baseClass
- the base class (must no be null)acceptNull
- a flag if null values are accepted
-
-
Method Detail
-
accept
public boolean accept(Object obj)
Tests whether the passed in object is accepted by this filter. This implementation will perform a type cast an delegate to the
method.acceptEvent(BuilderEvent)
- Specified by:
accept
in interfaceEventFilter
- Parameters:
obj
- the object to test- Returns:
- a flag if this object is accepted
-
isAcceptNull
public boolean isAcceptNull()
Returns theacceptNull
flag.- Returns:
- a flag if null values are accepted
-
setAcceptNull
public void setAcceptNull(boolean acceptNull)
Sets theacceptNull
flag. If a null value is passed to theaccept()
method, the value of this flag is returned.- Parameters:
acceptNull
- a flag if null values are accepted
-
getBaseClass
public Class<?> getBaseClass()
Returns the base class.- Returns:
- the filter's base class
-
setBaseClass
public void setBaseClass(Class<?> baseClass)
Sets the base class. The passed in class object must not be null and must be derived fromBuilderEvent
.- Parameters:
baseClass
- the base class
-
acceptEvent
protected abstract boolean acceptEvent(BuilderEvent event)
Tests if the passed in event object is accepted by this filter. This method is called by the base implementation ofaccept()
.- Parameters:
event
- the event to be tested- Returns:
- a flag whether the event object is accepted
-
-