001package jmri.jmrit.logixng.implementation;
002
003import javax.annotation.CheckForNull;
004import javax.annotation.Nonnull;
005
006/**
007 * The default implementation of a NamedTable
008 * 
009 * @author Daniel Bergqvist 2018
010 */
011public class DefaultCsvNamedTable extends AbstractNamedTable {
012
013    private String _fileName;
014
015    private CsvType _csvType;
016    
017    /**
018     * Create a new named table.
019     * @param sys the system name
020     * @param user the user name or null if no user name
021     * @param fileName the file name of the CSV table
022     * @param data the data in the table. Note that this data is not copied to
023     *        a new array but used by the table as is.
024     * @param csvType the type of delimiter used for the file (comma or tab)
025     */
026    public DefaultCsvNamedTable(
027            @Nonnull String sys, @CheckForNull String user,
028            @CheckForNull String fileName,
029            @Nonnull Object[][] data,
030            CsvType csvType)
031            throws BadUserNameException, BadSystemNameException {
032        super(sys,user,data);
033        
034        _fileName = fileName;
035        _csvType = csvType;
036    }
037    @Override
038    public boolean isCsvTypeSupported() {
039        return true;
040    }
041    
042    public String getFileName() {
043        return _fileName;
044    }
045
046    public void setFileName(String fileName) {
047        this._fileName = fileName;
048    }
049
050    @Override
051    public void setCsvType(CsvType csvType) {
052        _csvType = csvType;
053    }
054
055    @Override
056    public CsvType getCsvType() {
057        return _csvType;
058    }
059
060}