Class AbstractNamedTable
java.lang.Object
jmri.implementation.AbstractNamedBean
jmri.jmrit.logixng.implementation.AbstractNamedTable
- All Implemented Interfaces:
Comparable<NamedBean>,PropertyChangeProvider,NamedTable,Table,NamedBean
- Direct Known Subclasses:
DefaultCsvNamedTable,DefaultInternalNamedTable
The default implementation of a NamedTable
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameExceptionNested classes/interfaces inherited from interface jmri.jmrit.logixng.Table
Table.ColumnNotFoundException, Table.CsvType, Table.RowNotFoundException -
Field Summary
FieldsFields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, registerFields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionAbstractNamedTable(String sys, String user, int numRows, int numColumns) Create a new named table.AbstractNamedTable(String systemName, String userName, Object[][] data) Create a new named table with an existing array of cells.AbstractNamedTable(String systemName, String userName, String fileName, Object[][] data) Create a new named table with an existing array of cells. -
Method Summary
Modifier and TypeMethodDescriptionFor instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.getCell(int row, int column) Get the value of a cell.intgetColumnNumber(String columnName) Get the row number by name of row.intgetRowNumber(String rowName) Get the row number by name of row.intgetState()Provide generic access to internal state.static NamedTableloadTableFromCSV_File(String systemName, String userName, File file, boolean registerInManager, Table.CsvType csvType) static NamedTableloadTableFromCSV_File(String systemName, String userName, String fileName, boolean registerInManager, Table.CsvType csvType) static NamedTableloadTableFromCSV_Text(String systemName, String userName, String text, boolean registerInManager, Table.CsvType csvType) intGet the number of columns in the table.intnumRows()Get the number of rows in the table.voidGet the value of a cell.voidsetState(int s) Provide generic access to internal state.voidstoreTableAsCSV(File file) Store the table to a CSV file.voidstoreTableAsCSV(File file, String systemName, String userName) Store the table to a CSV file.Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, dispose, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRef, vetoableChangeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, dispose, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef, vetoableChangeMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from interface jmri.jmrit.logixng.Table
getCell, getCell, getCell, getCsvType, isCsvTypeSupported, setCell, setCell, setCsvType
-
Field Details
-
_internalTable
-
-
Constructor Details
-
AbstractNamedTable
public AbstractNamedTable(@Nonnull String sys, @CheckForNull String user, int numRows, int numColumns) throws NamedBean.BadUserNameException, NamedBean.BadSystemNameException Create a new named table.- Parameters:
sys- the system nameuser- the user name or null if no user namenumRows- the number or rows in the tablenumColumns- the number of columns in the table- Throws:
NamedBean.BadUserNameException- when neededNamedBean.BadSystemNameException- when needed
-
AbstractNamedTable
public AbstractNamedTable(@Nonnull String systemName, @CheckForNull String userName, @Nonnull Object[][] data) throws NamedBean.BadUserNameException, NamedBean.BadSystemNameException Create a new named table with an existing array of cells. Row 0 has the column names and column 0 has the row names.- Parameters:
systemName- the system nameuserName- the user namedata- the data in the table. Note that this data is not copied to a new array but used by the table as is.- Throws:
NamedBean.BadUserNameException- when neededNamedBean.BadSystemNameException- when needed
-
AbstractNamedTable
public AbstractNamedTable(@Nonnull String systemName, @CheckForNull String userName, @Nonnull String fileName, @Nonnull Object[][] data) throws NamedBean.BadUserNameException, NamedBean.BadSystemNameException Create a new named table with an existing array of cells. Row 0 has the column names and column 0 has the row names.- Parameters:
systemName- the system nameuserName- the user namefileName- the file name of the CSV tabledata- the data in the table. Note that this data is not copied to a new array but used by the table as is.- Throws:
NamedBean.BadUserNameException- when neededNamedBean.BadSystemNameException- when needed
-
-
Method Details
-
loadTableFromCSV_Text
@Nonnull public static NamedTable loadTableFromCSV_Text(@Nonnull String systemName, @CheckForNull String userName, @Nonnull String text, boolean registerInManager, Table.CsvType csvType) throws NamedBean.BadUserNameException, NamedBean.BadSystemNameException, IOException -
loadTableFromCSV_File
@Nonnull public static NamedTable loadTableFromCSV_File(@Nonnull String systemName, @CheckForNull String userName, @Nonnull String fileName, boolean registerInManager, Table.CsvType csvType) throws NamedBean.BadUserNameException, NamedBean.BadSystemNameException, IOException -
loadTableFromCSV_File
@Nonnull public static NamedTable loadTableFromCSV_File(@Nonnull String systemName, @CheckForNull String userName, @Nonnull File file, boolean registerInManager, Table.CsvType csvType) throws NamedBean.BadUserNameException, NamedBean.BadSystemNameException, IOException -
storeTableAsCSV
Store the table to a CSV file.- Specified by:
storeTableAsCSVin interfaceTable- Parameters:
file- the CSV file- Throws:
FileNotFoundException- if file not found
-
storeTableAsCSV
public 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.- Specified by:
storeTableAsCSVin interfaceTable- Parameters:
file- the CSV filesystemName- the system name of the tableuserName- the user name of the table- Throws:
FileNotFoundException- if file not found
-
setState
Description copied from interface:NamedBeanProvide generic access to internal state.This generally shouldn't be used by Java code; use the class-specific form instead (e.g. setCommandedState in Turnout). This is provided to make scripts access easier to read.
- Specified by:
setStatein interfaceNamedBean- Parameters:
s- the state- Throws:
JmriException- general error when setting the state fails
-
getState
Description copied from interface:NamedBeanProvide generic access to internal state.This generally shouldn't be used by Java code; use the class-specific form instead (e.g. getCommandedState in Turnout). This is provided to make scripts easier to read.
-
getBeanType
Description copied from interface:NamedBeanFor instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.- Specified by:
getBeanTypein interfaceNamedBean- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
getCell
Get the value of a cell. -
setCell
Get the value of a cell. -
numRows
Get the number of rows in the table. -
numColumns
Get the number of columns in the table.- Specified by:
numColumnsin interfaceTable- Returns:
- the number of columns
-
getRowNumber
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
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
-