net.sf.jguiraffe.gui.builder.event.filter
Class AbstractEventFilter

java.lang.Object
  extended by net.sf.jguiraffe.gui.builder.event.filter.AbstractEventFilter
All Implemented Interfaces:
EventFilter
Direct Known Subclasses:
ClassEventFilter, TypeEventFilter

public abstract class AbstractEventFilter
extends java.lang.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 subclasses

In 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 abstract acceptEvent() method.

Version:
$Id: AbstractEventFilter.java 154 2009-02-09 21:07:07Z oheger $
Author:
Oliver Heger

Constructor Summary
protected AbstractEventFilter()
          Creates a new instance of AbstractEventFilter.
protected AbstractEventFilter(java.lang.Class<?> baseClass)
          Creates a new instance of AbstractEventFilter and initializes it with the base class.
protected AbstractEventFilter(java.lang.Class<?> baseClass, boolean acceptNull)
          Creates a new instance of AbstractEventFilter and initializes it with the base class and the acceptNull flag.
 
Method Summary
 boolean accept(java.lang.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.
 java.lang.Class<?> getBaseClass()
          Returns the base class.
 boolean isAcceptNull()
          Returns the acceptNull flag.
 void setAcceptNull(boolean acceptNull)
          Sets the acceptNull flag.
 void setBaseClass(java.lang.Class<?> baseClass)
          Sets the base class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractEventFilter

protected AbstractEventFilter()
Creates a new instance of AbstractEventFilter. The base class is set to BuilderEvent; null values won't be accepted.


AbstractEventFilter

protected AbstractEventFilter(java.lang.Class<?> baseClass)
Creates a new instance of AbstractEventFilter 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(java.lang.Class<?> baseClass,
                              boolean acceptNull)
Creates a new instance of AbstractEventFilter and initializes it with the base class and the acceptNull flag.

Parameters:
baseClass - the base class (must no be null)
acceptNull - a flag if null values are accepted
Method Detail

accept

public boolean accept(java.lang.Object obj)
Tests whether the passed in object is accepted by this filter. This implementation will perform a type cast an delegate to the acceptEvent(BuilderEvent) method.

Specified by:
accept in interface EventFilter
Parameters:
obj - the object to test
Returns:
a flag if this object is accepted

isAcceptNull

public boolean isAcceptNull()
Returns the acceptNull flag.

Returns:
a flag if null values are accepted

setAcceptNull

public void setAcceptNull(boolean acceptNull)
Sets the acceptNull flag. If a null value is passed to the accept() method, the value of this flag is returned.

Parameters:
acceptNull - a flag if null values are accepted

getBaseClass

public java.lang.Class<?> getBaseClass()
Returns the base class.

Returns:
the filter's base class

setBaseClass

public void setBaseClass(java.lang.Class<?> baseClass)
Sets the base class. The passed in class object must not be null and must be derived from BuilderEvent.

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 of accept().

Parameters:
event - the event to be tested
Returns:
a flag whether the event object is accepted


Copyright © 2009 The JGUIraffe Team. All Rights Reserved.