Package io.keikai.model.impl.sys.formula
Class FormulaEngineImpl
- java.lang.Object
-
- io.keikai.model.impl.sys.formula.FormulaEngineImpl
-
- All Implemented Interfaces:
FormulaEngine
,Serializable
- Direct Known Subclasses:
FormulaEngineEx
public class FormulaEngineImpl extends Object implements FormulaEngine, Serializable
A formula engine implemented by ZPOI- Author:
- Pao
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
FormulaEngineImpl.ErrorFormulaExpressionImpl
protected static class
FormulaEngineImpl.EvalContext
protected static class
FormulaEngineImpl.EvaluationResultImpl
protected static interface
FormulaEngineImpl.FormulaAdjuster
protected static class
FormulaEngineImpl.FormulaExpressionImpl
-
Field Summary
Fields Modifier and Type Field Description static String
KEY_EVALUATORS
protected static IStabilityClassifier
noCacheClassifier
-
Fields inherited from interface io.keikai.model.sys.formula.FormulaEngine
KEY_EXTERNAL_BOOK_NAMES, KEY_FORMULA_CACHE, KEY_SHEET_INDEXES
-
-
Constructor Summary
Constructors Constructor Description FormulaEngineImpl()
-
Method Summary
-
-
-
Field Detail
-
KEY_EVALUATORS
public static final String KEY_EVALUATORS
- See Also:
- Constant Field Values
-
noCacheClassifier
protected static final IStabilityClassifier noCacheClassifier
-
-
Method Detail
-
parse
public FormulaExpression parse(String formula, FormulaParseContext context)
- Specified by:
parse
in interfaceFormulaEngine
-
shouldNormalize
protected static boolean shouldNormalize(Locale runtimeLocale)
-
parse
public Ptg[] parse(String formula, FormulaParsingWorkbook book, int sheetIndex, FormulaParseContext context)
-
renderFormula
protected String renderFormula(ParsingBook parsingBook, String formula, Ptg[] tokens, boolean always)
-
toDependRef
protected Ref toDependRef(FormulaParseContext ctx, ParsingBook parsingBook, Ptg ptg, int ptgIndex)
-
evaluateOnly
public void evaluateOnly(FormulaExpression expr, FormulaEvaluationContext context)
Description copied from interface:FormulaEngine
Evaluates the expression only, without returning the result.- Specified by:
evaluateOnly
in interfaceFormulaEngine
-
evaluate
public EvaluationResult evaluate(FormulaExpression expr, FormulaEvaluationContext context)
- Specified by:
evaluate
in interfaceFormulaEngine
-
evaluateFormula
protected EvaluationResult evaluateFormula(FormulaExpression expr, FormulaEvaluationContext context, EvalBook evalBook, WorkbookEvaluator evaluator) throws FormulaParseException, Exception
- Throws:
FormulaParseException
Exception
-
convertToEvaluationResult
public static EvaluationResult convertToEvaluationResult(ValueEval value) throws EvaluationException
- Throws:
EvaluationException
-
getResolvedValue
protected static io.keikai.model.impl.sys.formula.FormulaEngineImpl.ResultValueEval getResolvedValue(ValueEval value) throws EvaluationException
- Throws:
EvaluationException
-
getXelContext
protected Object getXelContext()
-
setXelContext
protected void setXelContext(Object ctx)
-
clearCache
public void clearCache(FormulaClearContext context)
- Specified by:
clearCache
in interfaceFormulaEngine
-
clearColumnCache
public void clearColumnCache(FormulaClearContext context, int start, int end)
- Specified by:
clearColumnCache
in interfaceFormulaEngine
-
move
public FormulaExpression move(String formula, SheetRegion region, int rowOffset, int columnOffset, FormulaParseContext context)
Description copied from interface:FormulaEngine
Shift the formula that care on sheet and region.- Specified by:
move
in interfaceFormulaEngine
- Returns:
-
getMoveAdjuster
protected FormulaEngineImpl.FormulaAdjuster getMoveAdjuster(SheetRegion region, int rowOffset, int columnOffset)
-
shrink
public FormulaExpression shrink(String formula, SheetRegion srcRegion, boolean horizontal, FormulaParseContext context)
- Specified by:
shrink
in interfaceFormulaEngine
-
extend
public FormulaExpression extend(String formula, SheetRegion srcRegion, boolean horizontal, FormulaParseContext context)
- Specified by:
extend
in interfaceFormulaEngine
-
shift
public FormulaExpression shift(String formula, int rowOffset, int columnOffset, FormulaParseContext context)
Description copied from interface:FormulaEngine
Shift the formula base on the offset- Specified by:
shift
in interfaceFormulaEngine
- Returns:
-
getShiftAdjuster
protected FormulaEngineImpl.FormulaAdjuster getShiftAdjuster(int rowOffset, int columnOffset)
-
transpose
public FormulaExpression transpose(String formula, int rowOrigin, int columnOrigin, FormulaParseContext context)
Description copied from interface:FormulaEngine
Transpose the formula base one the origin- Specified by:
transpose
in interfaceFormulaEngine
- Returns:
-
getTransposeAdjuster
protected FormulaEngineImpl.FormulaAdjuster getTransposeAdjuster(int rowOrigin, int columnOrigin)
-
renameSheet
public FormulaExpression renameSheet(String formula, SBook targetBook, String oldSheetName, String newSheetName, FormulaParseContext context)
- Specified by:
renameSheet
in interfaceFormulaEngine
-
getRenameSheetAdjuster
protected FormulaEngineImpl.FormulaAdjuster getRenameSheetAdjuster(SBook targetBook, String oldSheetName, String newSheetName)
-
renameName
public FormulaExpression renameName(String formula, SBook targetBook, String oldName, String newName, FormulaParseContext context)
- Specified by:
renameName
in interfaceFormulaEngine
-
cloneSheet
public FormulaExpression cloneSheet(String formula, SBook targetBook, String oldSheetName, String newSheetName, FormulaParseContext context)
- Specified by:
cloneSheet
in interfaceFormulaEngine
-
getCloneSheetAdjuster
protected FormulaEngineImpl.FormulaAdjuster getCloneSheetAdjuster(SBook targetBook, String oldSheetName, String newSheetName)
-
renameName
public FormulaExpression renameName(String formula, SBook targetBook, int sheetIndex, String oldName, String newName, FormulaParseContext context)
- Specified by:
renameName
in interfaceFormulaEngine
- Returns:
-
getRenameNameAdjuster
protected FormulaEngineImpl.FormulaAdjuster getRenameNameAdjuster(int sheetIndex, String oldName, String newName)
-
movePtgs
public FormulaExpression movePtgs(FormulaExpression fe, SheetRegion region, int rowOffset, int columnOffset, FormulaParseContext context)
Description copied from interface:FormulaEngine
Shift the formula that care on sheet and region for cells insertion, deletion, and paste- Specified by:
movePtgs
in interfaceFormulaEngine
- Returns:
-
shrinkPtgs
public FormulaExpression shrinkPtgs(FormulaExpression fe, SheetRegion srcRegion, boolean horizontal, FormulaParseContext context)
Description copied from interface:FormulaEngine
modifyFormulaExpression
for cells deletion- Specified by:
shrinkPtgs
in interfaceFormulaEngine
- Returns:
-
extendPtgs
public FormulaExpression extendPtgs(FormulaExpression fe, SheetRegion srcRegion, boolean horizontal, FormulaParseContext context)
Description copied from interface:FormulaEngine
modifyFormulaExpression
for cells insertion- Specified by:
extendPtgs
in interfaceFormulaEngine
- Returns:
-
shiftPtgs
public FormulaExpression shiftPtgs(FormulaExpression fe, int rowOffset, int columnOffset, FormulaParseContext context)
Description copied from interface:FormulaEngine
Shift the formula base on the offset- Specified by:
shiftPtgs
in interfaceFormulaEngine
- Returns:
-
transposePtgs
public FormulaExpression transposePtgs(FormulaExpression fe, int rowOrigin, int columnOrigin, FormulaParseContext context)
Description copied from interface:FormulaEngine
Transpose the formula base one the origin- Specified by:
transposePtgs
in interfaceFormulaEngine
- Returns:
-
renameSheetPtgs
public FormulaExpression renameSheetPtgs(FormulaExpression fe, SBook targetBook, String oldSheetName, String newSheetName, FormulaParseContext context)
- Specified by:
renameSheetPtgs
in interfaceFormulaEngine
- Returns:
-
cloneSheetPtgs
public FormulaExpression cloneSheetPtgs(FormulaExpression fe, SBook targetBook, String oldSheetName, String newSheetName, FormulaParseContext context)
- Specified by:
cloneSheetPtgs
in interfaceFormulaEngine
- Returns:
-
renameNamePtgs
public FormulaExpression renameNamePtgs(FormulaExpression fe, SBook targetBook, int sheetIndex, String oldName, String newName, FormulaParseContext context)
- Specified by:
renameNamePtgs
in interfaceFormulaEngine
- Returns:
-
updateDependencyTable
public void updateDependencyTable(FormulaExpression fexpr, FormulaParseContext context)
- Specified by:
updateDependencyTable
in interfaceFormulaEngine
-
reorderSheetPtgs
public FormulaExpression reorderSheetPtgs(FormulaExpression fexpr, SBook targetBook, int oldIndex, int newIndex, FormulaParseContext context)
- Specified by:
reorderSheetPtgs
in interfaceFormulaEngine
-
getReorderSheetAdjuster
protected FormulaEngineImpl.FormulaAdjuster getReorderSheetAdjuster(SBook targetBook, int oldIndex, int newIndex)
-
renameTableNameTablePtgs
public FormulaExpression renameTableNameTablePtgs(FormulaExpression fexpr, SBook book, String oldName, String newName, FormulaParseContext context)
- Specified by:
renameTableNameTablePtgs
in interfaceFormulaEngine
- Returns:
-
renameColumnNameTablePtgs
public FormulaExpression renameColumnNameTablePtgs(FormulaExpression fexpr, STable table, String oldName, String newName, FormulaParseContext context)
- Specified by:
renameColumnNameTablePtgs
in interfaceFormulaEngine
- Returns:
-
convertToPOIFormulaType
public static FormulaType convertToPOIFormulaType(FormulaType formulaType)
-
-