Class TypeEventFilter
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.event.filter.AbstractEventFilter
-
- net.sf.jguiraffe.gui.builder.event.filter.TypeEventFilter
-
- All Implemented Interfaces:
EventFilter
public class TypeEventFilter extends AbstractEventFilter
A specialized
EventFilter
implementation that filters by an event type.This event filter class allows to filter by concrete event (sub) types. So a developer can specify in a fine-grained way, which events should pass the filter. For instance it is possible to filter only for window events of type
WINDOW_OPENED
.Instances of this class are initialized with the name of the type to filter for. It is not necessary to specify a specific event class because event type names should be unique. Because not every event class supports sub types this filter implementation uses reflection for obtaining the type. An event object is accepted only if
- it has a public method named
getType()
- invocation of the
getType()
method does not cause an exception and returns anEnum
object - the name of the
Enum
object matches the type name this filter was initialized with.
- Version:
- $Id: TypeEventFilter.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description TypeEventFilter()
Creates a new instance ofTypeEventFilter
.TypeEventFilter(String type)
Creates a new instance ofTypeEventFilter
and sets the name of the event type to be filtered.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
acceptEvent(BuilderEvent event)
Tests the given event.String
getEventType()
Returns the event type name.void
setEventType(String eventType)
Sets the event type name.-
Methods inherited from class net.sf.jguiraffe.gui.builder.event.filter.AbstractEventFilter
accept, getBaseClass, isAcceptNull, setAcceptNull, setBaseClass
-
-
-
-
Constructor Detail
-
TypeEventFilter
public TypeEventFilter()
Creates a new instance ofTypeEventFilter
. The event type is set to the default type. null values are not accepted.
-
TypeEventFilter
public TypeEventFilter(String type)
Creates a new instance ofTypeEventFilter
and sets the name of the event type to be filtered. If the type is null, no events are accepted.- Parameters:
type
- the name of the event type
-
-
Method Detail
-
acceptEvent
protected boolean acceptEvent(BuilderEvent event)
Tests the given event. This implementation compares the event's type with the configured event type.- Specified by:
acceptEvent
in classAbstractEventFilter
- Parameters:
event
- the event to be tested- Returns:
- a flag if this event is accepted
-
getEventType
public String getEventType()
Returns the event type name.- Returns:
- the event type
-
setEventType
public void setEventType(String eventType)
Sets the event type name. Only events with this type can pass this filter. If the type is null, no events are accepted.- Parameters:
eventType
- the event type
-
-