JIDE 3.5.15

com.jidesoft.pivot
Interface PivotDataSource

All Known Implementing Classes:
TableModelPivotDataSource

public interface PivotDataSource

By default, PivotDataModel takes TableModel as the data source. By providing this interface, it is possible to use any compatible data as the data source for PivotDataModel. PivotDataSource also provides methods related to filtering. If you use this interface, you can totally skip the FilterableTableModel we used internally in PivotDataModel. If you can provide a more efficient filtering engine to implement this interface in the right way, it could make the pivot table faster.


Method Summary
 void addTableModelListener(TableModelListener listener)
          Adds the table model listener.
 void applyFilters()
          Tells the data source to apply the filters after all filters have been set using setFilter(Object[],int,boolean) method.
 void applyFilters(int[] rowFieldIndices, int[] columnFieldIndices, int[] dataFieldIndices, int[] filterFieldIndices)
          Tells the data source to apply the filters after all filters have been set using setFilter(Object[],int,boolean) method.
 void clearFilters()
          Tells the data source to clear all existing filters so that we can start to use setFilter(Object[],int,boolean) method to set the filters.
 int getActualRowIndex(int visualRowIndex)
          Gets the actual row index in the original table model.
 int getFieldCount()
          Gets number of fields in this data source.
 String getFieldName(int fieldIndex)
          Gets the field name.
 String getFieldTitle(int fieldIndex)
          Gets the field title.
 Class<?> getFieldType(int fieldIndex)
          Gets the field type.
 int getFilteredRowIndex(int actualRowIndex)
          Gets the row index after filtering so that we can use getValueAt(int,int) or setValueAt(Object,int,int) methods.
 Set<Object> getPossibleValues(int fieldIndex, boolean filterField, boolean isNullAllowed)
          Gets the possible values for the field.
 int getRowCount()
          Gets the row count.
 Object getValueAt(int rowIndex, int fieldIndex)
          Gets the value at the specified field index and the row index.
 boolean hasFilter()
          Get if the data source has filter applying on it.
 void removeTableModelListener(TableModelListener listener)
          Removes the table model listener that was added earlier.
 void setExcludeFilter(Object[] values, int fieldIndex, boolean filterField)
          Sets the deselected possible values for the field.
 void setFilter(Filter filter, int fieldIndex, boolean filterField)
          Sets the Filter for the field.
 void setFilter(Object[] values, int fieldIndex, boolean filterField)
          Sets the possible values for the field.
 void setValueAt(Object value, int rowIndex, int fieldIndex)
          Gets the value at the specified field index and the row index.
 

Method Detail

getFieldCount

int getFieldCount()
Gets number of fields in this data source.

Returns:
the field count.

getFieldName

String getFieldName(int fieldIndex)
Gets the field name. The name should be unique in this data source.

Parameters:
fieldIndex - the field index.
Returns:
the field name.

getFieldTitle

String getFieldTitle(int fieldIndex)
Gets the field title.

Parameters:
fieldIndex - the field index.
Returns:
the title of the field.
Since:
3.2.4

getFieldType

Class<?> getFieldType(int fieldIndex)
Gets the field type.

Parameters:
fieldIndex - the field index.
Returns:
the field type.

getRowCount

int getRowCount()
Gets the row count. If there is filtering, it should return the row count after filtering.

Returns:
the row count.

getValueAt

Object getValueAt(int rowIndex,
                  int fieldIndex)
Gets the value at the specified field index and the row index.

Parameters:
rowIndex - the row index. It is the index after filtering.
fieldIndex - the field index.
Returns:
the value.

setValueAt

void setValueAt(Object value,
                int rowIndex,
                int fieldIndex)
Gets the value at the specified field index and the row index.

Parameters:
value - the new value.
fieldIndex - the field index.
rowIndex - the row index. It is the index after filtering.

getPossibleValues

Set<Object> getPossibleValues(int fieldIndex,
                              boolean filterField,
                              boolean isNullAllowed)
Gets the possible values for the field.

Parameters:
fieldIndex - the field index.
filterField - whether the field is a filter field. If true, possible values will all values as in the original data source. If false, the rows will be filtered first based on the setFilter(Object[],int,boolean) and then collect all the possible values.
isNullAllowed - whether null value is allowed.
Returns:
the possible values.

clearFilters

void clearFilters()
Tells the data source to clear all existing filters so that we can start to use setFilter(Object[],int,boolean) method to set the filters.


hasFilter

boolean hasFilter()
Get if the data source has filter applying on it.

Returns:
true if there are filters. Otherwise false.

setFilter

void setFilter(Object[] values,
               int fieldIndex,
               boolean filterField)
Sets the possible values for the field.

Parameters:
values - the possible values.
filterField - whether the field is a filter field.
fieldIndex - the field index.

setExcludeFilter

void setExcludeFilter(Object[] values,
                      int fieldIndex,
                      boolean filterField)
Sets the deselected possible values for the field.

Parameters:
values - the deselected possible values.
filterField - whether the field is a filter field.
fieldIndex - the field index.

setFilter

void setFilter(Filter filter,
               int fieldIndex,
               boolean filterField)
Sets the Filter for the field.

Parameters:
filter - the Filter.
filterField - whether the field is a filter field.
fieldIndex - the field index.

applyFilters

void applyFilters(int[] rowFieldIndices,
                  int[] columnFieldIndices,
                  int[] dataFieldIndices,
                  int[] filterFieldIndices)
Tells the data source to apply the filters after all filters have been set using setFilter(Object[],int,boolean) method. This method tells you the field indices of each area. In TableModelPivotDataSource implementation, we simply call applyFilters() as that implementation doesn't need to know the field indices.

Parameters:
rowFieldIndices - the field indices for row fields.
columnFieldIndices - the field indices for column fields.
dataFieldIndices - the field indices for data fields.
filterFieldIndices - the field indices for filter fields.

applyFilters

void applyFilters()
Tells the data source to apply the filters after all filters have been set using setFilter(Object[],int,boolean) method. If you need to know the field indices of each area, you can override other applyFilters method with four int[] parameters.


getFilteredRowIndex

int getFilteredRowIndex(int actualRowIndex)
Gets the row index after filtering so that we can use getValueAt(int,int) or setValueAt(Object,int,int) methods.

Parameters:
actualRowIndex - the actual row index.
Returns:
the filtered row index. -1 of the row is filtered.

getActualRowIndex

int getActualRowIndex(int visualRowIndex)
Gets the actual row index in the original table model. You can use this to get the actual index based on the visual row index you got in PivotDataModel.getDataAt(int, int) method.

Parameters:
visualRowIndex - the visual row index.
Returns:
the actual row index. -1 of the row is filtered.

addTableModelListener

void addTableModelListener(TableModelListener listener)
Adds the table model listener. Although there is no table model concept in the data source, TableModelEvent can still be used to indicate data change in the data source. Please note, the row index is the index as in the original data without filtering. When you fire the table model event, you can leave the source of it to null.

Parameters:
listener - the table model listener to be added.

removeTableModelListener

void removeTableModelListener(TableModelListener listener)
Removes the table model listener that was added earlier.

Parameters:
listener - the table model listener to be removed.

JIDE 3.5.15