Class TransposeSpreadSheet

    • Field Detail

      • m_UseHeaderAsFirstColumn

        protected boolean m_UseHeaderAsFirstColumn
        whether to add the header row as first column.
      • m_UseFirstColumnAsHeader

        protected boolean m_UseFirstColumnAsHeader
        whether to use the first column as header.
      • m_ColumnPrefix

        protected String m_ColumnPrefix
        the column prefix if the first column is not used as header.
    • Constructor Detail

      • TransposeSpreadSheet

        public TransposeSpreadSheet()
    • Method Detail

      • setUseHeaderAsFirstColumn

        public void setUseHeaderAsFirstColumn​(boolean value)
        Sets whether to use the current header as first column.
        Parameters:
        value - true if to use header
      • getUseHeaderAsFirstColumn

        public boolean getUseHeaderAsFirstColumn()
        Returns whether to use the current header as first column.
        Returns:
        true if to use header
      • useHeaderAsFirstColumnTipText

        public String useHeaderAsFirstColumnTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setUseFirstColumnAsHeader

        public void setUseFirstColumnAsHeader​(boolean value)
        Sets whether to use the first column as new header.
        Parameters:
        value - true if to use column
      • getUseFirstColumnAsHeader

        public boolean getUseFirstColumnAsHeader()
        Returns whether to use the first column as new header.
        Returns:
        true if to use column
      • useFirstColumnAsHeaderTipText

        public String useFirstColumnAsHeaderTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setColumnPrefix

        public void setColumnPrefix​(String value)
        Sets the column prefix if the first column is not used as header.
        Parameters:
        value - the prefix
      • getColumnPrefix

        public String getColumnPrefix()
        Returns whether to use the first column as new header.
        Returns:
        true if to use column
      • columnPrefixTipText

        public String columnPrefixTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • toMatrix

        protected Cell[][] toMatrix​(SpreadSheet sheet)
        Turns the spreadsheet into a matrix of Cell objects (first row is header).
        Parameters:
        sheet - the spreadsheet to turn into matrix
        Returns:
        the generated matrix, missing cells are depicted by null
      • transpose

        protected Cell[][] transpose​(Cell[][] matrix)
        Transposes the matrix.
        Parameters:
        matrix - the matrix to transpose
        Returns:
        the transposed matrix
      • convert

        protected SpreadSheet convert​(SpreadSheet input)
                               throws Exception
        Performs the actual conversion.

        Input spreadsheet:
         +----+----+----+
         | c1 | c2 | c3 |
         +====+====+====+
         | A  | B  | C  |
         +----+----+----+
         | D  | E  | F  |
         +----+----+----+
         
         m_UseFirstColumnAsHeader = FAH
         m_HeaderAsFirstColumn    = HAF
         
        !FAH & !HAF:
         +----+----+
         | P1 | P2 |
         +====+====+
         | A  | D  |
         +----+----+
         | B  | E  |
         +----+----+
         | C  | F  |
         +----+----+
         
        FAH & !HAF:
         +----+----+
         | A  | D  |
         +====+====+
         | B  | E  |
         +----+----+
         | C  | F  |
         +----+----+
         
        !FAH & HAF:
         +----+----+----+
         | P1 | P2 | P3 |
         +====+====+====+
         | c1 | A  | D  |
         +----+----+----+
         | c2 | B  | E  |
         +----+----+----+
         | c3 | C  | F  |
         +----+----+----+
         
        FAH & HAF:
         +----+----+----+
         | c1 | A  | D  |
         +====+====+====+
         | c2 | B  | E  |
         +----+----+----+
         | c3 | C  | F  |
         +----+----+----+
         
        Specified by:
        convert in class AbstractSpreadSheetConversion
        Parameters:
        input - the incoming spreadsheet
        Returns:
        the converted data
        Throws:
        Exception - if something goes wrong with the conversion