com.sun.data.provider.impl
Class CompareFilterCriteria

java.lang.Object
  extended by com.sun.data.provider.FilterCriteria
      extended by com.sun.data.provider.impl.CompareFilterCriteria
All Implemented Interfaces:
java.io.Serializable

public class CompareFilterCriteria
extends FilterCriteria

The CompareFilterCriteria is an implementation of FilterCriteria that compares the value of a FieldKey in a TableDataProvider with a predefined compareValue. A user may specify matches to include less than (<), equal to (==), or greater than (>) the compareValue Object, or any combination of the above.

See Also:
TableDataProvider, TableDataFilter, Serialized Form

Field Summary
protected  java.util.Locale compareLocale
          Storage for the compare locale
protected  boolean matchEqualTo
           
protected  boolean matchGreaterThan
           
protected  boolean matchLessThan
           
 
Constructor Summary
CompareFilterCriteria()
           
CompareFilterCriteria(FieldKey fieldKey)
           
CompareFilterCriteria(FieldKey fieldKey, java.lang.Object compareValue)
           
CompareFilterCriteria(FieldKey fieldKey, java.lang.Object compareValue, boolean matchLessThan, boolean matchEqualTo, boolean matchGreaterThan)
           
CompareFilterCriteria(java.lang.Object compareValue)
           
 
Method Summary
static int compare(java.lang.Object o1, java.lang.Object o2, java.util.Locale compareLocale)
           
 java.util.Locale getCompareLocale()
           
 java.lang.Object getCompareValue()
           
 java.lang.String getDisplayName()
          Returns the display name for this filter criteria.
 FieldKey getFieldKey()
           
 boolean isMatchEqualTo()
           
 boolean isMatchGreaterThan()
           
 boolean isMatchLessThan()
           
 boolean match(TableDataProvider provider, RowKey row)
          This method tests a match by comparing the compareValue and the data value stored under the FieldKey at the specified row.
 void setCompareLocale(java.util.Locale compareLocale)
           
 void setCompareValue(java.lang.Object value)
           
 void setFieldKey(FieldKey fieldKey)
           
 void setMatchEqualTo(boolean matchEqualTo)
           
 void setMatchGreaterThan(boolean matchGreaterThan)
           
 void setMatchLessThan(boolean matchLessThan)
           
 
Methods inherited from class com.sun.data.provider.FilterCriteria
isInclude, setDisplayName, setInclude
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compareLocale

protected java.util.Locale compareLocale
Storage for the compare locale


matchEqualTo

protected boolean matchEqualTo

matchLessThan

protected boolean matchLessThan

matchGreaterThan

protected boolean matchGreaterThan
Constructor Detail

CompareFilterCriteria

public CompareFilterCriteria()

CompareFilterCriteria

public CompareFilterCriteria(FieldKey fieldKey)
Parameters:
fieldKey - FieldKey

CompareFilterCriteria

public CompareFilterCriteria(java.lang.Object compareValue)
Parameters:
compareValue - The desired compare value

CompareFilterCriteria

public CompareFilterCriteria(FieldKey fieldKey,
                             java.lang.Object compareValue)
Parameters:
fieldKey - FieldKey
compareValue - The desired compare value

CompareFilterCriteria

public CompareFilterCriteria(FieldKey fieldKey,
                             java.lang.Object compareValue,
                             boolean matchLessThan,
                             boolean matchEqualTo,
                             boolean matchGreaterThan)
Parameters:
fieldKey - FieldKey
compareValue - Object
matchLessThan - boolean
matchEqualTo - boolean
matchGreaterThan - boolean
Method Detail

getDisplayName

public java.lang.String getDisplayName()
Description copied from class: FilterCriteria

Returns the display name for this filter criteria.

Overrides:
getDisplayName in class FilterCriteria
Returns:
The display name of this filter criteria

setFieldKey

public void setFieldKey(FieldKey fieldKey)
Parameters:
fieldKey - FieldKey

getFieldKey

public FieldKey getFieldKey()
Returns:
FieldKey

setCompareValue

public void setCompareValue(java.lang.Object value)
Parameters:
value - Object

getCompareValue

public java.lang.Object getCompareValue()
Returns:
Object

setCompareLocale

public void setCompareLocale(java.util.Locale compareLocale)
Parameters:
compareLocale - Locale

getCompareLocale

public java.util.Locale getCompareLocale()
Returns:
Locale

setMatchEqualTo

public void setMatchEqualTo(boolean matchEqualTo)
Parameters:
matchEqualTo - boolean

isMatchEqualTo

public boolean isMatchEqualTo()
Returns:
boolean

setMatchLessThan

public void setMatchLessThan(boolean matchLessThan)
Parameters:
matchLessThan - boolean

isMatchLessThan

public boolean isMatchLessThan()
Returns:
boolean

setMatchGreaterThan

public void setMatchGreaterThan(boolean matchGreaterThan)
Parameters:
matchGreaterThan - boolean

isMatchGreaterThan

public boolean isMatchGreaterThan()
Returns:
boolean

match

public boolean match(TableDataProvider provider,
                     RowKey row)
              throws DataProviderException

This method tests a match by comparing the compareValue and the data value stored under the FieldKey at the specified row. The matchLessThan, matchEqualTo, and matchGreaterThan properties are used to determine if a match was found. The compareLocale is used for String comparisons.

Determines wether or not a particular row matches this filter criteria. Implementations may perform whatever logic is desired to make this determination. The combination of a positive match and the state of the include property determines if a row is included or excluded from the filter.

Specified by:
match in class FilterCriteria
Parameters:
provider - TableDataProvider containing the data on display
row - The RowKey of the data to be checked for a match
Returns:
true if a match was detected, or false if not.
Throws:
DataProviderException - Implementations may wish to surface internal exceptions (nested in DataProviderException) rather than simply returning null. A DPE may also indicate that the passed TableDataProvider or RowKey is not valid. Consult the documentation of the specific FilterCriteria implementation for details on what exceptions might be wrapped by a DPE.

compare

public static int compare(java.lang.Object o1,
                          java.lang.Object o2,
                          java.util.Locale compareLocale)