xelem.3.0

nl.fountain.xelem.lex
Class WorkbookListener

java.lang.Object
  extended by nl.fountain.xelem.lex.DefaultExcelReaderListener
      extended by nl.fountain.xelem.lex.WorkbookListener
All Implemented Interfaces:
ExcelReaderListener

public class WorkbookListener
extends DefaultExcelReaderListener

A concrete implementation of ExcelReaderListener. Listens to events, values and instances fired by ExcelReader and (re)constructs the Workbook. After the read has completed the current workbook may be obtained by getWorkbook().

Since:
xelem.2.0

Constructor Summary
WorkbookListener()
           
 
Method Summary
 Workbook getWorkbook()
          Gets the current workbook.
 void setAutoFilter(int sheetIndex, String sheetName, AutoFilter autoFilter)
          Called by event dispatcher.
 void setColumn(int sheetIndex, String sheetName, Column column)
          Called by event dispatcher.
 void setDocumentProperties(DocumentProperties docProps)
          Called by event dispatcher.
 void setExcelWorkbook(ExcelWorkbook excelWb)
          Called by event dispatcher.
 void setNamedRange(int sheetIndex, String sheetName, NamedRange namedRange)
          Called by event dispatcher.
 void setNamedRange(NamedRange namedRange)
          Called by event dispatcher.
 void setRow(int sheetIndex, String sheetName, Row row)
          Called by event dispatcher.
 void setWorksheetOptions(int sheetIndex, String sheetName, WorksheetOptions wsOptions)
          Called by event dispatcher.
 void startTable(int sheetIndex, String sheetName, Table table)
          Called by event dispatcher.
 void startWorkbook(String systemID)
          Called by event dispatcher.
 void startWorksheet(int sheetIndex, Worksheet sheet)
          Called by event dispatcher.
 
Methods inherited from class nl.fountain.xelem.lex.DefaultExcelReaderListener
endDocument, endWorksheet, processingInstruction, setCell, startDocument
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkbookListener

public WorkbookListener()
Method Detail

getWorkbook

public Workbook getWorkbook()
Gets the current workbook.

Returns:
the workbook that was read

startWorkbook

public void startWorkbook(String systemID)
Called by event dispatcher. Recieve notification of the start of the Workbook tag. Creates a new XLWorkbook. The workbookName may be set to a relevant portion of the passed systemID. The fileName of the workbook is set to systemID. The newly constructed Workbook is made the current workbook.

Specified by:
startWorkbook in interface ExcelReaderListener
Overrides:
startWorkbook in class DefaultExcelReaderListener
Parameters:
systemID - the systemID or "source" if no systemID was encountered

setDocumentProperties

public void setDocumentProperties(DocumentProperties docProps)
Called by event dispatcher. Recieve notification of the the construction of DocumentProperties. The passed docProps is added to the current workbook.

Specified by:
setDocumentProperties in interface ExcelReaderListener
Overrides:
setDocumentProperties in class DefaultExcelReaderListener
Parameters:
docProps - fully populated instance of DocumentProperties

setExcelWorkbook

public void setExcelWorkbook(ExcelWorkbook excelWb)
Called by event dispatcher. Recieve notification of the the construction of ExcelWorkbook. The passed excelWb is added to the current workbook.

Specified by:
setExcelWorkbook in interface ExcelReaderListener
Overrides:
setExcelWorkbook in class DefaultExcelReaderListener
Parameters:
excelWb - fully populated instance of ExcelWorkbook

setNamedRange

public void setNamedRange(NamedRange namedRange)
Called by event dispatcher. Recieve notification of the the construction of a NamedRange on the workbook level. The passed namedRange is added to the current workbook.

Specified by:
setNamedRange in interface ExcelReaderListener
Overrides:
setNamedRange in class DefaultExcelReaderListener
Parameters:
namedRange - fully populated instance of NamedRange

startWorksheet

public void startWorksheet(int sheetIndex,
                           Worksheet sheet)
Called by event dispatcher. Recieve notification of the the start of a Worksheet tag. The passed sheet is added to the current workbook and is made the current worksheet.

Specified by:
startWorksheet in interface ExcelReaderListener
Overrides:
startWorksheet in class DefaultExcelReaderListener
Parameters:
sheetIndex - the index of the encountered sheet. 0-based.
sheet - dummy instance of Worksheet. Only the (xml-)attributes of the Worksheet-element have been set on the instance

setNamedRange

public void setNamedRange(int sheetIndex,
                          String sheetName,
                          NamedRange namedRange)
Called by event dispatcher. Recieve notification of the the construction of a NamedRange on the worksheet level. The passed namedRange is added to the current worksheet.

Specified by:
setNamedRange in interface ExcelReaderListener
Overrides:
setNamedRange in class DefaultExcelReaderListener
Parameters:
sheetIndex - the index of the worksheet (0-based)
sheetName - the name of the worksheet where the namedRange was found
namedRange - fully populated instance of NamedRange

startTable

public void startTable(int sheetIndex,
                       String sheetName,
                       Table table)
Called by event dispatcher. Recieve notification of the start of a Table tag. The passed table is added to the current worksheet and is made the current table.

Specified by:
startTable in interface ExcelReaderListener
Overrides:
startTable in class DefaultExcelReaderListener
Parameters:
sheetIndex - the index of the worksheet (0-based)
sheetName - the name of the worksheet where the table was found
table - dummy instance of Table. Only the (xml-)attributes of the Table-element have been set on the instance

setColumn

public void setColumn(int sheetIndex,
                      String sheetName,
                      Column column)
Called by event dispatcher. Recieve notification of the the construction of a Column. The column is fully populated, it's column index has been set and can be obtained by column.getIndex(). The passed column is added to the current table.

Specified by:
setColumn in interface ExcelReaderListener
Overrides:
setColumn in class DefaultExcelReaderListener
Parameters:
sheetIndex - the index of the worksheet (0-based)
sheetName - the name of the worksheet where the column was found
column - fully populated instance of Column

setRow

public void setRow(int sheetIndex,
                   String sheetName,
                   Row row)
Called by event dispatcher. Recieve notification of the the construction of a Row. The row is fully populated, it's row index has been set and can be obtained by row.getIndex(). The passed row is added to the current table.

Specified by:
setRow in interface ExcelReaderListener
Overrides:
setRow in class DefaultExcelReaderListener
Parameters:
sheetIndex - the index of the worksheet (0-based)
sheetName - the name of the worksheet where the row was found
row - fully populated instance of Row

setWorksheetOptions

public void setWorksheetOptions(int sheetIndex,
                                String sheetName,
                                WorksheetOptions wsOptions)
Called by event dispatcher. Recieve notification of the the construction of WorksheetOptions. The passed wsOptions is added to the current worksheet.

Specified by:
setWorksheetOptions in interface ExcelReaderListener
Overrides:
setWorksheetOptions in class DefaultExcelReaderListener
Parameters:
sheetIndex - the index of the worksheet (0-based)
sheetName - the name of the worksheet where the worksheetOptions was found
wsOptions - fully populated instance of WorksheetOptions

setAutoFilter

public void setAutoFilter(int sheetIndex,
                          String sheetName,
                          AutoFilter autoFilter)
Called by event dispatcher. Recieve notification of the the construction of AutoFilter. The passed autoFilter is added to the current worksheet.

Specified by:
setAutoFilter in interface ExcelReaderListener
Overrides:
setAutoFilter in class DefaultExcelReaderListener
Parameters:
sheetIndex - the index of the worksheet (0-based)
sheetName - the name of the worksheet where the autoFilter was found
autoFilter - fully populated instance of AutoFilter

xelem.3.0