Package org.openl.rules.lang.xls.load
Class GreedyLazyWorkbookLoader
- java.lang.Object
-
- org.openl.rules.lang.xls.load.GreedyLazyWorkbookLoader
-
- All Implemented Interfaces:
WorkbookLoader
public class GreedyLazyWorkbookLoader extends Object implements WorkbookLoader
Lazily loads workbook only when it's needed but never unloads it
-
-
Constructor Summary
Constructors Constructor Description GreedyLazyWorkbookLoader(IOpenSourceCodeModule fileSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetNumberOfSheets()Get number of sheets in current workbook.SheetLoadergetSheetLoader(int sheetIndex)Get the sheet accessorSpreadsheetConstantsgetSpreadsheetConstants()org.apache.poi.ss.usermodel.WorkbookgetWorkbook()Get the workbook.booleanisCanUnload()If true - the workbook can (but mustn't) be unloaded (for example if there is no enough memory).voidsetCanUnload(boolean canUnload)Set the flag that this workbook can or cannot be unloaded.
-
-
-
Constructor Detail
-
GreedyLazyWorkbookLoader
public GreedyLazyWorkbookLoader(IOpenSourceCodeModule fileSource)
-
-
Method Detail
-
getWorkbook
public org.apache.poi.ss.usermodel.Workbook getWorkbook()
Description copied from interface:WorkbookLoaderGet the workbook. Depending on implementation andWorkbookLoader.isCanUnload()state, when this method is repeatedly called, it can (but mustn't) return different instances of workbook java object.- Specified by:
getWorkbookin interfaceWorkbookLoader- Returns:
- loaded workbook
- See Also:
WorkbookLoader.isCanUnload()
-
getSheetLoader
public SheetLoader getSheetLoader(int sheetIndex)
Description copied from interface:WorkbookLoaderGet the sheet accessor- Specified by:
getSheetLoaderin interfaceWorkbookLoader- Parameters:
sheetIndex- the sheet index in the workbook- Returns:
- object that provides access to the specified sheet of current workbook
-
isCanUnload
public boolean isCanUnload()
Description copied from interface:WorkbookLoaderIf 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.- Specified by:
isCanUnloadin interfaceWorkbookLoader- Returns:
- the flag that this workbook can or cannot be unloaded.
- See Also:
WorkbookLoader.setCanUnload(boolean)
-
setCanUnload
public void setCanUnload(boolean canUnload)
Description copied from interface:WorkbookLoaderSet the flag that this workbook can or cannot be unloaded. If workbook cannot be unloaded (for example when we edit the workbook) internal implementation should always keep strong reference to workbook andWorkbookLoader.getWorkbook()always returns the same Workbook instance.- Specified by:
setCanUnloadin interfaceWorkbookLoader- Parameters:
canUnload- the flag that this workbook can or cannot be unloaded- See Also:
WorkbookLoader.isCanUnload()
-
getNumberOfSheets
public int getNumberOfSheets()
Description copied from interface:WorkbookLoaderGet number of sheets in current workbook.- Specified by:
getNumberOfSheetsin interfaceWorkbookLoader- Returns:
- the number of sheets in current workbook
-
getSpreadsheetConstants
public SpreadsheetConstants getSpreadsheetConstants()
- Specified by:
getSpreadsheetConstantsin interfaceWorkbookLoader
-
-