Class Writer

    • Field Detail


        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.
        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.
        value - the level
      • getTypeMapper

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

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

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

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

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

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

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

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

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

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

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

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

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