Class AbstractNamedTable
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.jmrit.logixng.implementation.AbstractNamedTable
-
- All Implemented Interfaces:
java.lang.Comparable<NamedBean>,PropertyChangeProvider,NamedTable,Table,NamedBean
- Direct Known Subclasses:
DefaultCsvNamedTable,DefaultInternalNamedTable
public abstract class AbstractNamedTable extends AbstractNamedBean implements NamedTable
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.DuplicateSystemNameException
-
Nested classes/interfaces inherited from interface jmri.jmrit.logixng.Table
Table.ColumnNotFoundException, Table.CsvType, Table.RowNotFoundException
-
-
Field Summary
Fields Modifier and Type Field Description protected AnonymousTable_internalTable-
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
-
Fields 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
Constructors Constructor Description AbstractNamedTable(java.lang.String sys, java.lang.String user, int numRows, int numColumns)Create a new named table.AbstractNamedTable(java.lang.String systemName, java.lang.String userName, java.lang.Object[][] data)Create a new named table with an existing array of cells.AbstractNamedTable(java.lang.String systemName, java.lang.String userName, java.lang.String fileName, java.lang.Object[][] data)Create a new named table with an existing array of cells.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetBeanType()For 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.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.intgetState()Provide generic access to internal state.static NamedTableloadTableFromCSV_File(java.lang.String systemName, java.lang.String userName, java.io.File file, boolean registerInManager, Table.CsvType csvType)static NamedTableloadTableFromCSV_File(java.lang.String systemName, java.lang.String userName, java.lang.String fileName, boolean registerInManager, Table.CsvType csvType)static NamedTableloadTableFromCSV_Text(java.lang.String systemName, java.lang.String userName, java.lang.String text, boolean registerInManager, Table.CsvType csvType)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.voidsetState(int s)Provide generic access to internal state.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 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, vetoableChange
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods 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, vetoableChange
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface jmri.jmrit.logixng.Table
getCell, getCell, getCell, getCsvType, isCsvTypeSupported, setCell, setCell, setCsvType
-
-
-
-
Field Detail
-
_internalTable
protected final AnonymousTable _internalTable
-
-
Constructor Detail
-
AbstractNamedTable
public AbstractNamedTable(@Nonnull java.lang.String sys, @CheckForNull java.lang.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 java.lang.String systemName, @CheckForNull java.lang.String userName, @Nonnull java.lang.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 java.lang.String systemName, @CheckForNull java.lang.String userName, @Nonnull java.lang.String fileName, @Nonnull java.lang.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 Detail
-
loadTableFromCSV_Text
@Nonnull public static NamedTable loadTableFromCSV_Text(@Nonnull java.lang.String systemName, @CheckForNull java.lang.String userName, @Nonnull java.lang.String text, boolean registerInManager, Table.CsvType csvType) throws NamedBean.BadUserNameException, NamedBean.BadSystemNameException, java.io.IOException
- Throws:
NamedBean.BadUserNameExceptionNamedBean.BadSystemNameExceptionjava.io.IOException
-
loadTableFromCSV_File
@Nonnull public static NamedTable loadTableFromCSV_File(@Nonnull java.lang.String systemName, @CheckForNull java.lang.String userName, @Nonnull java.lang.String fileName, boolean registerInManager, Table.CsvType csvType) throws NamedBean.BadUserNameException, NamedBean.BadSystemNameException, java.io.IOException
- Throws:
NamedBean.BadUserNameExceptionNamedBean.BadSystemNameExceptionjava.io.IOException
-
loadTableFromCSV_File
@Nonnull public static NamedTable loadTableFromCSV_File(@Nonnull java.lang.String systemName, @CheckForNull java.lang.String userName, @Nonnull java.io.File file, boolean registerInManager, Table.CsvType csvType) throws NamedBean.BadUserNameException, NamedBean.BadSystemNameException, java.io.IOException
- Throws:
NamedBean.BadUserNameExceptionNamedBean.BadSystemNameExceptionjava.io.IOException
-
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
-
setState
public void setState(int s) throws JmriException
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
public int 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
public java.lang.String 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
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
-
-