Class DefaultAnonymousTable
- java.lang.Object
-
- jmri.jmrit.logixng.implementation.DefaultAnonymousTable
-
- All Implemented Interfaces:
AnonymousTable,Table
public class DefaultAnonymousTable extends java.lang.Object implements AnonymousTable
Default implementation for anonymous tables
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.jmrit.logixng.Table
Table.ColumnNotFoundException, Table.CsvType, Table.RowNotFoundException
-
-
Constructor Summary
Constructors Constructor Description DefaultAnonymousTable(int numRows, int numColumns)DefaultAnonymousTable(java.lang.Object[][] data)Create a new anonymous table with an existing array of cells.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteColumn(int col)voiddeleteRow(int row)java.lang.ObjectgetCell(int row, int column)Get the value of a cell.intgetColumnNumber(java.lang.String columnName)Get the row number by name of row.intgetRowNumber(java.lang.String rowName)Get the row number by name of row.voidinsertColumn(int col)voidinsertRow(int row)intnumColumns()Get the number of columns in the table.intnumRows()Get the number of rows in the table.voidsetCell(java.lang.Object value, int row, int column)Get the value of a cell.voidstoreTableAsCSV(java.io.File file)Store the table to a CSV file.voidstoreTableAsCSV(java.io.File file, java.lang.String systemName, java.lang.String userName)Store the table to a CSV file.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.jmrit.logixng.Table
getCell, getCell, getCell, getCsvType, isCsvTypeSupported, setCell, setCell, setCsvType
-
-
-
-
Constructor Detail
-
DefaultAnonymousTable
public DefaultAnonymousTable(int numRows, int numColumns)
-
DefaultAnonymousTable
public DefaultAnonymousTable(@Nonnull java.lang.Object[][] data)
Create a new anonymous table with an existing array of cells. Row 0 has the column names and column 0 has the row names.- Parameters:
data- the data in the table. Note that this data is not copied to an new array but used by the table as is.
-
-
Method Detail
-
storeTableAsCSV
public void storeTableAsCSV(@Nonnull java.io.File file) throws java.io.FileNotFoundException
Store the table to a CSV file.- Specified by:
storeTableAsCSVin interfaceTable- Parameters:
file- the CSV file- Throws:
java.io.FileNotFoundException- if file not found
-
storeTableAsCSV
public void storeTableAsCSV(@Nonnull java.io.File file, @CheckForNull java.lang.String systemName, @CheckForNull java.lang.String userName) throws java.io.FileNotFoundException
Store the table to a CSV file. If system name and/or user name is not null, these values are used instead of the tables own system name and user name. If no system name and user name is given and the table is anonymous, no system name and user name is stored in the file.- Specified by:
storeTableAsCSVin interfaceTable- Parameters:
file- the CSV filesystemName- the system name of the tableuserName- the user name of the table- Throws:
java.io.FileNotFoundException- if file not found
-
getCell
public java.lang.Object getCell(int row, int column)
Get the value of a cell.
-
setCell
public void setCell(java.lang.Object value, int row, int column)
Get the value of a cell.
-
numRows
public int numRows()
Get the number of rows in the table.
-
numColumns
public int numColumns()
Get the number of columns in the table.- Specified by:
numColumnsin interfaceTable- Returns:
- the number of columns
-
getRowNumber
public int getRowNumber(java.lang.String rowName)
Get the row number by name of row.- Specified by:
getRowNumberin interfaceTable- Parameters:
rowName- the name of the row. If there is no row with this name, and rowName is a positive integer, that row number will be returned.- Returns:
- the row number
-
getColumnNumber
public int getColumnNumber(java.lang.String columnName)
Get the row number by name of row.- Specified by:
getColumnNumberin interfaceTable- Parameters:
columnName- the name of the column. If there is no column with this name, and columnName is a positive integer, that column number will be returned.- Returns:
- the column number
-
insertColumn
public void insertColumn(int col)
- Specified by:
insertColumnin interfaceAnonymousTable
-
deleteColumn
public void deleteColumn(int col)
- Specified by:
deleteColumnin interfaceAnonymousTable
-
insertRow
public void insertRow(int row)
- Specified by:
insertRowin interfaceAnonymousTable
-
deleteRow
public void deleteRow(int row)
- Specified by:
deleteRowin interfaceAnonymousTable
-
-