public class UnloadableLazyWorkbookLoader extends Object implements WorkbookLoader
getWorkbook() first time is called, it is loaded from
file system and then is cached using WeakReference. If that workbook is used nowhere, it can at a certain moment be
garbage collected, and after that if getWorkbook() is called, the workbook will be loaded again. If you want
to prevent garbage collecting loaded Workbook instance, invoke setCanUnload(false).| Constructor and Description |
|---|
UnloadableLazyWorkbookLoader(IOpenSourceCodeModule fileSource) |
| Modifier and Type | Method and Description |
|---|---|
int |
getNumberOfSheets()
Get number of sheets in current workbook.
|
SheetLoader |
getSheetLoader(int sheetIndex)
Get the sheet accessor
|
SpreadsheetConstants |
getSpreadsheetConstants() |
org.apache.poi.ss.usermodel.Workbook |
getWorkbook()
Get the workbook.
|
boolean |
isCanUnload()
If true - the workbook can (but mustn't) be unloaded (for example if there is no enough memory).
|
protected org.apache.poi.ss.usermodel.Workbook |
loadWorkbook() |
void |
setCanUnload(boolean canUnload)
Set the flag that this workbook can or can't be unloaded.
|
public UnloadableLazyWorkbookLoader(IOpenSourceCodeModule fileSource)
public org.apache.poi.ss.usermodel.Workbook getWorkbook()
isCanUnload() state, when this method is repeatedly called, it can (but
mustn't) return different instances of workbook java object.getWorkbook in interface WorkbookLoaderisCanUnload()protected org.apache.poi.ss.usermodel.Workbook loadWorkbook()
public SheetLoader getSheetLoader(int sheetIndex)
getSheetLoader in interface WorkbookLoadersheetIndex - the sheet index in the workbookpublic boolean isCanUnload()
If true - the workbook can (but mustn't) be unloaded (for example if there is no enough memory). In this case
when the WorkbookLoader.getWorkbook() is repeatedly called, it can (but mustn't) return different instances of workbook
java object.
If false - the workbook is not unloaded and WorkbookLoader.getWorkbook() always returns the same Workbook instance.
isCanUnload in interface WorkbookLoaderWorkbookLoader.setCanUnload(boolean)public void setCanUnload(boolean canUnload)
WorkbookLoader.getWorkbook()
always returns the same Workbook instance.setCanUnload in interface WorkbookLoadercanUnload - the flag that this workbook can or can't be unloadedWorkbookLoader.isCanUnload()public int getNumberOfSheets()
getNumberOfSheets in interface WorkbookLoaderpublic SpreadsheetConstants getSpreadsheetConstants()
getSpreadsheetConstants in interface WorkbookLoaderCopyright © 2004–2019 OpenL Tablets. All rights reserved.