package com.onaro.util.jfc;
import com.onaro.util.jfc.tables.SortingInfo;
import javax.swing.table.TableModel;
import javax.swing.event.*;
import java.io.Serializable;
import java.text.Collator;
import java.util.Arrays;
import java.util.Comparator;
import java.util.EventListener;
public class SortedTableModel implements TableModel, TableModelListener, SortingInfo {
/**
* The table model that is wrapped by this one and provide the actual model's
* DATA.
*/
private TableModel sourceModel;
/**
* List of listeners which are notified whenever the source table model changes
* or the sorting has changed.
*/
protected EventListenerList listenerList = new EventListenerList();
/**
* Sorting column number to eliminate all sorting.
*/
public final static int NO_SORTING_COLUMN = -1;
/**
* The column number by which the table is sorted.
*/
private int sortingColumn = NO_SORTING_COLUMN;
/**
* When
*/
public final int BEFORE_SORTING = 1;
/**
* Ascending sort direction.
*/
private boolean ascending = true;
/**
* Maps sorted row numbers to rows in the source model. The index is
* the index in this sorted model and the value contains the index in the
* source model and the value of the sorting column at that row.
* Cells beyod the table's last row contain null.
*/
private MapEntry mapToSource[];
/**
* Compares the values of two map entries ({@link MapEntry}).
*/
private MapEntryComparator mapEntryComparator = new MapEntryComparator();
/**
* Compare two values. The mapEntryComparator delegates the
* values to this comparator.
*/
private Comparator