com.sun.data.provider.impl
Class BasicTableDataFilter

java.lang.Object
  extended by com.sun.data.provider.impl.BasicTableDataFilter
All Implemented Interfaces:
TableDataFilter

public class BasicTableDataFilter
extends java.lang.Object
implements TableDataFilter

This basic implementation of TableDataFilter iterates rows and the contained FilterCriteria and invokes the match() method on each. If the matchAllCriteria property is set to true, then all of the filter criteria must report either a positive match for an include criteria, or a negative match for an exclude criteria for a row to be accepted by the filter. If the matchAllCriteria property is set to false (match any), then any include criteria that matches a row or exclude criteria that does not match a row will cause the row to be accepted by the filter. If there is no filter criteria defined, all rows will be accepted.


Field Summary
protected  FilterCriteria[] filterCriteria
          storage for the filter criteria
protected  boolean matchAll
          storage for the matchAllCriteria property (default is true)
 
Constructor Summary
BasicTableDataFilter()
           
 
Method Summary
 RowKey[] filter(TableDataProvider provider, RowKey[] rows)
          This method iterates the passed rows and contained FilterCriteria and invokes the match() method on each.
 FilterCriteria[] getFilterCriteria()
          

Returns the current filter criteria on this data filterer.

 boolean isMatchAllCriteria()
          Gets the matchAllCriteria property.
 void setFilterCriteria(FilterCriteria[] filterCriteria)
          

Sets the filter criteria on this data filter.

 void setMatchAllCriteria(boolean matchAll)
          Sets the matchAllCriteria property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filterCriteria

protected FilterCriteria[] filterCriteria
storage for the filter criteria


matchAll

protected boolean matchAll
storage for the matchAllCriteria property (default is true)

Constructor Detail

BasicTableDataFilter

public BasicTableDataFilter()
Method Detail

setFilterCriteria

public void setFilterCriteria(FilterCriteria[] filterCriteria)

Sets the filter criteria on this data filter.

Specified by:
setFilterCriteria in interface TableDataFilter
Parameters:
filterCriteria - An array of FilterCriteria objects defining the filter order on this TableDataFilter

getFilterCriteria

public FilterCriteria[] getFilterCriteria()

Returns the current filter criteria on this data filterer.

Specified by:
getFilterCriteria in interface TableDataFilter
Returns:
FilterCriteria[] defining the filter order on this TableDataFilter

setMatchAllCriteria

public void setMatchAllCriteria(boolean matchAll)

Sets the matchAllCriteria property. When set to true, the accept(...) method to only accept rows that are matched by all include filter criteria and not mached by all exclude filter criteria. When set to false, the accept(...) method will accept an row if it is matched by any include filter criteria or not matched by any exclude filter criteria.

Parameters:
matchAll - The desired setting for the matchAllCriteria property

isMatchAllCriteria

public boolean isMatchAllCriteria()

Gets the matchAllCriteria property. When set to true, the accept(...) method to only accept rows that are matched by all include filter criteria and not mached by all exclude filter criteria. When set to false, the accept(...) method will accept an row if it is matched by any include filter criteria or not matched by any exclude filter criteria.

Returns:
The current setting for the matchAllCriteria property

filter

public RowKey[] filter(TableDataProvider provider,
                       RowKey[] rows)
                throws DataProviderException

This method iterates the passed rows and contained FilterCriteria and invokes the match() method on each. If the matchAllCriteria property is set to true, then all of the include filter criteria must match a row, and all of the exclude filter criteria must not match a row for that row to be accepted by the filter. If the matchAllCriteria property is set to false (match any), then any include criteria that matches a row or exclude criteria that does not match a row will cause that row to be excluded. If there is no filter criteria defined, then this method returns the passed-in rows, effectively accepting all rows.

Performs a filter operation on the passed set of RowKey objects. Typically, the contained FilterCriteria objects will be iterated for each row and their match(...) method will be called in conjunction with their isInclude() method to determine if a row should be displayed or not.

NOTE: If a component is bound to an TableDataProvider and an TableDataFilter, which are the *same* instance, this method is never called. The filter is assumed to be intrinsic in the row data of the TableDataProvider, based on the currently set filter criteria.

Specified by:
filter in interface TableDataFilter
Parameters:
provider - TableDataProvider containing the data on display
rows - An array of RowKey to be filtered. If this is null, then the return value should be null or an empty array of RowKeys.
Returns:
An array of RowKey representing the result of the filter operation
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 RowKeys are not valid. Consult the documentation of the specific TableDataFilter implementation for details on what exceptions might be wrapped by a DPE.