You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IStabilityClassifier.java 4.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.ss.formula;
  16. /**
  17. * Used to help optimise cell evaluation result caching by allowing applications to specify which
  18. * parts of a workbook are <em>final</em>.<br>
  19. * The term <b>final</b> is introduced here to denote immutability or 'having constant definition'.
  20. * This classification refers to potential actions (on the evaluated workbook) by the evaluating
  21. * application. It does not refer to operations performed by the evaluator ({@link
  22. * WorkbookEvaluator}).<br>
  23. * <br>
  24. * <b>General guidelines</b>:
  25. * <ul>
  26. * <li>a plain value cell can be marked as 'final' if it will not be changed after the first call
  27. * to {@link WorkbookEvaluator#evaluate(EvaluationCell)}.
  28. * </li>
  29. * <li>a formula cell can be marked as 'final' if its formula will not be changed after the first
  30. * call to {@link WorkbookEvaluator#evaluate(EvaluationCell)}. This remains true even if changes
  31. * in dependent values may cause the evaluated value to change.</li>
  32. * <li>plain value cells should be marked as 'not final' if their plain value value may change.
  33. * </li>
  34. * <li>formula cells should be marked as 'not final' if their formula definition may change.</li>
  35. * <li>cells which may switch between plain value and formula should also be marked as 'not final'.
  36. * </li>
  37. * </ul>
  38. * <b>Notes</b>:
  39. * <ul>
  40. * <li>If none of the spreadsheet cells is expected to have its definition changed after evaluation
  41. * begins, every cell can be marked as 'final'. This is the most efficient / least resource
  42. * intensive option.</li>
  43. * <li>To retain freedom to change any cell definition at any time, an application may classify all
  44. * cells as 'not final'. This freedom comes at the expense of greater memory consumption.</li>
  45. * <li>For the purpose of these classifications, setting the cached formula result of a cell (for
  46. * example in {@link org.apache.poi.ss.usermodel.FormulaEvaluator#evaluateFormulaCell(org.apache.poi.ss.usermodel.Cell)})
  47. * does not constitute changing the definition of the cell.</li>
  48. * <li>Updating cells which have been classified as 'final' will cause the evaluator to behave
  49. * unpredictably (typically ignoring the update).</li>
  50. * </ul>
  51. *
  52. * @author Josh Micich
  53. */
  54. public interface IStabilityClassifier {
  55. /**
  56. * Convenience implementation for situations where all cell definitions remain fixed after
  57. * evaluation begins.
  58. */
  59. IStabilityClassifier TOTALLY_IMMUTABLE = new IStabilityClassifier() {
  60. public boolean isCellFinal(int sheetIndex, int rowIndex, int columnIndex) {
  61. return true;
  62. }
  63. };
  64. /**
  65. * Checks if a cell's value(/formula) is fixed - in other words - not expected to be modified
  66. * between calls to the evaluator. (Note - this is an independent concept from whether a
  67. * formula cell's evaluated value may change during successive calls to the evaluator).
  68. *
  69. * @param sheetIndex zero based index into workbook sheet list
  70. * @param rowIndex zero based row index of cell
  71. * @param columnIndex zero based column index of cell
  72. * @return <code>false</code> if the evaluating application may need to modify the specified
  73. * cell between calls to the evaluator.
  74. */
  75. boolean isCellFinal(int sheetIndex, int rowIndex, int columnIndex);
  76. }