JIDE 3.5.15

com.jidesoft.filter
Interface Filter<T>

All Superinterfaces:
Cloneable, Serializable
All Known Subinterfaces:
DynamicTableFilter<T>, Filter<T>, ListFilter<T>, MutableValueFilter<E>, TableFilter<T>, TableRowFilter<T>, ValueFilter<E>
All Known Implementing Classes:
AbstractDynamicTableFilter, AbstractFilter, AbstractFilter, AbstractListFilter, AbstractMutableValueFilter, AbstractTableFilter, AbstractTableRowFilter, AbstractValueFilter, AllFilter, AndFilter, AutoFilterUtils.TableWildcardFilter, BetweenFilter, DateOrCalendarFilter, EmptyFilter, EqualFilter, GreaterOrEqualFilter, GreaterThanFilter, IFilterableTableModel.FilterItem, InFilter, LastMonthFilter, LastQuarterFilter, LastWeekFilter, LastYearFilter, LessOrEqualFilter, LessThanFilter, LikeFilter, MonthFilter, MultipleFilters, MultipleValuesFilter, NextMonthFilter, NextQuarterFilter, NextWeekFilter, NextYearFilter, NoneFilter, NotBetweenFilter, NotEqualFilter, NotFilter, NotInFilter, NotLikeFilter, OrFilter, QuarterFilter, QuickFilterField.FieldFilter, QuickTableFilterField.FieldTableFilter, RegexFilter, SimpleValueFilter, SingleValueFilter, ThisMonthFilter, ThisQuarterFilter, ThisWeekFilter, ThisYearFilter, TodayFilter, TomorrowFilter, WildcardFilter, YearFilter, YesterdayFilter

public interface Filter<T>
extends Serializable, Cloneable

Filter is used to filter some values away by checking the value in isValueFiltered(Object). If isValueFiltered(Object) returns true, the value should be filtered. Otherwise, it should return false.

In addition, you can give the filter a name by implementing getName(). You can also enable or disable a filter. If a filter is disabled, no matter what value isValueFiltered returns, it should never be considered.

AbstractFilter implements this interface to provide basic support a Filter needs such as name, enabled/disabled, and listener support.


Field Summary
static String ALL
          A constant for ALL for filters.
static String CUSTOM
          A constant for ALL for filters.
static String NULL
          A constant for null value for filters.
static String SEPARATOR
           
 
Method Summary
 void addFilterListener(FilterListener l)
          Adds a listener to the list that's notified each time a change to the filter occurs.
 Object clone()
          Creates and returns a copy of the filter.
 FilterFactory getFilterFactory()
          Gets the FilterFactory.
 String getFilterFactoryName()
          Gets the FilterFactory name.
 String getName()
          Gets the name of the filter.
 String getPreference(Class<?> clazz, ConverterContext converterContext)
          Gets the preference while persisting this filter.
 boolean isEnabled()
          Checks if the filter is enabled.
 boolean isValueFiltered(T value)
          Checks to see if the value should be filtered.
 void removeFilterListener(FilterListener l)
          Removes a listener from the list that's notified each time a change to the filter occurs.
 void setEnabled(boolean enabled)
          Sets the filter enabled or disabled.
 void setFilterFactory(FilterFactory filterFactory)
          Sets the FilterFactory that creates this Filter.
 void setFilterFactoryName(String name)
          Sets the FilterFactory name that creates this Filter.
 void setName(String name)
          Sets the name of the filter.
 Object[] setPreference(String prefString, Class<?> clazz, ConverterContext converterContext)
          Sets the preference to load the preference string back to this filter.
 boolean stricterThan(Filter inputFilter)
          Checks if this filter is stricter than the input filter.
 

Field Detail

ALL

static final String ALL
A constant for ALL for filters. If you want to display it on screen, please use GridResource.getResourceBundle(locale).getString("Filter.all") to get the localized string

See Also:
Constant Field Values

NULL

static final String NULL
A constant for null value for filters. If you want to display it on screen, please use GridResource.getResourceBundle(locale).getString("Filter.null") to get the localized string

See Also:
Constant Field Values

CUSTOM

static final String CUSTOM
A constant for ALL for filters. If you want to display it on screen, please use GridResource.getResourceBundle(locale).getString("Filter.custom") to get the localized string

See Also:
Constant Field Values

SEPARATOR

static final String SEPARATOR
See Also:
Constant Field Values
Method Detail

getName

String getName()
Gets the name of the filter.

Returns:
the name of the filter.

setName

void setName(String name)
Sets the name of the filter.

Parameters:
name - the name of the filter.

isValueFiltered

boolean isValueFiltered(T value)
Checks to see if the value should be filtered.

Parameters:
value - the value to filter
Returns:
true if the value should be filtered. Otherwise false.

isEnabled

boolean isEnabled()
Checks if the filter is enabled. If a filter is not enabled, isValueFiltered() will never be called.

Returns:
true if the filter is enabled. Otherwise false.

setEnabled

void setEnabled(boolean enabled)
Sets the filter enabled or disabled.

Parameters:
enabled - true to enabled the filter; false to disable it.

getFilterFactory

FilterFactory getFilterFactory()
Gets the FilterFactory. If the Filter is created through a FilterFactory, this method will return that FilterFactory. Otherwise it will return null.

Returns:
the FilterFactory that creates the Filter. Otherwise it will return null.

setFilterFactory

void setFilterFactory(FilterFactory filterFactory)
Sets the FilterFactory that creates this Filter.

Parameters:
filterFactory - the FilterFactory that creates this Filter.

getFilterFactoryName

String getFilterFactoryName()
Gets the FilterFactory name. If the Filter is created through a FilterFactory, this method will return that FilterFactory name. Otherwise it will return null.

Returns:
the FilterFactory name that creates the Filter. Otherwise it will return null.

setFilterFactoryName

void setFilterFactoryName(String name)
Sets the FilterFactory name that creates this Filter.

Parameters:
name - the FilterFactory that creates this Filter.

addFilterListener

void addFilterListener(FilterListener l)
Adds a listener to the list that's notified each time a change to the filter occurs.

Parameters:
l - the FilterListener

removeFilterListener

void removeFilterListener(FilterListener l)
Removes a listener from the list that's notified each time a change to the filter occurs.

Parameters:
l - the FilterListener

stricterThan

boolean stricterThan(Filter inputFilter)
Checks if this filter is stricter than the input filter. Stricter means that every data satisfying the input filter must also satisfy this filter.

Sometimes it's really hard to say if one filter is stricter than another or not. Please return true only if you are very sure and return false in any other cases. The reason to do that is, if you return incorrect false, the only hit you will get is just performance due to unnecessary filter applying. However, if you return incorrect true, the hit will be very serious that you would not get expected rows showing up.

Parameters:
inputFilter - the input filter
Returns:
true if this filter stricter than the input filter. Otherwise false.

getPreference

String getPreference(Class<?> clazz,
                     ConverterContext converterContext)
Gets the preference while persisting this filter.

Parameters:
clazz - the class type to convert the values inside the filter to string
converterContext - the converter context to convert the values inside the filter to string
Returns:
the preference string.
Since:
3.4.4

setPreference

Object[] setPreference(String prefString,
                       Class<?> clazz,
                       ConverterContext converterContext)
Sets the preference to load the preference string back to this filter.

Parameters:
prefString - the preference string
clazz - the class type to convert the values inside the filter to string
converterContext - the converter context to convert the values inside the filter to string
Returns:
the object array to be passed into the FilterFactoryManager if necessary.
Since:
3.4.4

clone

Object clone()
             throws CloneNotSupportedException
Creates and returns a copy of the filter.

Returns:
a cloned copy of the filter.
Throws:
CloneNotSupportedException - if the cloning of the filter is not supported.

JIDE 3.5.15