Package jmri.jmrit.logixng
Interface Table
- All Known Subinterfaces:
AnonymousTable,NamedTable
- All Known Implementing Classes:
AbstractNamedTable,DefaultAnonymousTable,DefaultCsvNamedTable,DefaultInternalNamedTable
public interface Table
Represent a Table.
A table is a two dimensional array where the rows and columns may have names.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic enumThe available types of CSV from which to load a table The default is TABBED, as that was previously the only choice TABBED results in parsing the CSV file with tabs as the delimiters COMMA uses csvFormat of RFC-4180, which is the standard Comma Seperated Value format, but does not allow empty lines.static class -
Method Summary
Modifier and TypeMethodDescriptiondefault ObjectgetCell(int row) Get the value of a cell.getCell(int row, int column) Get the value of a cell.default ObjectGet the value of a cell.default ObjectGet the value of a cell.intgetColumnNumber(String columnName) Get the row number by name of row.default Table.CsvTypeintgetRowNumber(String rowName) Get the row number by name of row.default booleanintGet the number of columns in the table.intnumRows()Get the number of rows in the table.voidGet the value of a cell.default voidSet the value of a cell.default voidSet the value of a cell.default voidsetCsvType(Table.CsvType csvType) voidstoreTableAsCSV(File file) Store the table to a CSV file.voidstoreTableAsCSV(File file, String systemName, String userName) Store the table to a CSV file.
-
Method Details
-
getCell
Get the value of a cell. If the table has both rows and columns, the value of the first column will be returned.- Parameters:
row- the row of the cell or null if all rows should be returned- Returns:
- the value of the cell
-
getCell
Get the value of a cell.- Parameters:
row- the row of the cellcolumn- the column of the cell- Returns:
- the value of the cell
-
getCell
Get the value of a cell. If the table has both rows and columns, the value of the first column will be returned.- Parameters:
row- the row of the cell or null if all rows should be returned- Returns:
- the value of the cell
- Throws:
Table.RowNotFoundException- if the row is not found
-
getCell
default Object getCell(@Nonnull String row, @Nonnull String column) throws Table.RowNotFoundException, Table.ColumnNotFoundException Get the value of a cell.- Parameters:
row- the row of the cell. If this string is a name of a row, that row is used. If it's not a name of a row, but an integer value, that index is used, where row 0 is the name of the row.column- the column of the cell. If this string is a name of a column, that column is used. If it's not a name of a column, but an integer value, that index is used, where column 0 is the name of the column.- Returns:
- the value of the cell
- Throws:
Table.RowNotFoundException- if the row is not foundTable.ColumnNotFoundException- if the column is not found
-
setCell
Get the value of a cell.- Parameters:
value- the new value of the cellrow- the row of the cellcolumn- the column of the cell
-
setCell
Set the value of a cell. If the table has both rows and columns, the value of the first column will be returned.- Parameters:
value- the new value of the cellrow- the row of the cell- Throws:
Table.RowNotFoundException- if the row is not found
-
setCell
default void setCell(Object value, String row, String column) throws Table.RowNotFoundException, Table.ColumnNotFoundException Set the value of a cell.- Parameters:
value- the new value of the cellrow- the row of the cell. If this string is a name of a row, that row is used. If it's not a name of a row, but an integer value, that index is used, where row 0 is the name of the row.column- the column of the cell. If this string is a name of a column, that column is used. If it's not a name of a column, but an integer value, that index is used, where column 0 is the name of the column.- Throws:
Table.RowNotFoundException- if the row is not foundTable.ColumnNotFoundException- if the column is not found
-
numRows
int numRows()Get the number of rows in the table.- Returns:
- the number of rows
-
numColumns
int numColumns()Get the number of columns in the table.- Returns:
- the number of columns
-
getRowNumber
Get the row number by name of row.- 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
- Throws:
Table.RowNotFoundException- if the row is not found
-
getColumnNumber
Get the row number by name of row.- 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
- Throws:
Table.ColumnNotFoundException- if the column is not found
-
isCsvTypeSupported
-
setCsvType
-
getCsvType
-
storeTableAsCSV
Store the table to a CSV file.- Parameters:
file- the CSV file- Throws:
FileNotFoundException- if file not found
-
storeTableAsCSV
void storeTableAsCSV(@Nonnull File file, @CheckForNull String systemName, @CheckForNull String userName) throws 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.- Parameters:
file- the CSV filesystemName- the system name of the tableuserName- the user name of the table- Throws:
FileNotFoundException- if file not found
-