org.jdesktop.swingx.decorator
Class Sorter

java.lang.Object
  extended by org.jdesktop.swingx.decorator.Filter
      extended by org.jdesktop.swingx.decorator.Sorter
Direct Known Subclasses:
ShuttleSorter

public abstract class Sorter
extends Filter

Pluggable sorting filter.

Author:
Ramesh Gupta

Field Summary
 
Fields inherited from class org.jdesktop.swingx.decorator.Filter
adapter, fromPrevious, pipeline
 
Constructor Summary
Sorter()
           
Sorter(int col, boolean ascending)
           
Sorter(int col, boolean ascending, java.util.Comparator comparator)
           
 
Method Summary
protected abstract  void adopt(Sorter oldSorter)
          Adopts the row mappings of the specified sorter by cloning the mappings.
 int compare(int row1, int row2)
           
protected  java.text.Collator getCollator()
          exposed for testing only!
 java.util.Comparator getComparator()
           
 void interpose(FilterPipeline filters, ComponentAdapter adapter, Sorter oldSorter)
          Deprecated. - use filterPipeline.setSorter instead
 boolean isAscending()
           
protected  void refresh(boolean reset)
          Refreshes the internal state of the filter, optionally resetting the cache of existing row mappings from this filter to the previous filter.
protected  void refreshCollator()
          Subclasses must call this before filtering to guarantee the correct collator!
protected  void releasePipeline()
          release the old
 void setAscending(boolean ascending)
           
 void setComparator(java.util.Comparator comparator)
          set the Comparator to use when comparing values.
 void toggle()
           
 
Methods inherited from class org.jdesktop.swingx.decorator.Filter
assign, convertRowIndexToModel, convertRowIndexToView, filter, getColumnIndex, getColumnName, getInputSize, getInputValue, getPipeline, getSize, getValueAt, init, isCellEditable, mapTowardModel, mapTowardView, refresh, reset, setColumnIndex, setValueAt, translateFromPreviousFilter, translateToPreviousFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sorter

public Sorter()

Sorter

public Sorter(int col,
              boolean ascending)

Sorter

public Sorter(int col,
              boolean ascending,
              java.util.Comparator comparator)
Method Detail

refresh

protected void refresh(boolean reset)
Description copied from class: Filter
Refreshes the internal state of the filter, optionally resetting the cache of existing row mappings from this filter to the previous filter. Always performs the filter operation and regenerates row mappings from the previous filter. If this filter is bound to a filter pipeline (as most filters are), it also triggers a filterChanged notification.

Overrides:
refresh in class Filter
Parameters:
reset - true if existing row mappings from this filter to the previous filter should be reset; false, if the existing row mappings should be preserved.

refreshCollator

protected void refreshCollator()
Subclasses must call this before filtering to guarantee the correct collator!


getCollator

protected java.text.Collator getCollator()
exposed for testing only!

Returns:

setComparator

public void setComparator(java.util.Comparator comparator)
set the Comparator to use when comparing values. If not null every compare will be delegated to it. If null the compare will follow the internal compare (no contract, but implemented here as: first check if the values are Comparable, if so delegate, then compare the String representation)

Parameters:
comparator -

getComparator

public java.util.Comparator getComparator()

adopt

protected abstract void adopt(Sorter oldSorter)
Adopts the row mappings of the specified sorter by cloning the mappings.

Parameters:
oldSorter - Sorter whose mappings are to be cloned

interpose

public void interpose(FilterPipeline filters,
                      ComponentAdapter adapter,
                      Sorter oldSorter)
Deprecated. - use filterPipeline.setSorter instead

Interposes this sorter between a filter pipeline and the component that the pipeline is bound to, replacing oldSorter as the previously interposed sorter. You should not have to call this method directly.

Parameters:
filters -
adapter -
oldSorter -

releasePipeline

protected void releasePipeline()
release the old


compare

public int compare(int row1,
                   int row2)

isAscending

public boolean isAscending()

setAscending

public void setAscending(boolean ascending)

toggle

public void toggle()


Copyright © 2005 Sun Microsystems All Rights Reserved.