com.sas.swing.models
Class TableModelAdapter

com.sas.swing.models.TableModelAdapter
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.collection.ContentsChangedListener, ViewDefaultModel, AccurateRowCountInterface, DeleteRowInterface, com.sas.table.FormattedInterface, InsertRowInterface, com.sas.table.SortableInterface, com.sas.table.SortDistinctValuesInterface, com.sas.table.StaticColumnInfoInterface, com.sas.table.StaticRowLabelInterface, UpdateRowInterface, com.sas.util.SortDirectionInterface, com.sas.util.transforms.DisplayTransformInterface, java.io.Serializable, java.util.EventListener, javax.swing.table.TableModel

public class TableModelAdapter
implements com.sas.collection.ContentsChangedListener, com.sas.beans.PropertyChangeSource, ViewDefaultModel, com.sas.util.transforms.DisplayTransformInterface, com.sas.table.StaticRowLabelInterface, DeleteRowInterface, InsertRowInterface, UpdateRowInterface, AccurateRowCountInterface, com.sas.table.SortDistinctValuesInterface, com.sas.table.FormattedInterface, com.sas.table.StaticColumnInfoInterface

The TableModelAdapter is an adapter to allow a com.sas.table.StaticTableInterface object to be used in a javax.swing.JTable object. Any object that implements the com.sas.table.StaticTableInterface can be set as the model for this adapter. The adapter extends from AbstractTableModel and can be set as the model for a JTable. The default model delegate used by this adapter is a com.sas.table.SimpleTable object. If the model implements the com.sas.collection.ContentsChangedSource interface, the adapter will add itself as a listener to the model for changes that occur on it. The adapter does not allow editing by default. This is because a remote SAS object connected to a shared dataset will throw exceptions if cells are locked by one user and another user attempts to edit the cells.

See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable columnDisplayTransforms
           
protected  int currentMaxCount
           
protected  int currentRowCount
           
protected  boolean defaultModelAttached
           
protected  com.sas.util.transforms.TransformInterface displayTransform
           
protected  boolean distinctValues
           
protected  boolean formattedDataUsed
           
protected  int lastRowIndex
           
protected  int maxRowCount
           
protected  StaticTableInterface model
           
protected  com.sas.beans.PropertyChangeSupport propertyChangeSupport
           
protected  boolean sortAllowed
           
protected  boolean tableEditable
           
 
Fields inherited from interface com.sas.table.InsertRowInterface
DEFAULT_INDEX
 
Fields inherited from interface com.sas.util.SortDirectionInterface
ASCENDING, DESCENDING, NOT_SORTED
 
Constructor Summary
TableModelAdapter()
          Default constructor.
TableModelAdapter(StaticTableInterface table)
          Constructor that sets the model of the adapter.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener to the adapter.
 void cancelUncommittedRow()
          Removes the "fake" row from the model, effectively performing a cancel.
 void commitUncommittedRow()
          Commits the data in the row to the underlying model.
 void contentsChanged(com.sas.collection.ContentsChangedEvent event)
          ContentsChangedListener method to listen for events sent by the model and fire the appropriate table changed events.
 void deleteRow(int rowIndex)
          Deletes a row.
protected  void expandRowCount()
          Expand the row count by using the countRows(int) method on the model and passing in either the maxRowCount or the last known rowCount incremented by the maxRowCount amount.
protected  void firePropertyChange(java.beans.PropertyChangeEvent evt)
          Send a PropertyChangeEvent to any listeners added to the adapter.
protected  void firePropertyChange(java.lang.String propName, java.lang.Object oldValue, java.lang.Object newValue)
          Send a PropertyChangeEvent to any listeners added to the adapter.
 void fireTableChanged(javax.swing.event.TableModelEvent evt)
          Overridden to reset the rowCount if an INSERT or a DELETE TableModelEvent is sent.
 void fireTableStructureChanged()
          Overridden to recalculate the rowCount.
 java.lang.Class getColumnClass(int columnIndex)
          Get the class for the specified columnIndex.
 int getColumnCount()
          Get the number of columns in the model.
 com.sas.util.transforms.TransformInterface getColumnDisplayTransform(java.lang.String columnName)
          Return the current transform on the given column, which can be null
 java.lang.Object getColumnInfo(int index, java.lang.String columnInfoName)
          Returns the named information for a column.
 java.lang.String[] getColumnInfoNames()
          Returns an array of the named information that can be returned for the columns.
 java.lang.String getColumnInfoUsed()
          Returns the column information that is currently being returned as the column label.
 java.lang.String getColumnName(int columnIndex)
          Get the column name for the specified column index.
 java.util.Enumeration getColumnNamesWithDisplayTransform()
          Returns an enumeration of all the column names that have a display transform applied to them.
 com.sas.util.transforms.TransformInterface getDisplayTransform()
          Return current transform, which can be null
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
          Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this BaseBorder.
 java.lang.String getFormat(int columnIndex)
          Returns the format that is being used for the given column in the model.
 java.lang.String getFormattedValueAt(int rowIndex, int columnIndex)
          Returns the formatted data for the given cell coordinates.
 int getMaxRowCount()
          Get the max row count used when the row count is unknown by the model.
 StaticTableInterface getModel()
          Get the model used by the adapter.
 int getRowCount()
          Get the known rowCount.
 java.lang.Object getRowLabel(int row)
           
 java.lang.Object[] getRowLabels(int startIndex, int count)
           
 java.lang.String[] getSortedColumns()
          Returns an array of strings that are the column names that have been sorted.
 int[] getSortedDirections()
          Returns an array of ints that indicate which direction each column in the sortedColumns array has been sorted.
 int getUncommittedRowNumber()
          Returns the index of the "fake" row.
 java.lang.Class getUnformattedColumnClass(int columnIndex)
          Get the class of the unformatted data for the specified columnIndex.
 java.lang.Object getUnformattedValueAt(int rowIndex, int columnIndex)
          Returns the unformatted data for the given cell coordinates
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Get the value at the specified row and column index.
protected  void initTable()
          Initialize the tables internal fields.
 void insertUncommittedRow(int rowIndex)
          Adds a "fake" row to the table model at the specified location.
 boolean isAccurateRowCountAvailable()
          Indicates whether an accurate row count is available.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Determine if the cell at the specified row and column is editable.
 boolean isColumnSortable(java.lang.String columnName)
          Returns a boolean indicating whether the columnName is allowed to be sorted.
 boolean isDefaultModelAttached()
          returns true is the component is using a default internal model.
 boolean isDistinctValues()
          Returns a boolean indicating whether the sorted columns should return only distinct values.
 boolean isFormattedDataUsed()
          Returns whether the model is using formatted data or just the raw data.
 boolean isRowDeletionAllowed()
          Indicates whether rows can be deleted.
 boolean isRowInsertionAllowed()
          Indicates whether rows can be inserted into the existing table.
 boolean isRowLabelsSupported()
           
 boolean isRowsLabelSupported()
           
 boolean isRowUpdateAllowed()
          Indicates whether rows can be updated.
 boolean isSortAllowed()
          Returns a boolean indicating whether sorting is allowed.
 boolean isTableEditable()
          Determine if the table is editable.
 boolean isTableExtendOnly()
          Indicates whether rows can only be inserted at the default location (usually at the end) of the existing table.
 boolean isUncommittedRowPresent()
          Returns true if the "fake" row exists.
protected  StaticTableInterface newDefaultModel()
          Create a new default model.
protected  void recalculateRowCount()
          Recalculates the known rowCount.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener from the adapter.
protected  void resetRowCount()
          Reset the row count fields to -1.
 void setColumnDisplayTransform(java.lang.String columnName, com.sas.util.transforms.TransformInterface newTransform)
          Sets the display transform on the given column.
 void setColumnInfoUsed(java.lang.String columnInfoUsed)
          Sets the column information that is currently being returned as the column label.
protected  void setDefaultModelAttached(boolean defaultModelUsed)
           
 void setDisplayTransform(com.sas.util.transforms.TransformInterface newTransform)
          Set transform to given transform, which can be null
 void setDistinctValues(boolean distinct)
          Sets whether the sorted columns should return only distinct values.
 void setFormattedDataUsed(boolean useFormattedData)
          Sets whether the model is using formatted data or just the raw data.
 void setMaxRowCount(int rc)
          The max row count to be used when the row count is unknown by the model.
 void setModel(StaticTableInterface table)
          Set the model used by the adapter to delegate all table calls.
 void setSortAllowed(boolean allowSorting)
          Sets whether sorting is enabled or not, by default it is.
 void setTableEditable(boolean editable)
          Set the table to editable.
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
          Set the value of the model at the specified row and column indices.
 void sort(java.lang.String[] columnNames, int[] direction)
          Each columnName must have a matching direction.
protected  void updateRowCount(int firstRow, int lastRow)
          Calls the super.fireTableChanged(TableModelEvent) method to notify the table that the row count has been updated.
 

Field Detail

defaultModelAttached

protected boolean defaultModelAttached

propertyChangeSupport

protected com.sas.beans.PropertyChangeSupport propertyChangeSupport

model

protected StaticTableInterface model

maxRowCount

protected int maxRowCount

currentMaxCount

protected int currentMaxCount

lastRowIndex

protected int lastRowIndex

tableEditable

protected boolean tableEditable

displayTransform

protected com.sas.util.transforms.TransformInterface displayTransform

columnDisplayTransforms

protected java.util.Hashtable columnDisplayTransforms

currentRowCount

protected int currentRowCount

formattedDataUsed

protected boolean formattedDataUsed

sortAllowed

protected boolean sortAllowed

distinctValues

protected boolean distinctValues
Constructor Detail

TableModelAdapter

public TableModelAdapter()
Default constructor. The adapter is initialized using initTable(). Sets the model to that returned by the newDefaultModel() method.


TableModelAdapter

public TableModelAdapter(StaticTableInterface table)
Constructor that sets the model of the adapter. The adapter is initialized using initTable().

Parameters:
table - the model used as a delegate for the adapter
Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this BaseBorder.

Returns:
the ExtendedBeanInfo for this class

initTable

protected void initTable()
Initialize the tables internal fields.


newDefaultModel

protected StaticTableInterface newDefaultModel()
Create a new default model.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the adapter.

Specified by:
addPropertyChangeListener in interface com.sas.beans.PropertyChangeSource
Parameters:
listener - the PropertyChangeListener to be notified when a PropertyChangeEvent occurs

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the adapter.

Specified by:
removePropertyChangeListener in interface com.sas.beans.PropertyChangeSource
Parameters:
listener - the PropertyChangeListener to stop being notified when a PropertyChangeEvent occurs

firePropertyChange

protected void firePropertyChange(java.beans.PropertyChangeEvent evt)
Send a PropertyChangeEvent to any listeners added to the adapter.


firePropertyChange

protected void firePropertyChange(java.lang.String propName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
Send a PropertyChangeEvent to any listeners added to the adapter.


getModel

public StaticTableInterface getModel()
Get the model used by the adapter.


isDefaultModelAttached

public boolean isDefaultModelAttached()
Description copied from interface: ViewDefaultModel
returns true is the component is using a default internal model.

Specified by:
isDefaultModelAttached in interface ViewDefaultModel

setDefaultModelAttached

protected void setDefaultModelAttached(boolean defaultModelUsed)

setModel

public void setModel(StaticTableInterface table)
Set the model used by the adapter to delegate all table calls. The adapter is added as a ContentsChangedListener if the model implements the ContentsChangedSource interface. Setting this property will cause the tableStructure to be changed.


getDisplayTransform

public com.sas.util.transforms.TransformInterface getDisplayTransform()
Return current transform, which can be null

Specified by:
getDisplayTransform in interface com.sas.util.transforms.DisplayTransformInterface
Returns:
current transform

setDisplayTransform

public void setDisplayTransform(com.sas.util.transforms.TransformInterface newTransform)
Set transform to given transform, which can be null

Specified by:
setDisplayTransform in interface com.sas.util.transforms.DisplayTransformInterface
Parameters:
newTransform - transform to be set

getColumnDisplayTransform

public com.sas.util.transforms.TransformInterface getColumnDisplayTransform(java.lang.String columnName)
Return the current transform on the given column, which can be null

Returns:
the current display transform on the column

setColumnDisplayTransform

public void setColumnDisplayTransform(java.lang.String columnName,
                                      com.sas.util.transforms.TransformInterface newTransform)
Sets the display transform on the given column. If the transform is null, it removes the display tranform from the column.

Parameters:
columnName - the name of the column to set the transform on
newTransform - transform to be set on the column, null to remove the transform

getColumnNamesWithDisplayTransform

public java.util.Enumeration getColumnNamesWithDisplayTransform()
Returns an enumeration of all the column names that have a display transform applied to them. This does not include the display transform that can be applied to the whole table model.

Returns:
an enumeration of the column names with display transforms

contentsChanged

public void contentsChanged(com.sas.collection.ContentsChangedEvent event)
ContentsChangedListener method to listen for events sent by the model and fire the appropriate table changed events. This method specifically listens for com.sas.table.RowChangedEvent, com.sas.table.DataCellChangedEvent, and com.sas.table.RowLabelChangedEvent subclasses of ContentsChangedEvent. If the event is another subclass the tableStructure changed event will be send to the JTable.

Specified by:
contentsChanged in interface com.sas.collection.ContentsChangedListener

getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
Get the class for the specified columnIndex. If the model implements the com.sas.table.FormattedDataInterface, this method will return the java.lang.String class. If the model implements the com.sas.table.StaticRowTemplateTableInterface then the getColumnClass(int) method on that interface will be used to determine the column class. Otherwise, the Object class is returned as the column type.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - the index of the column to return the type of
Returns:
the type of the column at the specified index

getUnformattedColumnClass

public java.lang.Class getUnformattedColumnClass(int columnIndex)
Get the class of the unformatted data for the specified columnIndex. If the model implements the com.sas.table.StaticRowTemplateTableInterface then the getColumnClass(int) method on that interface will be used to determine the column class. Otherwise, the Object class is returned as the column type.

Specified by:
getUnformattedColumnClass in interface com.sas.table.FormattedInterface
Parameters:
columnIndex - the index of the column to return the unformatted type of
Returns:
the unformatted type of the column at the specified index

getColumnCount

public int getColumnCount()
Get the number of columns in the model.

Specified by:
getColumnCount in interface javax.swing.table.TableModel

getColumnName

public java.lang.String getColumnName(int columnIndex)
Get the column name for the specified column index. If the model delegate implements the com.sas.table.StaticColumnLabelInterface, the getColumnLabel(int) is used to find the column name. Otherwise, the super.getColumnName(int) method is used.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - the index of the column to find the name for
Returns:
the name of the column at the specified index

setMaxRowCount

public void setMaxRowCount(int rc)
The max row count to be used when the row count is unknown by the model. The StaticTableInterface.countRows(int) method is used to determine the number of rows when the StaticTableInterface.getRowCount() method returns -1. The maxRowCount property is the initial max row count used when calling the countRows(int) method. This number is also used to increment the known count when the final row count is not known after using the countRows(int) method. This value is 100 by default.


getMaxRowCount

public int getMaxRowCount()
Get the max row count used when the row count is unknown by the model.

See Also:
setMaxRowCount(int)

fireTableChanged

public void fireTableChanged(javax.swing.event.TableModelEvent evt)
Overridden to reset the rowCount if an INSERT or a DELETE TableModelEvent is sent.

Overrides:
fireTableChanged in class javax.swing.table.AbstractTableModel

fireTableStructureChanged

public void fireTableStructureChanged()
Overridden to recalculate the rowCount.

Overrides:
fireTableStructureChanged in class javax.swing.table.AbstractTableModel

updateRowCount

protected void updateRowCount(int firstRow,
                              int lastRow)
Calls the super.fireTableChanged(TableModelEvent) method to notify the table that the row count has been updated.


resetRowCount

protected void resetRowCount()
Reset the row count fields to -1.


expandRowCount

protected void expandRowCount()
Expand the row count by using the countRows(int) method on the model and passing in either the maxRowCount or the last known rowCount incremented by the maxRowCount amount. The SwingUtilities.invokeLater(Runnable) is then used to cause the updateRowCount(int,int) method to be invoked at a later time.


getRowCount

public int getRowCount()
Get the known rowCount. If the rowCount is unknown, the last known rowCount is stored and when the first value on that row is requested, the rowCount is expanded again until the final rowCount is known.

Specified by:
getRowCount in interface javax.swing.table.TableModel

recalculateRowCount

protected void recalculateRowCount()
Recalculates the known rowCount. If the rowCount is unknown, the last known rowCount is stored and when the first value on that row is requested, the rowCount is expanded again until the final rowCount is known.


getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Get the value at the specified row and column index. If the model is an instance of the FormattedDataInterface, the getFormattedCell(int,int) method is used to find the value. Otherwise the getCell(int,int) method is used. If the row index is the same as the last known row index, expandRowCount is used to attempt to determine the true row count.

Specified by:
getValueAt in interface javax.swing.table.TableModel

getUnformattedValueAt

public java.lang.Object getUnformattedValueAt(int rowIndex,
                                              int columnIndex)
Returns the unformatted data for the given cell coordinates

Specified by:
getUnformattedValueAt in interface com.sas.table.FormattedInterface
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
the unformatted value of the data at the specified cell

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Determine if the cell at the specified row and column is editable. This checks the value of isTableEditable() first. If the table is editable and the model implements the com.sas.table.TableInterface, then the value of the isCellsModifiable() method is returned. Otherwise, the cell is not considered editable.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel

isTableEditable

public boolean isTableEditable()
Determine if the table is editable. This does not mean check the TableInterface.isCellsModifiable() method. If the model cells are actually modifyable, then this property can be set to true and the cells will be able to be edited. This value is false by default because using the model if it is a shared remote dataset can cause problems if one user locks a row and another attempts to update that same row. This will cause an exception when attempting to set the value.


setTableEditable

public void setTableEditable(boolean editable)
Set the table to editable.

See Also:
isTableEditable()

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Set the value of the model at the specified row and column indices. If the model is an instance of com.sas.table.FormattedDataInterface then the setFormattedCell(int,int,String) method is used to set the value. Otherwise if the model is an instance of the TableInterface, the setCell(int,int,Object) method is used. If an error occurs when setting the value, a ComponentException is thrown.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel

getRowLabel

public java.lang.Object getRowLabel(int row)
Specified by:
getRowLabel in interface com.sas.table.StaticRowLabelInterface

getRowLabels

public java.lang.Object[] getRowLabels(int startIndex,
                                       int count)
Specified by:
getRowLabels in interface com.sas.table.StaticRowLabelInterface

isRowLabelsSupported

public boolean isRowLabelsSupported()
Specified by:
isRowLabelsSupported in interface com.sas.table.StaticRowLabelInterface

isRowsLabelSupported

public boolean isRowsLabelSupported()
Specified by:
isRowsLabelSupported in interface com.sas.table.StaticRowLabelInterface

insertUncommittedRow

public void insertUncommittedRow(int rowIndex)
                          throws com.sas.util.UncheckedException
Description copied from interface: InsertRowInterface
Adds a "fake" row to the table model at the specified location.

Specified by:
insertUncommittedRow in interface InsertRowInterface
Parameters:
rowIndex - The row to add the "fake" row before.
Throws:
com.sas.util.UncheckedException - Provides a catch-all for all Exceptions.

commitUncommittedRow

public void commitUncommittedRow()
                          throws com.sas.util.UncheckedException
Description copied from interface: InsertRowInterface
Commits the data in the row to the underlying model.

Specified by:
commitUncommittedRow in interface InsertRowInterface
Throws:
com.sas.util.UncheckedException - Provides a catch-all for all Exceptions.

cancelUncommittedRow

public void cancelUncommittedRow()
                          throws com.sas.util.UncheckedException
Description copied from interface: InsertRowInterface
Removes the "fake" row from the model, effectively performing a cancel.

Specified by:
cancelUncommittedRow in interface InsertRowInterface
Throws:
com.sas.util.UncheckedException - Provides a catch-all for all Exceptions.

isUncommittedRowPresent

public boolean isUncommittedRowPresent()
Description copied from interface: InsertRowInterface
Returns true if the "fake" row exists. Once the row is committed or cancelled then the uncommittedRowPresent is false.

Specified by:
isUncommittedRowPresent in interface InsertRowInterface
Returns:
true if an uncommitted row exists

getUncommittedRowNumber

public int getUncommittedRowNumber()
Description copied from interface: InsertRowInterface
Returns the index of the "fake" row. Returns -1 if no "fake" row is present.

Specified by:
getUncommittedRowNumber in interface InsertRowInterface
Returns:
the index of the "fake" row

isRowInsertionAllowed

public boolean isRowInsertionAllowed()
Description copied from interface: InsertRowInterface
Indicates whether rows can be inserted into the existing table.

Specified by:
isRowInsertionAllowed in interface InsertRowInterface
Returns:
true if new rows can be inserted, false otherwise.

isTableExtendOnly

public boolean isTableExtendOnly()
Description copied from interface: InsertRowInterface
Indicates whether rows can only be inserted at the default location (usually at the end) of the existing table.

Specified by:
isTableExtendOnly in interface InsertRowInterface
Returns:
true if isRowInsertionAllowed is true and the table is only allowed to be extended.

isRowUpdateAllowed

public boolean isRowUpdateAllowed()
Description copied from interface: UpdateRowInterface
Indicates whether rows can be updated.

Specified by:
isRowUpdateAllowed in interface UpdateRowInterface
Returns:
true if rows can be updated, false otherwise.

deleteRow

public void deleteRow(int rowIndex)
Description copied from interface: DeleteRowInterface
Deletes a row. The row is identified by the given index.

Some implementations may not allow rows to be deleted. This can be determined through isRowDeletionAllowed().

Specified by:
deleteRow in interface DeleteRowInterface
Parameters:
rowIndex - A zero-based index that identifies the row.

isRowDeletionAllowed

public boolean isRowDeletionAllowed()
Description copied from interface: DeleteRowInterface
Indicates whether rows can be deleted.

Specified by:
isRowDeletionAllowed in interface DeleteRowInterface
Returns:
true if rows can be deleted, false otherwise.

isAccurateRowCountAvailable

public boolean isAccurateRowCountAvailable()
Description copied from interface: AccurateRowCountInterface
Indicates whether an accurate row count is available.

Specified by:
isAccurateRowCountAvailable in interface AccurateRowCountInterface
Returns:
true if an accurate row count is available, false otherwise.

sort

public void sort(java.lang.String[] columnNames,
                 int[] direction)
Each columnName must have a matching direction. If not, then an IllegalArgumentException will be thrown.

Specified by:
sort in interface com.sas.table.SortableInterface
Parameters:
columnNames - The names of the columns in the order that the columns will be sorted.
direction - The direction in which to sort the columns. Valid values are SortControllerInterface.ASCENDING and SortControllerInterface.DESCENDING. // * @param removeDuplicates Sets if dupicate rows are to be removed after the data is sorted. // * @param sortInPlace Sets if the data is to be sorted in place or in a temporary location. // * @param outputLocation The name of the location to store the sorted data. outputLocation is ignored if sortInPlace is true.

isColumnSortable

public boolean isColumnSortable(java.lang.String columnName)
Returns a boolean indicating whether the columnName is allowed to be sorted. The default is that all columns are allowed to be sorted.

Specified by:
isColumnSortable in interface com.sas.table.SortableInterface
Parameters:
columnName - The name of the column to query about whether it is allowed to be sorted.
Returns:
A boolean indicating whether the column is allowed to be sorted.

isSortAllowed

public boolean isSortAllowed()
Returns a boolean indicating whether sorting is allowed. Sorting is allowed by default.

Specified by:
isSortAllowed in interface com.sas.table.SortableInterface
Returns:
A boolean indicating whether sorting is allowed.

setSortAllowed

public void setSortAllowed(boolean allowSorting)
Sets whether sorting is enabled or not, by default it is.

Specified by:
setSortAllowed in interface com.sas.table.SortableInterface
Parameters:
allowSorting - true to enable sorting, false otherwise.
See Also:
isSortAllowed()

getSortedColumns

public java.lang.String[] getSortedColumns()
Returns an array of strings that are the column names that have been sorted. The sortedColumns array is updated after each call to the sort method. The length of the array can be from 0 to the number of available columns. An array of length 0 means that no columns are currently sorted.

Specified by:
getSortedColumns in interface com.sas.table.SortableInterface
Returns:
An array of strings that are the column names on which the data is sorted.

getSortedDirections

public int[] getSortedDirections()
Returns an array of ints that indicate which direction each column in the sortedColumns array has been sorted. The array will be the same size of the sortedColumns array. The sortedDirections array is update after each call to the sort method.

Specified by:
getSortedDirections in interface com.sas.table.SortableInterface
Returns:
An array of ints that indicate which direction the sorted columns have been sorted. Valid values are ASCENDING or DESCENDING.

isDistinctValues

public boolean isDistinctValues()
Returns a boolean indicating whether the sorted columns should return only distinct values. In other words, remove duplicate values for the sorted columns. Default value is false;

Specified by:
isDistinctValues in interface com.sas.table.SortDistinctValuesInterface
Returns:
A boolean indicating the sorted columns should return only distinct values

setDistinctValues

public void setDistinctValues(boolean distinct)
Sets whether the sorted columns should return only distinct values. Default value is false.

Specified by:
setDistinctValues in interface com.sas.table.SortDistinctValuesInterface
Parameters:
distinct - true if only distinct values should be return for the sorted columns

getColumnInfoUsed

public java.lang.String getColumnInfoUsed()
Returns the column information that is currently being returned as the column label. The default is to return the NAME of the column. Valid only if the model is an instance of com.sas.table.DataTableInterface.

Returns:
A String indicating the type of information to use as the column label or null if the model is not an instance of com.sas.table.DataTableInterface The valid values are : RemoteDataSetInterface.NAME, RemoteDataSetInterface.LENGTH, RemoteDataSetInterface.TYPE, RemoteDataSetInterface.LABEL, RemoteDataSetInterface.FORMAT, and RemoteDataSetInterface.INFORMAT.
See Also:
RemoteDataSetInterface, setColumnInfoUsed(java.lang.String)

setColumnInfoUsed

public void setColumnInfoUsed(java.lang.String columnInfoUsed)
                       throws com.sas.util.UncheckedException
Sets the column information that is currently being returned as the column label. Valid only if the model is an instance of com.sas.table.DataTableInterface, otherwise ignored.

Parameters:
columnInfoUsed - A String indicating the type of information to use as the column label. Case does not matter. The valid values are : RemoteDataSetInterface.NAME, RemoteDataSetInterface.LENGTH, RemoteDataSetInterface.TYPE, RemoteDataSetInterface.LABEL, RemoteDataSetInterface.FORMAT, and RemoteDataSetInterface.INFORMAT.
Throws:
com.sas.table.TableException - if the column information cannot be retrieved.
com.sas.util.UncheckedException
See Also:
RemoteDataSetInterface, getColumnInfoUsed()

getFormat

public java.lang.String getFormat(int columnIndex)
                           throws com.sas.util.UncheckedException
Returns the format that is being used for the given column in the model. If the model is an instance of com.sas.table.StaticColumnInfoInterface, if will return the SAS format for that column, otherwise an empty string will be returned. User can use this to help format data on their own if they have the raw data.

Specified by:
getFormat in interface com.sas.table.FormattedInterface
Parameters:
columnIndex - the column index in the model that the format is to be returned for
Returns:
the format that is applied to the raw data
Throws:
com.sas.util.UncheckedException

getFormattedValueAt

public java.lang.String getFormattedValueAt(int rowIndex,
                                            int columnIndex)
Returns the formatted data for the given cell coordinates. If a transform is set, it will call toString on the value returned from the transform as this method needs to return a String and a transform may be trying to return somethign else.

Specified by:
getFormattedValueAt in interface com.sas.table.FormattedInterface
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
the formatted value of the data at the specified cell

setFormattedDataUsed

public void setFormattedDataUsed(boolean useFormattedData)
Sets whether the model is using formatted data or just the raw data. A call to getFormattedVaueAt(int, int) should ignore this variable and always return the formatted data when possible. The getColumnClass(int) method pays attention to this value and return the column class based on whether formatted or unformatted data is being used. The default value is true.

Specified by:
setFormattedDataUsed in interface com.sas.table.FormattedInterface
Parameters:
useFormattedData - whether to use formatted data by default versus raw data
See Also:
isFormattedDataUsed()

isFormattedDataUsed

public boolean isFormattedDataUsed()
Returns whether the model is using formatted data or just the raw data. A call to getFormattedVaueAt(int, int) should ignore this variable and always return the formatted data when possible. The getColumnClass(int) method should pay attention to this value and return the column class based on whether formatted or unformatted data is being used. The default value is true.

Specified by:
isFormattedDataUsed in interface com.sas.table.FormattedInterface
Returns:
true if formatted data is being used or false otherwise
See Also:
setFormattedDataUsed(boolean)

getColumnInfo

public java.lang.Object getColumnInfo(int index,
                                      java.lang.String columnInfoName)
                               throws com.sas.util.UncheckedException
Returns the named information for a column. The column is identified by the given index. The model must implement the com.sas.table.StaticColumnInfoInterface, otherwise null will be returned.

Specified by:
getColumnInfo in interface com.sas.table.StaticColumnInfoInterface
Parameters:
index - the index the identifies the column, needs to be one-based
columnInfoName - the name of the information a user wants to query for, the valid values are whatever values are returned from a call to getColumnInfoNames().
Returns:
the named information for the column, or null if the model does not implement com.sas.table.StaticColumnInfoInterface
Throws:
com.sas.util.UncheckedException - thrown if a call to the model yields an exception
See Also:
getColumnInfoNames(), StaticColumnInfoInterface

getColumnInfoNames

public java.lang.String[] getColumnInfoNames()
                                      throws com.sas.util.UncheckedException
Returns an array of the named information that can be returned for the columns. The model must implement the com.sas.table.StaticColumnInfoInterface, otherwise an empty array will be returned.

Specified by:
getColumnInfoNames in interface com.sas.table.StaticColumnInfoInterface
Returns:
an array of strings of the type of information the columns can be queried for, or an empty array if the model does not support such
Throws:
com.sas.util.UncheckedException - thrown if a call to the model yields an exception



Copyright © 2009 SAS Institute Inc. All Rights Reserved.