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.

RefEvalBase.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.eval;
  16. import org.apache.poi.ss.formula.SheetRange;
  17. /**
  18. * Common base class for implementors of {@link RefEval}
  19. */
  20. public abstract class RefEvalBase implements RefEval {
  21. private final int _firstSheetIndex;
  22. private final int _lastSheetIndex;
  23. private final int _rowIndex;
  24. private final int _columnIndex;
  25. protected RefEvalBase(SheetRange sheetRange, int rowIndex, int columnIndex) {
  26. if (sheetRange == null) {
  27. throw new IllegalArgumentException("sheetRange must not be null");
  28. }
  29. _firstSheetIndex = sheetRange.getFirstSheetIndex();
  30. _lastSheetIndex = sheetRange.getLastSheetIndex();
  31. _rowIndex = rowIndex;
  32. _columnIndex = columnIndex;
  33. }
  34. protected RefEvalBase(int firstSheetIndex, int lastSheetIndex, int rowIndex, int columnIndex) {
  35. _firstSheetIndex = firstSheetIndex;
  36. _lastSheetIndex = lastSheetIndex;
  37. _rowIndex = rowIndex;
  38. _columnIndex = columnIndex;
  39. }
  40. protected RefEvalBase(int onlySheetIndex, int rowIndex, int columnIndex) {
  41. this(onlySheetIndex, onlySheetIndex, rowIndex, columnIndex);
  42. }
  43. public int getNumberOfSheets() {
  44. return _lastSheetIndex-_firstSheetIndex+1;
  45. }
  46. public int getFirstSheetIndex() {
  47. return _firstSheetIndex;
  48. }
  49. public int getLastSheetIndex() {
  50. return _lastSheetIndex;
  51. }
  52. public final int getRow() {
  53. return _rowIndex;
  54. }
  55. public final int getColumn() {
  56. return _columnIndex;
  57. }
  58. }