|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.models.SimpleTable
public class SimpleTable
SimpleTable manages any two-dimensional data where all the columns are of uniform type. It implements the two-dimensional data interfaces which define access and updates to the data.
SimpleTable defines row template style data, where the set of column classes defines a template, or signature, for each of the rows. All cells within a column are assumed to be of uniform type.
The SimpleTable model is designed for simple definition of two-dimensional data. The data is stored in memory within the model, and has nothing to do with data sets. To manage two-dimensional data within a dataset, use the DataSetInterface class.
To use the SimpleTable model, simply start defining columns and adding rows with the appropriate data.
Creating a SimpleTable modelThe following example creates a model with weather information for each day of the week.
// Make an instance of the SimpleTable object SimpleTable weather = new SimpleTable(); weather.initialize();
// Define the columns for the model // Add the column for the daily forecast weather.addColumn(1, java.lang.String.class, null); weather.setColumnLabel(1, "Forecast"); // Add the column for the temperature weather.addColumn(2, java.lang.Double.class, null); weather.setColumnLabel(2, "High temperature"); // Add the rows for Friday, Saturday, and Sunday // Add a row using the addRow and setCell methods weather.addRow(1); weather.setRowLabel(1, "Friday"); weather.setCell(1, 1, "Sunny"); weather.setCell(1, 2, new Double(76.2)); // Add a row using the addRow method with cell arguments Object[] saturday = new Object[2]; saturday[0] = "Cloudy"; saturday[1] = new Double(56.7); weather.addRow(2, saturday); weather.setRowLabel(2, "Saturday"); // Add a row using the addRow and setRow methods Object[] sunday = new Object[2]; sunday[0] = "Stormy"; sunday[1] = new Double(52.3); weather.addRow(3); weather.setRowLabel(3, "Sunday"); weather.setRow(3, sunday);
Rocf,
DataSetInterface,
Serialized Form| Field Summary | |
|---|---|
protected com.sas.collection.ContentsChangedListenerList |
allContentsChangedListeners
allContentsChangedListeners is a list of listeners for the com.sas.util.ContentsChangedEvent event. |
protected boolean |
columnLabelsSupported
Whether or not column labels are supported |
protected java.lang.Object |
columnsLabel
The columns label |
protected boolean |
columnsLabelSupported
Whether or not the columns label is supported |
protected boolean |
rowLabelsSupported
Whether or not row labels are supported |
protected java.lang.Object |
rowsLabel
The rows label |
protected boolean |
rowsLabelSupported
Whether or not the rows label is supported |
| Fields inherited from interface com.sas.table.RowTemplateTableInterface |
|---|
DEFAULT_INDEX |
| Constructor Summary | |
|---|---|
SimpleTable()
Default constructor, creates an empty table (no rows, no columns). |
|
SimpleTable(DataTableInterface table)
Construct a SimpleTable using an existing table |
|
SimpleTable(DataTableInterface table,
java.util.Comparator[] comparators)
Construct a sortable SimpleTable using an existing table. |
|
SimpleTable(DataTableInterface table,
int startRow,
int endRow,
int startCol,
int endCol)
Construct a SimpleTable using an existing table with the specified rows and columns |
|
SimpleTable(DataTableInterface table,
int startRowIndex,
int endRowIndex,
int startCol,
int endCol,
java.util.Comparator[] comparators)
Construct a sortable SimpleTable using an existing table with the specified rows and columns |
|
SimpleTable(int numRows,
int numColumns)
Construct a SimpleTable with an initial number of rows and columns. |
|
SimpleTable(int numRows,
int numColumns,
java.util.Comparator[] comparators)
Construct a SimpleTable with an initial number of rows and columns. |
|
| Method Summary | |
|---|---|
void |
addColumn(int columnIndex)
Add a default column at columnIndex The column type will be Object and the default value will be null. |
void |
addColumn(int columnIndex,
java.lang.Class type,
java.lang.Object defaultValue)
The specified default value will be used to set the value of every cell in the new column. |
void |
addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
Add a listener for the com.sas.util.ContentsChangedEvent event. |
void |
addRow(int rowIndex)
The row will be filled in with the default values for each column. |
void |
addRow(int rowIndex,
java.lang.Object[] values)
Adds a row. |
protected boolean |
anyContentsChangedListeners()
Test is there is any registered event listener for a ContentsChangedEvent, or any registered PropertyChangeEvent. |
protected int |
calculateTotalColumns(DataTableInterface dti)
Calculate the total number of columns in the data table |
protected int |
calculateTotalRows(DataTableInterface dti)
Calculate the total number of rows in the data table |
java.lang.Object |
clone()
Clone the simple table object |
int |
countColumns(int maxColumnCount)
This model does not handle the maxColumnCount argument and will always return getColumnCount() |
int |
countRows(int maxRowCount)
This model does not handle the maxRowCount argument and will always return getRowCount() |
void |
deleteAllColumns()
deleteAllColumns is a convenience method which deletes all the column definitions in the table. |
void |
deleteAllRows()
deleteAllRows is a convenience method which deletes all the rows in the table. |
void |
deleteColumn(int columnIndex)
Deleting the column will delete any associated column labels as well. |
void |
deleteRow(int rowIndex)
Deleting the row will delete any associated row labels as well. |
void |
deleteRows(boolean[] delete)
Delete rows between startRowIndex and endRowIndex as indicated in a vector of flags. |
void |
disableEvents()
Suspends sending of ContentsChangedEvent, which otherwise would be sent on every update method call, such as setCell or addColumn. |
void |
enableEvents()
Resumes sending of ContentsChangedEvent, which otherwise would be sent on every update method call, such as setCell or addColumn. |
protected void |
enableEvents(com.sas.collection.ContentsChangedEvent e)
Resumes sending of ContentsChangedEvent, which otherwise would be sent on every update method call, such as setCell or addColumn. |
boolean |
equals(java.lang.Object o)
implementation of Object.equals(Object). |
boolean |
equals(SimpleTable table)
Compare this SimpleTable to another SimpleTable |
protected void |
fireContentsChanged()
Fire a default contents changed event. |
protected void |
fireContentsChanged(com.sas.collection.ContentsChangedEvent event)
Send a ContentsChangedEvent event to all the ContentsChangedListener objects in the listener list. |
java.lang.Object |
getCell(int rowIndex,
int columnIndex)
Returns the value of a cell. |
static java.lang.Object |
getCell(java.lang.Object row,
int columnIndex)
Extracts the desired cell from a table row using This static method should be used for row based comparators (for either sorting or removing duplicates). |
java.lang.Class |
getCellClass(int rowIndex,
int columnIndex)
Returns the specific class for each individual cell. |
java.lang.Class[][] |
getCellClasses(int startRowIndex,
int startColumnIndex,
int rowCount,
int columnCount)
Returns the classes for a block of cells. |
java.lang.Object[][] |
getCells(int startRowIndex,
int startColumnIndex,
int rowCount,
int columnCount)
Returns the values for a block of cells. |
StaticPropertyBagInterface |
getCellStyle(int rowIndex,
int colIndex)
Throws an exception since SimpleTable does not support styles on a per-cell basis at this time. |
java.lang.Object[] |
getColumn(int columnIndex)
Returns the values of all the cells in a column. |
java.lang.Class |
getColumnClass(int columnIndex)
Returns the class of a column. |
java.lang.Class[] |
getColumnClasses()
|
java.lang.Class[] |
getColumnClasses(int startColumnIndex,
int columnCount)
Returns the classes for a range of columns. |
java.util.Comparator |
getColumnComparator(int columnIndex)
Return the comparator associated with this column. |
int |
getColumnCount()
Returns the number of columns available. |
java.lang.Object |
getColumnDefaultValue(int columnIndex)
Returns the default value associated with a column. |
java.lang.Object[] |
getColumnDefaultValues(int startColumnIndex,
int columnCount)
Returns the default values associated with a range of columns. |
java.lang.Object |
getColumnLabel(int columnIndex)
Returns the label for a column. |
java.lang.Object[] |
getColumnLabels(int startColumnIndex,
int columnCount)
Returns the labels for a range of columns. |
StaticPropertyBagInterface |
getColumnLabelStyle(int colIndex)
Throws an exception since SimpleTable does not support styles on a per-column-label basis at this time. |
StaticPropertyBagInterface |
getColumnStyle(int colIndex)
Throws an exception since SimpleTable does not support styles on a per-column basis at this time. |
StaticPropertyBagInterface |
getDefaultCellStyle()
Returns the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for cells. |
StaticPropertyBagInterface |
getDefaultColumnStyle()
Returns the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for columns. |
StaticPropertyBagInterface |
getDefaultLabelStyle()
Returns the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for labels. |
StaticPropertyBagInterface |
getDefaultRowStyle()
Returns the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for rows. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
|
java.lang.Object[] |
getRow(int rowIndex)
Returns the values of all the cells in a row. |
int |
getRowCount()
Returns the number of rows available. |
java.lang.Object |
getRowLabel(int rowIndex)
|
java.lang.Object[] |
getRowLabels(int startRowIndex,
int rowCount)
|
StaticPropertyBagInterface |
getRowLabelStyle(int rowIndex)
Throws an exception since SimpleTable does not support styles on a per-row-label basis at this time. |
StaticPropertyBagInterface |
getRowStyle(int rowIndex)
Throws an exception since SimpleTable does not support styles on a per-row basis at this time. |
boolean |
isCellsModifiable()
In this model, the cells are always modifiable, so this method always returns true. |
boolean |
isCellStylesSupported()
Returns false since SimpleTable does not support styles
a per-cell basis at this time. |
boolean |
isColumnLabelsModifiable()
Indicates whether column labels can be modified. |
boolean |
isColumnLabelsSupported()
Indicates whether getColumnLabel() and getColumnLabels() should be called. |
boolean |
isColumnLabelStylesSupported()
Returns false since SimpleTable does not support styles
a per-column-label basis at this time. |
boolean |
isColumnsDeletable()
In this model, the columns can always be deleted, so this method will always return true. |
boolean |
isColumnsExtendable()
In this model, the columns list can always be extended, so this method will always return true. |
boolean |
isColumnsInsertable()
In this model, new columns can always be inserted, so this method will always return true. |
boolean |
isColumnsLabelSupported()
Indicates whether there is support for a column labels label, i.e. a label for the set of column labels taken as a whole. |
boolean |
isColumnsRedefinable()
In this model, column types can always be redefined, so this method will always return true. |
boolean |
isColumnStylesSupported()
Returns false since SimpleTable does not support styles
a per-column basis at this time. |
boolean |
isMultipleColumnUpdateSupported()
In this model, multiple column update is always supported, so this method always returns true. |
boolean |
isMultipleRowUpdateSupported()
In this model, multiple row update is always supported, so this method always returns true. |
boolean |
isRowLabelsModifiable()
Indicates whether row labels can be modified. |
boolean |
isRowLabelsSupported()
|
boolean |
isRowLabelStylesSupported()
Returns false since SimpleTable does not support styles
a per-row-label basis at this time. |
boolean |
isRowsDeletable()
In this model, rows can always be deleted, so this method will always return true. |
boolean |
isRowsExtendable()
In this model, the rows list can always be extended, so this method will always return true. |
boolean |
isRowsInsertable()
In this model, new rows can always be inserted, so this method will always return true. |
boolean |
isRowsLabelSupported()
|
boolean |
isRowStylesSupported()
Returns false since SimpleTable does not support styles
a per-row basis at this time. |
protected java.util.Comparator |
newColumnComparator(int col,
java.util.Comparator comparator)
Returns the column comparator for the column col or if it is null, return ConstantComparator.COMPARE_EQUALS |
java.util.Comparator |
newCompositeComparator(int[] columnIndices,
java.util.Comparator[] comparators)
Return a CompositeComparator that compares using
the comparators or, if any element of comparators column comparators
is null, the corresponding column comparator. |
protected java.util.Comparator |
newRowComparator()
|
int |
normalizeEndRow(int rowNumber)
|
int |
normalizeStartRow(int rowNumber)
|
void |
permute(int[] permutation)
Permute a table according to a permutation array. |
void |
populate(DataTableInterface dti)
Populate a SimpleTable using an existing table. |
protected void |
populate(DataTableInterface dti,
boolean defineColumns)
Populate a SimpleTable using an existing table |
void |
populate(DataTableInterface dti,
boolean defineColumns,
int startRow,
int endRow,
int startCol,
int endCol)
Populate a SimpleTable using an existing table with the specified row and column parameters |
void |
populate(DataTableInterface dti,
int startCol,
int endCol)
Populate a SimpleTable using an existing table with the specified column parameters |
void |
removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
Remove a listener for the com.sas.util.ContentsChangedEvent event. |
void |
removeDuplicates(java.util.Comparator comparator)
Remove duplicates from a sorted table, based on comparing the row contents. |
void |
removeDuplicates(java.util.Comparator comparator,
int startRowIndex,
int endRowIndex,
boolean keepFirst,
boolean[] removed)
Remove duplicates from a sorted table, based on comparing the row contents. |
void |
removeDuplicates(int[] columnIndices,
java.util.Comparator[] comparators)
Remove duplicates from a sorted table, based on comparing cell contents from multiple columns. |
void |
removeDuplicates(int[] columnIndices,
java.util.Comparator[] comparators,
int startRowIndex,
int endRowIndex,
boolean keepFirst,
boolean[] removed)
Remove duplicates from a sorted table, based on comparing cell contents from multiple columns. |
void |
removeDuplicates(int columnIndex,
java.util.Comparator comparator)
Remove duplicates from a sorted table, based on comparing cell contents from a single column. |
void |
removeDuplicates(int columnIndex,
java.util.Comparator comparator,
int startRowIndex,
int endRowIndex,
boolean keepFirst,
boolean[] removed)
Remove duplicates from a sorted table, based on comparing cell contents from a single column. |
protected void |
removeWastedSpace()
If there is wasted space in the internal vectors due to removing many rows or columns, reclaim it. |
void |
reverseColumnComparator(int columnIndex)
Reverse the sense of the comparator for column columnIndex. |
void |
setCell(int rowIndex,
int columnIndex,
java.lang.Object data)
Specifies the value of a cell. |
void |
setCells(int startRowIndex,
int startColumnIndex,
int rowCount,
int columnCount,
java.lang.Object[][] cells)
Specifies the values for a block of cells. |
void |
setColumn(int columnIndex,
java.lang.Object[] cells)
Specifies the values of all the cells in a column. |
void |
setColumnClass(int columnIndex,
java.lang.Class newValue)
The column class is returned in the getColumnClass method. |
void |
setColumnComparator(int columnIndex,
java.util.Comparator comparator)
|
void |
setColumnComparators(java.util.Comparator[] comparators)
Assign a set of comparators for sorting the table by columns. |
void |
setColumnCount(int numColumns)
Set the number of columns |
void |
setColumnDefaultValue(int columnIndex,
java.lang.Object newValue)
The default column values apply only to subsequent calls to addRow or addColumn, and not to cell values that are already set. |
void |
setColumnLabel(int columnIndex,
java.lang.Object label)
Specifies the label to associate with a column. |
void |
setColumnLabelsSupported(boolean columnLabelsSupported)
|
void |
setDefaultCellStyle(StaticPropertyBagInterface newValue)
Specifies the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for cells. |
void |
setDefaultColumnStyle(StaticPropertyBagInterface newValue)
Specifies the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for columns. |
void |
setDefaultLabelStyle(StaticPropertyBagInterface newValue)
Specifies the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for labels. |
void |
setDefaultRowStyle(StaticPropertyBagInterface newValue)
Specifies the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for rows. |
void |
setDefaultValues()
Override the setDefaultValues method to initialize local variables |
void |
setRow(int rowIndex,
java.lang.Object[] cells)
Specifies the values of all the cells in a row. |
void |
setRowCount(int numRows)
Set the number of rows |
void |
setRowLabel(int rowIndex,
java.lang.Object label)
Specifies the label to associate with a row. |
void |
setRowLabelsSupported(boolean rowLabelsSupported)
|
void |
setSize(int rowCount,
int colCount)
Sets the size of this table. |
void |
sort(java.util.Comparator comparator,
boolean removeDuplicates)
Sort the table in place, based on comparing row contents using the comparator. |
void |
sort(java.util.Comparator comparator,
int startRowIndex,
int endRowIndex,
int[] permutation)
Sort the table in place, based on comparing row contents using the comparator. |
void |
sort(int[] columnIndices,
java.util.Comparator[] comparators,
boolean removeDuplicates)
Sort the table in place, based on comparing elements from multiple columns listed in columnIndices, using the corresponding Comparator from the array, comparators. |
void |
sort(int[] columnIndices,
java.util.Comparator[] comparators,
int startRowIndex,
int endRowIndex,
int[] permutation)
Sort the table in place, based on comparing elements from multiple columns listed in columnIndices, using the corresponding Comparator from the array, comparators. |
void |
sort(int columnIndex,
java.util.Comparator comparator,
boolean removeDuplicates)
Sort the table in place, based on comparing elements from the column columnIndex, using the comparator. |
void |
sort(int columnIndex,
java.util.Comparator comparator,
int startRowIndex,
int endRowIndex,
int[] permutation)
Sort the table in place, based on comparing elements from the column columnIndex, using the comparator. |
| Field Detail |
|---|
protected boolean columnsLabelSupported
protected java.lang.Object columnsLabel
protected boolean rowsLabelSupported
protected java.lang.Object rowsLabel
protected boolean rowLabelsSupported
protected boolean columnLabelsSupported
protected transient com.sas.collection.ContentsChangedListenerList allContentsChangedListeners
addContentsChangedListener(com.sas.collection.ContentsChangedListener),
removeContentsChangedListener(com.sas.collection.ContentsChangedListener),
anyContentsChangedListeners()| Constructor Detail |
|---|
public SimpleTable()
public SimpleTable(int numRows,
int numColumns)
numRows - the initial number of rows.numColumns - the initial number of columns.
public SimpleTable(DataTableInterface table)
throws com.sas.table.TableException
table - data table
com.sas.table.TableException - Thrown by populate method called by constructor
public SimpleTable(DataTableInterface table,
int startRow,
int endRow,
int startCol,
int endCol)
throws com.sas.table.TableException
table - data tablestartRow - starting row (value must be greater than 0)endRow - ending row (value must be greater than 0 and
greater than or equal to the starting row). A value of -1 indicates the
remaining rows of the tablestartCol - starting column (value must be greater than 0)endCol - ending column (value must be greater than 0 and
greater than or equal to the starting column). A value of -1 indicates the
remaining columns of the table
com.sas.table.TableException - Thrown by populate method called by constructor
public SimpleTable(DataTableInterface table,
java.util.Comparator[] comparators)
throws com.sas.table.TableException
table - a table of data to populate this new SimpleTable from.comparators - and array of comparators to associate with the columns.
Element 1 of this array is the comparator for column 1, etc.
Thus, element 0 is always ignored. Items beyond getColumnCount()
are ignored.
com.sas.table.TableException - when there is an exception reading data from table
public SimpleTable(DataTableInterface table,
int startRowIndex,
int endRowIndex,
int startCol,
int endCol,
java.util.Comparator[] comparators)
throws com.sas.table.TableException
table - a table of data to populate this new SimpleTable from.comparators - and array of comparators to associate with the columns.
Element 1 of this array is the comparator for column 1, etc.
Thus, element 0 is always ignored. Items beyond getColumnCount()
are ignored.
com.sas.table.TableException - when there is an exception reading data from table
public SimpleTable(int numRows,
int numColumns,
java.util.Comparator[] comparators)
numRows - the initial number of rows.numColumns - the initial number of columns.comparators - and array of comparators to associate with the columns.
Element 1 of this array is the comparator for column 1, etc.
Thus, element 0 is always ignored. Items beyond getColumnCount()
are ignored.| Method Detail |
|---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public void setColumnComparators(java.util.Comparator[] comparators)
public void populate(DataTableInterface dti)
throws com.sas.table.TableException
table - data table
com.sas.table.TableException - Thrown (see populate(DataTableInterface dti, boolean defineColumns,
int startRow, int endRow, int startCol, int endCol))
java.lang.IndexOutOfBoundsException - Thrown (see populate(DataTableInterface dti, boolean defineColumns,
int startRow, int endRow, int startCol, int endCol))
java.lang.IllegalStateException - Thrown (see populate(DataTableInterface dti, boolean defineColumns,
int startRow, int endRow, int startCol, int endCol))
protected void populate(DataTableInterface dti,
boolean defineColumns)
throws com.sas.table.TableException
table - data tabledefineColumns - indicates whether the SimpleTable should
read the data table's column descriptors and create corresponding columns
in the SimpleTable. If set to false, the SimpleTable will simply append the
data from the data table (no changes/additions to the SimpleTable column definitions)
com.sas.table.TableException - Thrown (see populate(DataTableInterface dti, boolean defineColumns,
int startRow, int endRow, int startCol, int endCol))
java.lang.IndexOutOfBoundsException - Thrown (see populate(DataTableInterface dti, boolean defineColumns,
int startRow, int endRow, int startCol, int endCol))
java.lang.IllegalStateException - Thrown (see populate(DataTableInterface dti, boolean defineColumns,
int startRow, int endRow, int startCol, int endCol))
public void populate(DataTableInterface dti,
boolean defineColumns,
int startRow,
int endRow,
int startCol,
int endCol)
throws com.sas.table.TableException,
java.lang.IndexOutOfBoundsException,
java.lang.IllegalStateException
table - data tabledefineColumns - indicates whether the SimpleTable should
read the data table's column descriptors and create corresponding columns
in the SimpleTable. If set to false, the SimpleTable will simply append the
data from the data table (no changes/additions to the SimpleTable column definitions)startRow - starting row (value must be greater than 0)endRow - ending row (value must be greater than 0 and
greater than or equal to the starting row). A value of -1 indicates the
remaining rows of the tablestartCol - starting column (value must be greater than 0)endCol - ending column (value must be greater than 0 and
greater than or equal to the starting column). A value of -1 indicates the
remaining columns of the table
java.lang.IndexOutOfBoundsException - Thrown if starting or ending row/column
parameters are not valid (startRow/Column <=0, endRow/Column =0,
endRow/Column < startRow/Column, endRow/Column <-1)
com.sas.table.TableException - Thrown if an attempt is made to add more
columns to the SimpleTable and the value of defineColumns is false
OR the column classes of the data table are not compatible with the
current Simple Table column classes (defineColumns is specified as
false)
java.lang.IllegalStateException - Thrown if columns are not defined in the Simple Table (defineColumns
is specified as false)
public void populate(DataTableInterface dti,
int startCol,
int endCol)
throws com.sas.table.TableException,
java.lang.IndexOutOfBoundsException
table - data tablestartCol - starting column (value must be greater than 0)endCol - ending column (value must be greater than 0 and
greater than or equal to the starting column). A value of -1 indicates the
remaining columns of the table
java.lang.IndexOutOfBoundsException - Thrown if starting or ending column
parameters are not valid (startColumn <=0, endColumn =0,
endColumn < startColumn, endColumn <-1)
com.sas.table.TableException - Thrown if
the column classes of the data table are not compatible with the
current Simple Table column classes
protected int calculateTotalRows(DataTableInterface dti)
throws com.sas.table.TableException,
java.lang.IndexOutOfBoundsException
table - data table
com.sas.table.TableException
java.lang.IndexOutOfBoundsException
protected int calculateTotalColumns(DataTableInterface dti)
throws com.sas.table.TableException
table - data table
com.sas.table.TableException
public void setSize(int rowCount,
int colCount)
If the new row count is greater than the current row count, new empty rows are added to the end of the table. If the new row count is less than the current row count, all rows at indices greater than the new row count are discarded.
If the new column count is greater than the current column count, new columns of type String are added to the end of the table. If the new column count is less than the current column count, all columns at indices greater than the new column count are discarded.
All created rows and columns are assigned default labels derived from their index. For example, 1,2,3,...etc. for rows and A,B,C,...etc. for columns.
rowCount - The number of rows to assign the table.colCount - The number of columns to assign the table.protected void removeWastedSpace()
public void setDefaultValues()
setDefaultValues in interface ComponentInterfacesetDefaultValues in class ComponentComponentInterface.setDefaultValues()public void disableEvents()
disableEvents in interface com.sas.util.EventGateInterfaceEventGateInterface.disableEvents()
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in interface com.sas.PublicClonableclone in class Componentjava.lang.CloneNotSupportedException - if the clone
fails.public boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - an object
equals((SimpleTable) o)
else return falsepublic boolean equals(SimpleTable table)
table - another SimpleTable object
public void enableEvents()
enableEvents in interface com.sas.util.EventGateInterfaceEventGateInterface.enableEvents()protected void enableEvents(com.sas.collection.ContentsChangedEvent e)
EventGateInterface.enableEvents()public int countColumns(int maxColumnCount)
countColumns in interface StaticTableInterfacemaxColumnCount - Maximum number of columns to read, or 0 to read indefinitely.
Implementations where the number of columns is always known should
ignore this parameter. In cases where the total number of columns
is unknown, but the number known so far is greater than maxCount
should return the larger known number. Thus maxCount is only
used as a limiting factor when the implementation has to actually do
computation (e.g. fetch observations).
StaticTableInterface.countColumns(int),
getColumnCount()public int countRows(int maxRowCount)
countRows in interface StaticTableInterfacemaxRowCount - Maximum number of rows to read, or 0 to read indefinitely.
Implementations where the number of rows is always known should
ignore this parameter. In cases where the total number of rows
is unknown, but the number known so far is greater than maxCount
should return the larger known number. Thus maxCount is only
used as a limiting factor when the implementation has to actually do
computation (e.g. fetch observations).
StaticTableInterface.countRows(int),
getRowCount()
public java.lang.Object getCell(int rowIndex,
int columnIndex)
StaticTableInterface
getCell in interface StaticTableInterfacerowIndex - A one-based index that identifies the cell's row.columnIndex - A one-based index that identifies the cell's column.
StaticTableInterface.getCell(int, int)
public java.lang.Object[][] getCells(int startRowIndex,
int startColumnIndex,
int rowCount,
int columnCount)
StaticTableInterfacenew Object[rowCount][colCount], with
values[0][0] containing the value of the cell at
(startRowIndex, startColumnIndex).
getCells in interface StaticTableInterfacestartRowIndex - A one-based index that identifies the start of the row range.startColumnIndex - A one-based index that identifies the start of the column range.rowCount - The number of rows in the row range.columnCount - The number of columns in the column range.
StaticTableInterface.getCells(int, int, int, int)
public java.lang.Class getCellClass(int rowIndex,
int columnIndex)
getCellClass in interface StaticTableInterfacerowIndex - A one-based index that identifies the cell's row.columnIndex - A one-based index that identifies the cell's column.
StaticTableInterface.getCellClass(int, int)
public java.lang.Class[][] getCellClasses(int startRowIndex,
int startColumnIndex,
int rowCount,
int columnCount)
StaticTableInterfacenew Class[rowCount][colCount], with
clases[0][0] containing the class of the cell at
(startRowIndex, startColumnIndex).
getCellClasses in interface StaticTableInterfacestartRowIndex - A one-based index that identifies the start of the row range.startColumnIndex - A one-based index that identifies the start of the column range.rowCount - The number of rows in the row range.columnCount - The number of columns in the column range.
StaticTableInterface.getCellClasses(int, int, int, int)public java.lang.Object[] getColumn(int columnIndex)
StaticTableInterface
getColumn in interface StaticTableInterfacecolumnIndex - A one-based index that identifies the column.
StaticTableInterface.getColumn(int)public int getColumnCount()
StaticTableInterface
getColumnCount in interface StaticTableInterfaceStaticTableInterface.getColumnCount()public void setColumnCount(int numColumns)
numColumns - the number of columns.
If smaller, columns whose index is greater than numColumns
are deleted. If larger, empty columns are addedsetRowCount(int),
setSize(int, int)public java.lang.Object[] getRow(int rowIndex)
StaticTableInterface
getRow in interface StaticTableInterfacerowIndex - A one-based index that identifies the row.
StaticTableInterface.getRow(int)public int getRowCount()
StaticTableInterface
getRowCount in interface StaticTableInterfaceStaticTableInterface.getRowCount()public void setRowCount(int numRows)
numRows - the number of rows
If smaller, rows whose index is greater than numRows
are deleted. If larger, empty rows are addedsetColumnCount(int),
setSize(int, int)public boolean isCellsModifiable()
isCellsModifiable in interface TableInterfacetrue if cells can be modified,
and false otherwise.TableInterface.isCellsModifiable()public boolean isMultipleRowUpdateSupported()
isMultipleRowUpdateSupported in interface TableInterfacetrue if multiple rows can be simultaneously updated,
and false otherwise.TableInterface.isMultipleRowUpdateSupported()public boolean isMultipleColumnUpdateSupported()
isMultipleColumnUpdateSupported in interface TableInterfacetrue if multiple columns can be simultaneously updated,
and false otherwise.TableInterface.isMultipleColumnUpdateSupported()
public void setCell(int rowIndex,
int columnIndex,
java.lang.Object data)
TableInterface
setCell in interface TableInterfacerowIndex - A one-based index that identifies the cell's row.columnIndex - A one-based index that identifies the cell's column.data - The cell's new value.TableInterface.setCell(int, int, java.lang.Object)
public void setCells(int startRowIndex,
int startColumnIndex,
int rowCount,
int columnCount,
java.lang.Object[][] cells)
TableInterfacenew Object[rowCount][colCount], with
values[0][0] containing the value of the cell at
(startRowIndex, startColumnIndex).
Usually, the implementation will require that the class of each
new value match what's returned by getCellClass() for the corresponding
cell, but a common exception to
this will be implementations that allow values to be instances of
com.sas.MissingValues.
setCells in interface TableInterfacestartRowIndex - A one-based index that identifies the start of the row range.startColumnIndex - A one-based index that identifies the start of the column range.rowCount - The number of rows in the row range.columnCount - The number of columns in the column range.cells - The new values for each cell in the block.TableInterface.setCells(int, int, int, int, java.lang.Object[][])
public void setColumn(int columnIndex,
java.lang.Object[] cells)
TableInterface
setColumn in interface TableInterfacecolumnIndex - A one-based index that identifies the column.cells - The new values for each cell in the column.TableInterface.setColumn(int, java.lang.Object[])
public void setRow(int rowIndex,
java.lang.Object[] cells)
TableInterface
setRow in interface TableInterfacerowIndex - A one-based index that identifies the row.cells - The new values for each cell in the row.TableInterface.setRow(int, java.lang.Object[])public boolean isRowLabelsSupported()
isRowLabelsSupported in interface com.sas.table.StaticRowLabelInterfaceStaticRowLabelInterface.isRowLabelsSupported()public java.lang.Object getRowLabel(int rowIndex)
getRowLabel in interface com.sas.table.StaticRowLabelInterfaceStaticRowLabelInterface.getRowLabel(int)
public java.lang.Object[] getRowLabels(int startRowIndex,
int rowCount)
getRowLabels in interface com.sas.table.StaticRowLabelInterfaceStaticRowLabelInterface.getRowLabels(int, int)public boolean isRowsLabelSupported()
isRowsLabelSupported in interface com.sas.table.StaticRowLabelInterfaceStaticRowLabelInterface.isRowsLabelSupported()public boolean isRowLabelsModifiable()
RowLabelInterface
isRowLabelsModifiable in interface RowLabelInterfacetrue if row labels can be modified,
and false otherwise.RowLabelInterface.isRowLabelsModifiable()
public void setRowLabel(int rowIndex,
java.lang.Object label)
RowLabelInterface
When isRowsLabelSupported() is true, setRowLabel(0) can
be used to set the label for the entire set of row labels.
setRowLabel in interface RowLabelInterfacerowIndex - A one-based index that identifies the row.
See note about use of zero above.label - The row's new label.RowLabelInterface.setRowLabel(int, java.lang.Object)public boolean isColumnLabelsSupported()
StaticColumnLabelInterface
isColumnLabelsSupported in interface StaticColumnLabelInterfacetrue if labels are available,
and false otherwise.StaticColumnLabelInterface.isColumnLabelsSupported()public java.lang.Object getColumnLabel(int columnIndex)
StaticColumnLabelInterface
When isColumnsLabelSupported() is true, getColumnLabel(0) can
be used to retrieve the label for the entire set of column labels.
getColumnLabel in interface StaticColumnLabelInterfacecolumnIndex - A one-based index that identifies the column.
See note about use of zero above.
StaticColumnLabelInterface.getColumnLabel(int)
public java.lang.Object[] getColumnLabels(int startColumnIndex,
int columnCount)
StaticColumnLabelInterface
getColumnLabels in interface StaticColumnLabelInterfacestartColumnIndex - A one-based index which identifies the start of the range.columnCount - The number of labels to return (the extent of the range).
StaticColumnLabelInterface.getColumnLabels(int, int)public boolean isColumnsLabelSupported()
StaticColumnLabelInterfacegetColumnLabel(0) can be used to access it.
isColumnsLabelSupported in interface StaticColumnLabelInterfacetrue if a column labels label is supported,
and false otherwise.StaticColumnLabelInterface.isColumnsLabelSupported()public boolean isColumnLabelsModifiable()
ColumnLabelInterface
isColumnLabelsModifiable in interface ColumnLabelInterfacetrue if column labels can be modified,
and false otherwise.ColumnLabelInterface.isColumnLabelsModifiable()
public void setColumnLabel(int columnIndex,
java.lang.Object label)
ColumnLabelInterface
When isColumnsLabelSupported() is true, setColumnLabel(0) can
be used to set the label for the entire set of column labels.
setColumnLabel in interface ColumnLabelInterfacecolumnIndex - A one-based index that identifies the column.
See note about use of zero above.label - The column's new label.ColumnLabelInterface.setColumnLabel(int, java.lang.Object)public java.lang.Class[] getColumnClasses()
StaticRowTemplateTableInterface.getColumnClasses(int, int)public java.lang.Class getColumnClass(int columnIndex)
StaticRowTemplateTableInterface
getColumnClass in interface StaticRowTemplateTableInterfacecolumnIndex - A one-based index that identifies the column.
StaticRowTemplateTableInterface.getColumnClass(int)
public java.lang.Class[] getColumnClasses(int startColumnIndex,
int columnCount)
StaticRowTemplateTableInterface
getColumnClasses in interface StaticRowTemplateTableInterfacestartColumnIndex - A one-based index which identifies the start of the range.columnCount - The number of classes to return; defines the extent of the range.
StaticRowTemplateTableInterface.getColumnClasses(int, int)
public void addColumn(int columnIndex,
java.lang.Class type,
java.lang.Object defaultValue)
addColumn in interface RowTemplateTableInterfacecolumnIndex - The one-based position at which to insert the column; columns already
at or above that position will be shifted-up.
If DEFAULT_INDEX is specified the position of the new column is
implementation defined, but should be at the end if possible.type - The class of the column's cells.defaultValue - The default value for the column's cells.RowTemplateTableInterface.addColumn(int, java.lang.Class, java.lang.Object)public void addColumn(int columnIndex)
public void addRow(int rowIndex)
addRow in interface RowTemplateTableInterfacerowIndex - The one-based position at which to insert the row; rows already
at or above that position will be shifted-up.
If DEFAULT_INDEX is specified the position of the new row is
implementation defined, but should be at the end if possible.RowTemplateTableInterface.addRow(int, java.lang.Object[])
public void addRow(int rowIndex,
java.lang.Object[] values)
RowTemplateTableInterfaceSome implementations may not allow rows to be added. This can be determined through isRowsExtendable. Some implementations may allow rows to be added, but not inserted; check isRowsInsertable. If this is the case, only DEFAULT_INDEX can be specified for index.
addRow in interface RowTemplateTableInterfacerowIndex - The one-based position at which to insert the row; rows already
at or above that position will be shifted-up.
If DEFAULT_INDEX is specified the position of the new row is
implementation defined, but should be at the end if possible.values - The values for each of the row's cells.
java.lang.IllegalArgumentException - Thrown if values.length is not the current number
of columnsRowTemplateTableInterface.addRow(int, java.lang.Object[])public void deleteColumn(int columnIndex)
deleteColumn in interface RowTemplateTableInterfacecolumnIndex - A one-based index that identifies the column.RowTemplateTableInterface.deleteColumn(int)public void deleteRow(int rowIndex)
deleteRow in interface RowTemplateTableInterfacerowIndex - A one-based index that identifies the row.RowTemplateTableInterface.deleteRow(int)public java.lang.Object getColumnDefaultValue(int columnIndex)
RowTemplateTableInterface
getColumnDefaultValue in interface RowTemplateTableInterfacecolumnIndex - A one-based index that identifies the column.
RowTemplateTableInterface.getColumnDefaultValue(int)
public java.lang.Object[] getColumnDefaultValues(int startColumnIndex,
int columnCount)
RowTemplateTableInterface
getColumnDefaultValues in interface RowTemplateTableInterfacestartColumnIndex - A one-based index which identifies the start of the range.columnCount - The number of default values to return; defines the extent of the
range.
RowTemplateTableInterface.getColumnDefaultValues(int, int)public boolean isColumnsDeletable()
isColumnsDeletable in interface RowTemplateTableInterfaceRowTemplateTableInterface.isColumnsDeletable()public boolean isColumnsExtendable()
isColumnsExtendable in interface RowTemplateTableInterfaceRowTemplateTableInterface.isColumnsExtendable()public boolean isColumnsInsertable()
isColumnsInsertable in interface RowTemplateTableInterfaceRowTemplateTableInterface.isColumnsInsertable()public boolean isColumnsRedefinable()
isColumnsRedefinable in interface RowTemplateTableInterfaceRowTemplateTableInterface.isColumnsRedefinable()public boolean isRowsDeletable()
isRowsDeletable in interface RowTemplateTableInterfaceisRowsDeletable in interface SortableTableInterfaceRowTemplateTableInterface.isRowsDeletable()public boolean isRowsExtendable()
isRowsExtendable in interface RowTemplateTableInterfaceRowTemplateTableInterface.isRowsExtendable()public boolean isRowsInsertable()
isRowsInsertable in interface RowTemplateTableInterfaceRowTemplateTableInterface.isRowsInsertable()
public void setColumnDefaultValue(int columnIndex,
java.lang.Object newValue)
setColumnDefaultValue in interface RowTemplateTableInterfacecolumnIndex - A one-based index that identifies the column.newValue - The new defaultValue to associate with the column.RowTemplateTableInterface.setColumnDefaultValue(int, java.lang.Object)
public void setColumnClass(int columnIndex,
java.lang.Class newValue)
setColumnClass in interface RowTemplateTableInterfacecolumnIndex - A one-based index that identifies the column.RowTemplateTableInterface.setColumnClass(int, java.lang.Class)public void setColumnLabelsSupported(boolean columnLabelsSupported)
public void setRowLabelsSupported(boolean rowLabelsSupported)
public void deleteAllColumns()
deleteColumn(int),
deleteAllRows()public void deleteAllRows()
deleteRow(int),
deleteAllColumns()public void addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
addContentsChangedListener in interface com.sas.collection.ContentsChangedSourcelistener - an object which handles ContentsChangedEvent events
the listener is not added a second time if it already exists
in the list of listeners for this event. If listener is null,
it is ignored.ContentsChangedSourcepublic void removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
removeContentsChangedListener in interface com.sas.collection.ContentsChangedSourcelistener - an object which handles ContentsChangedEvent eventsContentsChangedSourceprotected void fireContentsChanged(com.sas.collection.ContentsChangedEvent event)
event - the event to sendprotected void fireContentsChanged()
fireContentsChanged(com.sas.collection.ContentsChangedEvent)protected boolean anyContentsChangedListeners()
disableEvents(),
enableEvents()public StaticPropertyBagInterface getDefaultCellStyle()
getDefaultCellStyle in interface StaticTableStyleInterfacesetDefaultCellStyle(com.sas.collection.StaticPropertyBagInterface)public void setDefaultCellStyle(StaticPropertyBagInterface newValue)
newValue - The new value to assign the defaultCellStyle property;
may be null.getDefaultCellStyle()public StaticPropertyBagInterface getDefaultColumnStyle()
getDefaultColumnStyle in interface StaticTableStyleInterfacesetDefaultColumnStyle(com.sas.collection.StaticPropertyBagInterface)public void setDefaultColumnStyle(StaticPropertyBagInterface newValue)
newValue - The new value to assign the defaultColumnStyle property;
may be null.getDefaultColumnStyle()public StaticPropertyBagInterface getDefaultLabelStyle()
getDefaultLabelStyle in interface StaticTableStyleInterfacesetDefaultLabelStyle(com.sas.collection.StaticPropertyBagInterface)public void setDefaultLabelStyle(StaticPropertyBagInterface newValue)
newValue - The new value to assign the defaultLabelStyle property;
may be null.getDefaultLabelStyle()public StaticPropertyBagInterface getDefaultRowStyle()
getDefaultRowStyle in interface StaticTableStyleInterfacesetDefaultRowStyle(com.sas.collection.StaticPropertyBagInterface)public void setDefaultRowStyle(StaticPropertyBagInterface newValue)
newValue - The new value to assign the defaultRowStyle property;
may be null.getDefaultRowStyle()
public StaticPropertyBagInterface getCellStyle(int rowIndex,
int colIndex)
getCellStyle in interface StaticTableStyleInterfacerowIndex - One-based index that identifies the cell's row.colIndex - One-based index that identifies the cell's column.
isCellStylesSupported()public boolean isCellStylesSupported()
false since SimpleTable does not support styles
a per-cell basis at this time.
isCellStylesSupported in interface StaticTableStyleInterfacetrue if styles are supported on a per-cell basis
and false otherwise.getCellStyle(int, int)public StaticPropertyBagInterface getColumnLabelStyle(int colIndex)
getColumnLabelStyle in interface StaticTableStyleInterfacecolIndex - One-based index that identifies the label's column.
isColumnLabelStylesSupported()public boolean isColumnLabelStylesSupported()
false since SimpleTable does not support styles
a per-column-label basis at this time.
isColumnLabelStylesSupported in interface StaticTableStyleInterfacetrue if styles are supported on a per-column-label basis
and false otherwise.getColumnLabelStyle(int)public StaticPropertyBagInterface getColumnStyle(int colIndex)
getColumnStyle in interface StaticTableStyleInterfacecolIndex - One-based index that identifies the column.
isColumnStylesSupported()public boolean isColumnStylesSupported()
false since SimpleTable does not support styles
a per-column basis at this time.
isColumnStylesSupported in interface StaticTableStyleInterfacetrue if styles are supported on a per-column basis
and false otherwise.getColumnStyle(int)public StaticPropertyBagInterface getRowLabelStyle(int rowIndex)
getRowLabelStyle in interface StaticTableStyleInterfacerowIndex - One-based index that identifies the label's row.
isRowLabelStylesSupported()public boolean isRowLabelStylesSupported()
false since SimpleTable does not support styles
a per-row-label basis at this time.
isRowLabelStylesSupported in interface StaticTableStyleInterfacetrue if styles are supported on a per-row-label basis
and false otherwise.getRowLabelStyle(int)public StaticPropertyBagInterface getRowStyle(int rowIndex)
getRowStyle in interface StaticTableStyleInterfacerowIndex - One-based index that identifies the row.
isRowStylesSupported()public boolean isRowStylesSupported()
false since SimpleTable does not support styles
a per-row basis at this time.
isRowStylesSupported in interface StaticTableStyleInterfacetrue if styles are supported on a per-row basis
and false otherwise.getRowStyle(int)
public final void sort(java.util.Comparator comparator,
boolean removeDuplicates)
throws com.sas.table.TableException
sort(comparator, 1, -1, null);
followed by a call to
removeDuplicates(comparator, 1, -1, true, null);
if removeDuplicates is true
com.sas.table.TableExceptionprotected java.util.Comparator newRowComparator()
public void sort(java.util.Comparator comparator,
int startRowIndex,
int endRowIndex,
int[] permutation)
throws com.sas.table.TableException
SortableTableInterface.sort(Comparator, int, int, int[]).
sort in interface SortableTableInterfacecomparator - the Comparator to use to compare table rows.
Row values are passed to the comparator an Object[] array
or a List. Use getCell(Object row, int columnIndex)
to extract a cell from this row for use in the comparator.
If comparator is null, a Comparator is made from
combining all column comparators.startRowIndex - the index of the first row of the range of rows to sort.endRowIndex - one greater than then index of the last row of the range of rows to sort,
or -1 to include all rows through the end of the table.
See also startRowIndex and endRowIndex above.permutation - the permutation under which the table was sorted.
This may be null; otherwise it must be initialized with
the consecutive integers from 0 to table.getRowCount() - 1 (the permutation is 0 based).
If non-null, the sort method will return the sort permutation in this
int[] array.
See Permuter.identityPermutation(int)
com.sas.table.TableException - if the table operation cannot be performedpublic int normalizeStartRow(int rowNumber)
public int normalizeEndRow(int rowNumber)
public final void sort(int columnIndex,
java.util.Comparator comparator,
boolean removeDuplicates)
throws com.sas.table.TableException
sort(columnIndex, comparator, 1, -1, nul);
followed by a call to
removeDuplicates(columnIndex, comparator, 1, -1, true, null);
if removeDuplicates is true
com.sas.table.TableException
public void sort(int columnIndex,
java.util.Comparator comparator,
int startRowIndex,
int endRowIndex,
int[] permutation)
throws com.sas.table.TableException
SortableTableInterface.sort(int, Comparator, int, int, int[]).
sort in interface SortableTableInterfacecolumnIndex - the column index to use for sorting.
Table column indices are 1-based.comparator - the comparator to use to compare table cells
When sorting by a column, only table cell values
table.getCell(a, columnIndex) and table.getCell(b, columnIndex)
are passed to the comparator. If this value is null, use
the comparator assigned to this row with SortableTableInterface.setColumnComparator(int, Comparator)startRowIndex - the index of the first row of the range of rows to sort.endRowIndex - one greater than then index of the last row of the range of rows to sort,
or -1 to include all rows through the end of the table.
See also startRowIndex and endRowIndex above.permutation - the permutation under which the table was sorted.
This may be null; otherwise it must be initialized with
the consecutive integers from 0 to table.getRowCount() - 1 (the permutation is 0 based).
If non-null, the sort method will return the sort permutation in this
int[] array.
See Permuter.identityPermutation(int)
com.sas.table.TableException - if the table operation cannot be performed
public final void sort(int[] columnIndices,
java.util.Comparator[] comparators,
boolean removeDuplicates)
throws com.sas.table.TableException
sort(columnIndices,comparator, 1, -1, null);
followed by a call to
removeDuplicates(columnIndices,comparators, 1, -1, true, null);
if removeDuplicates is true
com.sas.table.TableException
public void sort(int[] columnIndices,
java.util.Comparator[] comparators,
int startRowIndex,
int endRowIndex,
int[] permutation)
throws com.sas.table.TableException
SortableTableInterface.sort(int[], Comparator[], int, int, int[]).
sort in interface SortableTableInterfacecolumnIndices - an array of column indices to use for sorting.
Table column indices are 1-based.comparators - the comparators to use to compare table cells
comparators.length must not be less
than columnIndices.length.
If any comparators[col] is null,
for a column col
use getColumnComparator(col)startRowIndex - the index of the first row of the range of rows to sort.endRowIndex - one greater than then index of the last row of the range of rows to sort,
or -1 to include all rows through the end of the table.
See also startRowIndex and endRowIndex above.permutation - the permutation under which the table was sorted.
This may be null; otherwise it must be initialized with
the consecutive integers from 0 to table.getRowCount() - 1 (the permutation is 0 based).
If non-null, the sort method will return the sort permutation in this
int[] array
See Permuter.identityPermutation(int)
com.sas.table.TableException - if the table operation cannot be performed
protected java.util.Comparator newColumnComparator(int col,
java.util.Comparator comparator)
ConstantComparator.COMPARE_EQUALS
public java.util.Comparator newCompositeComparator(int[] columnIndices,
java.util.Comparator[] comparators)
CompositeComparator that compares using
the comparators or, if any element of comparators column comparators
is null, the corresponding column comparator.
For example, to construct a row comparator for sorting the table
via sort(Comparator, boolean) or sort(Comparator, int, int, int[]),
such that column 4 is the primary key and column 2 as secondary key,
use newCompositeComparator(new int[] { 4, 2 }, null);
columnIndices - an array of column numbers for which you want to
create a composite comparator
The comparator for column columnIndices[0] serves as the primary
comparison key;
the comparator for column columnIndices[1] serves as the secondary
comparison key, and so on.
If an element is 0, that element all all remaining columnIndices and comparators
are ignored.comparators - an array of comparators, corresponding to the elements
in columnIndices. This array may be null, or elements may be null, in
which case the corresponding column comparator, getColumnComparator(columnIndices[i])
will be used.
public void permute(int[] permutation)
throws com.sas.table.TableException
SortableTableInterface.permute(int[]).
permute in interface SortableTableInterfacepermutation - An array indicating how to permute the rows.
For example, with a table of five rows, the permutation { 3, 1, 0, 4, 2 }
will reorder the table as { row4, row2, row1, row5, row3 }.
The permutation must contain exactly table.getRowCount() items
ranging from 0 to table.getRowCount()-1 with no duplicate values.
Note that permutations are 0 based while row numbers are one based.
com.sas.table.TableException - if the table operation cannot be performed
public final void removeDuplicates(java.util.Comparator comparator)
throws com.sas.table.TableException
removeDuplicates(comparator, 1, -1, true, null);
com.sas.table.TableException
public void removeDuplicates(java.util.Comparator comparator,
int startRowIndex,
int endRowIndex,
boolean keepFirst,
boolean[] removed)
throws com.sas.table.TableException
SortableTableInterface.removeDuplicates(Comparator, int, int, boolean, boolean[]).
removeDuplicates in interface SortableTableInterfacecomparator - a Comparator which compares entire rows. The values passed to
this method are Object[] arrays
or List objects.
Use getCell(Object row, int columnIndex)
to extract a cell from this row for use in the comparator.
If comparator is null, a Comparator is made from
combining all column comparators.startRowIndex - the index of the first row of the range of rows to search for duplicates.endRowIndex - one greater than then index of the last row of the range of rows to search for duplicates,
or -1 to include all rows through the end of the table.
See also startRowIndex and endRowIndex above.keepFirst - if true, then when comparing rows i and i+1,
row i+1 is removed when equal. If false,
row i is removed when equal.removed - Flags indicating which items were removed.
If row i was removed, then removed[i-1]
is set to true, else false.
This parameter may be null if you do not need to record the removed rows.
Otherwise, it must contain table.getRowCount() elements.
This array is zero based, whereas row numbers are one based.
This method does not change elements of removed
outside of the range of rows specified by endRowIndex and endRowIndex.
com.sas.table.TableException - if the table operation cannot be performed
public final void removeDuplicates(int columnIndex,
java.util.Comparator comparator)
throws com.sas.table.TableException
removeDuplicates(comparator, 1, -1, true, null);
com.sas.table.TableException
public void removeDuplicates(int columnIndex,
java.util.Comparator comparator,
int startRowIndex,
int endRowIndex,
boolean keepFirst,
boolean[] removed)
throws com.sas.table.TableException
SortableTableInterface.removeDuplicates(int, Comparator, int, int, boolean, boolean[]).
removeDuplicates in interface SortableTableInterfacecomparator - a Comparator which compares table cells. If null, use getColumnComparator(columnIndex).startRowIndex - the index of the first row of the range of rows to search for duplicates.endRowIndex - one greater than then index of the last row of the range of rows to search for duplicates,
or -1 to include all rows through the end of the table.
See also startRowIndex and endRowIndex above.keepFirst - if true, then when comparing rows i and i+1,
row i+1 is removed when equal. If false,
row i is removed when equal.removed - Flags indicating which items were removed. See the same parameter in SortableTableInterface.removeDuplicates(Comparator,int,int,boolean,boolean[])
com.sas.table.TableException - if the table operation cannot be performed
public final void removeDuplicates(int[] columnIndices,
java.util.Comparator[] comparators)
throws com.sas.table.TableException
removeDuplicates(comparator, 1, -1, true, null);
com.sas.table.TableException
public void removeDuplicates(int[] columnIndices,
java.util.Comparator[] comparators,
int startRowIndex,
int endRowIndex,
boolean keepFirst,
boolean[] removed)
throws com.sas.table.TableException
SortableTableInterface.removeDuplicates(int[], Comparator[], int, int, boolean, boolean[]).
removeDuplicates in interface SortableTableInterfacestartRowIndex - the index of the first row of the range of rows to search for duplicates.
Normally, this is 1endRowIndex - one greater than then index of the last row of the range of rows to search for duplicates,
or -1 to include all rows through the end of the table,
See also startRowIndex and endRowIndex above.keepFirst - if true, then when comparing rows i and i+1,
row i+1 is removed when equal. If false,
row i is removed when equal.removed - Flags indicating which items were removed. See the same parameter in SortableTableInterface.removeDuplicates(Comparator,int,int,boolean,boolean[])
com.sas.table.TableException - if the table operation cannot be performedpublic void deleteRows(boolean[] delete)
deleteRows in interface SortableTableInterfacedelete - If delete[i]
is set to true, remove row i+1. The delete array must contain
table.getRowCount() elements. This array is zero based,
whereas row numbers are one based.
The delete row may be obtained from one of the removeDuplicates methods
listed in this interface. For example, if you wish to keep two
or more tables in sync and you remove duplicate rows from table A,
you can have the removeDuplicates method record the deleted rows
and then use deleteRows to remove the same rows
from tables B and C.public java.util.Comparator getColumnComparator(int columnIndex)
getColumnComparator in interface SortableTableInterfacecolumnIndex - the column number of the desired comparator.
column numbers are one based.
public void setColumnComparator(int columnIndex,
java.util.Comparator comparator)
setColumnComparator in interface SortableTableInterfacepublic void reverseColumnComparator(int columnIndex)
ReverseComparator, replace
it with the root comparator, ReverseComparator.getComparator(),
else, replace the comparator with new ReverseComparator(getColumnComparator(columnIndex))
reverseColumnComparator in interface SortableTableInterfacecolumnIndex - the column number whose comparison function you wish to reverse.
public static java.lang.Object getCell(java.lang.Object row,
int columnIndex)
Object[] array or
as a List (such as a Vector or ArrayList).
row - a row value from a table. This may be either an array (an Object[])
or a ListcolumnIndex - the index of the desired column. This index is 1 based.
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||