JIDE 3.5.15

com.jidesoft.filter
Class InFilter<T>

java.lang.Object
  extended by com.jidesoft.filter.AbstractFilter<T>
      extended by com.jidesoft.filter.InFilter<T>
All Implemented Interfaces:
Filter<T>, ObjectGrouperSupport, SqlFilterSupport, Serializable, Cloneable
Direct Known Subclasses:
NotInFilter

public class InFilter<T>
extends AbstractFilter<T>
implements SqlFilterSupport

A Filter returns false in isValueFiltered(Object) only if the input value is in a collection of the specified values.

Please note, for numbers, as long as the numbers have the same value, they are considered as equal. For example 20.0 == 20 even though they are double and int respectively. In the other word, new InFilter(new Object[]{20.0}).isValueFilter(20) returns false.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.jidesoft.filter.Filter
ALL, CUSTOM, NULL, SEPARATOR
 
Constructor Summary
InFilter()
          Creates an InFilter.
InFilter(String name, T[] values)
          Creates MultipleValuesFilter.
InFilter(T[] values)
          Creates an InFilter.
 
Method Summary
 boolean equals(Object obj)
           
 String getName()
          Gets the name of the filter.
 String getOperator()
          Gets the operator.
 String getPreference(Class<?> clazz, ConverterContext converterContext)
          Gets the preference while persisting this filter.
 T[] getValues()
          Gets the only allowed value.
 boolean isFilterValid()
          Checks if the filter is valid or not.
 boolean isValueFiltered(T value)
          Checks to see if the value should be filtered.
 Object[] setPreference(String prefString, Class<?> clazz, ConverterContext converterContext)
          Sets the preference to load the preference string back to this filter.
 void setValues(T[] values)
          Sets the allowed values.
 boolean stricterThan(Filter inputFilter)
          Check if this filter is stricter than the input filter while the two filters are with the same class.
 
Methods inherited from class com.jidesoft.filter.AbstractFilter
addFilterListener, clone, fireFilterChanged, fireFilterContentChanged, fireFilterDisabled, fireFilterEnabled, fireFilterNameChanged, getConditionString, getFilterFactory, getFilterFactoryName, getFilterListeners, getObjectGrouper, getObjectGrouperName, isEnabled, removeFilterListener, setEnabled, setFilterFactory, setFilterFactoryName, setName, setObjectGrouper, setObjectGrouperName
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InFilter

public InFilter()
Creates an InFilter.


InFilter

public InFilter(T[] values)
Creates an InFilter.

Parameters:
values - the values that will not be filtered

InFilter

public InFilter(String name,
                T[] values)
Creates MultipleValuesFilter.

Parameters:
name - name of the filter
values - the values that will not be filtered
Method Detail

isValueFiltered

public boolean isValueFiltered(T value)
Description copied from interface: Filter
Checks to see if the value should be filtered.

Specified by:
isValueFiltered in interface Filter<T>
Parameters:
value - the value to filter
Returns:
true if the value should be filtered. Otherwise false.

setValues

public void setValues(T[] values)
Sets the allowed values.

Parameters:
values - the allowed values.

getValues

public T[] getValues()
Gets the only allowed value.

Returns:
the only allowed value.

getOperator

public String getOperator()
Gets the operator. It will return " IN " by default.

Specified by:
getOperator in interface SqlFilterSupport
Returns:
the operator.

getName

public String getName()
Description copied from interface: Filter
Gets the name of the filter.

Specified by:
getName in interface Filter<T>
Overrides:
getName in class AbstractFilter<T>
Returns:
the name of the filter.

stricterThan

public boolean stricterThan(Filter inputFilter)
Check if this filter is stricter than the input filter while the two filters are with the same class.

Specified by:
stricterThan in interface Filter<T>
Overrides:
stricterThan in class AbstractFilter<T>
Parameters:
inputFilter - the input filter
Returns:
true if all the possible values contained in this filter are also contained in the input filter. Otherwise false.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getPreference

public String getPreference(Class<?> clazz,
                            ConverterContext converterContext)
Description copied from interface: Filter
Gets the preference while persisting this filter.

Specified by:
getPreference in interface Filter<T>
Overrides:
getPreference in class AbstractFilter<T>
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.

setPreference

public Object[] setPreference(String prefString,
                              Class<?> clazz,
                              ConverterContext converterContext)
Description copied from interface: Filter
Sets the preference to load the preference string back to this filter.

Specified by:
setPreference in interface Filter<T>
Overrides:
setPreference in class AbstractFilter<T>
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.

isFilterValid

public boolean isFilterValid()
Description copied from class: AbstractFilter
Checks if the filter is valid or not. By default, it just returns true simply. This method will help determine if the filter loaded from a string by invoking AbstractFilter.setPreference(String, Class, com.jidesoft.converter.ConverterContext) is valid or not.

Overrides:
isFilterValid in class AbstractFilter<T>
Returns:
true by default.

JIDE 3.5.15