Class Writer

    • Field Detail

      • PLACEHOLDER_MAX

        public static final String PLACEHOLDER_MAX
        the placeholder for the maximum length for string values.
        See Also:
        Constant Field Values
      • m_Sheet

        protected SpreadSheet m_Sheet
        the underlying spreadm_Sheet.
      • m_Table

        protected String m_Table
        the table to write the data to.
      • m_ContentTypes

        protected Cell.ContentType[] m_ContentTypes
        the type used for the table.
      • m_MaxColumnLength

        protected int m_MaxColumnLength
        the maximum length for column names.
      • m_ColumnNames

        protected String[] m_ColumnNames
        the column names (shortened, disambiguated).
      • m_ColumnNameConversion

        protected ColumnNameConversion m_ColumnNameConversion
        the column name conversion.
      • m_StringColumnSQL

        protected String m_StringColumnSQL
        the SQL type for string columns.
      • m_MaxStringLength

        protected int m_MaxStringLength
        the maximum length for strings.
      • m_BatchSize

        protected int m_BatchSize
        the batch size.
      • m_Stopped

        protected boolean m_Stopped
        whether the last action was stopped.
    • Constructor Detail

      • Writer

        public Writer​(SpreadSheet sheet,
                      AbstractTypeMapper typeMapper,
                      String table,
                      int maxCol,
                      ColumnNameConversion colName,
                      String stringCol,
                      int maxStr,
                      int batchSize)
        Initializes the object.
        Parameters:
        sheet - the underlying spreadm_Sheet
        typeMapper - the type mapper to use
        table - the table name
        maxCol - the maximum length for column names
        colName - the conversion for column names
        stringCol - the SQL type for string columns
        maxStr - the maximum length for strings (get truncated)
    • Method Detail

      • generate

        protected void generate()
        Generates the table setup.
      • setLoggingLevel

        public void setLoggingLevel​(LoggingLevel value)
        Sets the logging level.
        Parameters:
        value - the level
      • getTypeMapper

        public AbstractTypeMapper getTypeMapper()
        Returns the type mapper in use.
        Returns:
        the type mapper
      • getTable

        public String getTable()
        Returns the table to write the data to.
        Returns:
        the table name
      • getColumnNameConversion

        public ColumnNameConversion getColumnNameConversion()
        Returns how to convert the column headers into SQL table column names.
        Returns:
        the conversion
      • getMaxStringLength

        public int getMaxStringLength()
        Returns the maximum length for strings.
        Returns:
        the maximum
      • getStringColumnSQL

        public String getStringColumnSQL()
        Returns the SQL type for string columns for the CREATE statement.
        Returns:
        the SQL type
      • fixColumnName

        protected String fixColumnName​(String s)
        Fixes the column name.
        Parameters:
        s - the column name to fix
        Returns:
        the fixed name
      • getCreateStatement

        public String getCreateStatement()
        Generates the CREATE TABLE statement.
        Returns:
        the SQL statement
      • getInsertStatement

        public String getInsertStatement()
        Generates a statement for an insert statement.
        Returns:
        the insert statement
      • getColumnNames

        public String[] getColumnNames()
        Returns the generated column names.
        Returns:
        the column names
      • getContentTypes

        public Cell.ContentType[] getContentTypes()
        Returns the content types of the columns.
        Returns:
        the content types
      • createTable

        public String createTable​(SQLIntf sql)
        Creates the table.
        Parameters:
        sql - for executing queries
        Returns:
        null if everything OK, otherwise error message
      • writeData

        public String writeData​(SQLIntf sql)
        Writes the data to the table.
        Parameters:
        sql - for performing the writing
        Returns:
        null if everything OK, otherwise error message
      • stopExecution

        public void stopExecution()
        Stops the execution.
        Specified by:
        stopExecution in interface Stoppable