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 void
deleteColumn(int col)
void
deleteRow(int row)
java.lang.Object
getCell(int row, int column)
Get the value of a cell.int
getColumnNumber(java.lang.String columnName)
Get the row number by name of row.int
getRowNumber(java.lang.String rowName)
Get the row number by name of row.void
insertColumn(int col)
void
insertRow(int row)
int
numColumns()
Get the number of columns in the table.int
numRows()
Get the number of rows in the table.void
setCell(java.lang.Object value, int row, int column)
Get the value of a cell.void
storeTableAsCSV(java.io.File file)
Store the table to a CSV file.void
storeTableAsCSV(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:
storeTableAsCSV
in 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:
storeTableAsCSV
in 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:
numColumns
in interfaceTable
- Returns:
- the number of columns
-
getRowNumber
public int getRowNumber(java.lang.String rowName)
Get the row number by name of row.- Specified by:
getRowNumber
in 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:
getColumnNumber
in 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:
insertColumn
in interfaceAnonymousTable
-
deleteColumn
public void deleteColumn(int col)
- Specified by:
deleteColumn
in interfaceAnonymousTable
-
insertRow
public void insertRow(int row)
- Specified by:
insertRow
in interfaceAnonymousTable
-
deleteRow
public void deleteRow(int row)
- Specified by:
deleteRow
in interfaceAnonymousTable
-
-