Class AbstractExcelSheetDataWriter

  • Direct Known Subclasses:
    Wrq2ExcelSheetDataWriter

    public abstract class AbstractExcelSheetDataWriter
    extends java.lang.Object
    Base class for writing a Wrs or a WrsRequest to an Excel sheet
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Vector<java.lang.Integer> colTypes  
      protected int currentColIdx  
      protected int currentRowIdx  
      protected static java.lang.String defaultSheetName  
      protected org.apache.logging.log4j.Logger log  
      protected java.util.Stack<java.lang.String> pathStack  
      protected org.apache.poi.ss.usermodel.Sheet sheet  
      protected java.lang.String sheetName  
      protected int startColIdx  
      protected int startRowIdx  
      protected boolean usingTemplate  
      protected org.apache.poi.ss.usermodel.Workbook workbook  
      protected java.util.List<java.util.Map<java.lang.String,​java.lang.String>> wrsHeaderCols  
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractExcelSheetDataWriter​(org.apache.poi.ss.usermodel.Workbook workbook, java.util.Stack<java.lang.String> pathStack, boolean includeHeader)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String attr​(javax.xml.stream.events.StartElement element, java.lang.String attrName)
      reads attribute
      protected void cleanup()
      Tasks to be done after the data is inserted
      protected org.apache.poi.ss.usermodel.Cell getCellAt​(int row, int col)  
      protected org.apache.poi.ss.usermodel.Cell getCellAtCursor()  
      protected java.lang.String getPath()  
      protected void moveToNextColumn()
      moves cursor to next column
      protected void moveToNextLine()
      moves cursor to next row and resets column cursor via #resetColCursor(), no new row or column is inserted into excel sheet at this operation, till de.businesscode.bcdui.wrs.export.Wrs2Excel.WrsContainerParser#writeCell(String, Map)
      protected void openSheet()
      To be called after it is guaranteed that rnd:Wrs2Excel, if given, is already read
      protected void resetColCursor()
      reset column cursor to setStartColIdx(int) , such as de.businesscode.bcdui.wrs.export.Wrs2Excel.WrsContainerParser#writeCell(String, Map) would start writing with a first column
      protected void resetRowColCursor()
      protected void resetRowColStartIdx()
      resets offset indexes for row, col and resets cursors
      protected void resetRowCursor()
      reset row cursor to setStartRowIdx(int) , such as moveToNextRow() would start with a first row
      protected void setStartColIdx​(int startColIdx)
      set column start index and reset column cursor to it via resetColCursor()
      protected void setStartRowIdx​(int startRowIdx)
      set row start index and reset row cursor to it via resetRowCursor()
      protected javax.xml.stream.events.XMLEvent track​(javax.xml.stream.events.XMLEvent event)
      call on every new event
      protected void writeCell​(java.lang.String cellValue)
      write cell at current cursor applying cell type from given property-map containing attributes from wrs:Header/wrs:Columns/wrs:C
      protected void writeHeaderCell​(java.lang.String cellValue)  
      protected void wrs2ExcelInfo​(javax.xml.stream.events.StartElement element)
      Evaluate optional information provided as a wrs:Wrs2ExcelInfo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • workbook

        protected final org.apache.poi.ss.usermodel.Workbook workbook
      • pathStack

        protected final java.util.Stack<java.lang.String> pathStack
      • usingTemplate

        protected final boolean usingTemplate
      • defaultSheetName

        protected static final java.lang.String defaultSheetName
        See Also:
        Constant Field Values
      • sheetName

        protected java.lang.String sheetName
      • startRowIdx

        protected int startRowIdx
      • startColIdx

        protected int startColIdx
      • currentColIdx

        protected int currentColIdx
      • currentRowIdx

        protected int currentRowIdx
      • sheet

        protected org.apache.poi.ss.usermodel.Sheet sheet
      • wrsHeaderCols

        protected java.util.List<java.util.Map<java.lang.String,​java.lang.String>> wrsHeaderCols
      • colTypes

        protected java.util.Vector<java.lang.Integer> colTypes
      • log

        protected org.apache.logging.log4j.Logger log
    • Constructor Detail

      • AbstractExcelSheetDataWriter

        public AbstractExcelSheetDataWriter​(org.apache.poi.ss.usermodel.Workbook workbook,
                                            java.util.Stack<java.lang.String> pathStack,
                                            boolean includeHeader)
    • Method Detail

      • openSheet

        protected void openSheet()
                          throws de.businesscode.bcdui.wrs.export.ExcelWriterException
        To be called after it is guaranteed that rnd:Wrs2Excel, if given, is already read
        Parameters:
        sheetName -
        Throws:
        de.businesscode.bcdui.wrs.export.ExcelWriterException
      • getCellAt

        protected org.apache.poi.ss.usermodel.Cell getCellAt​(int row,
                                                             int col)
        Returns:
        existing or created Cell at row / col
        Throws:
        de.businesscode.bcdui.wrs.export.ExcelWriterException
      • getCellAtCursor

        protected org.apache.poi.ss.usermodel.Cell getCellAtCursor()
                                                            throws de.businesscode.bcdui.wrs.export.ExcelWriterException
        Returns:
        existing or created Cell at cursor
        Throws:
        de.businesscode.bcdui.wrs.export.ExcelWriterException
      • moveToNextColumn

        protected void moveToNextColumn()
                                 throws de.businesscode.bcdui.wrs.export.ExcelWriterException
        moves cursor to next column
        Throws:
        de.businesscode.bcdui.wrs.export.ExcelWriterException
      • moveToNextLine

        protected void moveToNextLine()
                               throws de.businesscode.bcdui.wrs.export.ExcelWriterException
        moves cursor to next row and resets column cursor via #resetColCursor(), no new row or column is inserted into excel sheet at this operation, till de.businesscode.bcdui.wrs.export.Wrs2Excel.WrsContainerParser#writeCell(String, Map)
        Throws:
        de.businesscode.bcdui.wrs.export.ExcelWriterException
      • resetColCursor

        protected void resetColCursor()
        reset column cursor to setStartColIdx(int) , such as de.businesscode.bcdui.wrs.export.Wrs2Excel.WrsContainerParser#writeCell(String, Map) would start writing with a first column
      • resetRowColStartIdx

        protected void resetRowColStartIdx()
        resets offset indexes for row, col and resets cursors
      • setStartColIdx

        protected void setStartColIdx​(int startColIdx)
        set column start index and reset column cursor to it via resetColCursor()
        Parameters:
        startColIdx -
      • setStartRowIdx

        protected void setStartRowIdx​(int startRowIdx)
        set row start index and reset row cursor to it via resetRowCursor()
        Parameters:
        startRowIdx -
      • writeHeaderCell

        protected void writeHeaderCell​(java.lang.String cellValue)
                                throws de.businesscode.bcdui.wrs.export.ExcelWriterException
        Throws:
        de.businesscode.bcdui.wrs.export.ExcelWriterException
      • writeCell

        protected void writeCell​(java.lang.String cellValue)
                          throws de.businesscode.bcdui.wrs.export.ExcelWriterException
        write cell at current cursor applying cell type from given property-map containing attributes from wrs:Header/wrs:Columns/wrs:C
        Parameters:
        cellValue -
        Throws:
        de.businesscode.bcdui.wrs.export.ExcelWriterException
      • wrs2ExcelInfo

        protected void wrs2ExcelInfo​(javax.xml.stream.events.StartElement element)
        Evaluate optional information provided as a wrs:Wrs2ExcelInfo
        Parameters:
        element -
      • attr

        protected java.lang.String attr​(javax.xml.stream.events.StartElement element,
                                        java.lang.String attrName)
        reads attribute
        Parameters:
        element -
        attrName -
        Returns:
        empty string or attribute value
      • getPath

        protected java.lang.String getPath()
      • track

        protected javax.xml.stream.events.XMLEvent track​(javax.xml.stream.events.XMLEvent event)
        call on every new event
        Parameters:
        event -
      • cleanup

        protected void cleanup()
        Tasks to be done after the data is inserted