View Javadoc
1   /*
2    * Prometheus: Application Framework
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.prometheus.service.sheet;
18  
19  import io.github.tonywasher.joceanus.oceanus.base.OceanusException;
20  import io.github.tonywasher.joceanus.prometheus.service.sheet.PrometheusSheet.PrometheusSheetSheetCtl;
21  import io.github.tonywasher.joceanus.prometheus.service.sheet.PrometheusSheet.PrometheusSheetWorkBookCtl;
22  
23  import java.util.ListIterator;
24  
25  /**
26   * Class representing a sheet within a workBook.
27   */
28  public abstract class PrometheusSheetSheet
29          implements PrometheusSheetSheetCtl {
30      /**
31       * The WorkBook.
32       */
33      private final PrometheusSheetWorkBookCtl theWorkBook;
34  
35      /**
36       * Name of sheet.
37       */
38      private final String theSheetName;
39  
40      /**
41       * Is the sheet readOnly?
42       */
43      private final boolean isReadOnly;
44  
45      /**
46       * Constructor for Excel Sheet.
47       *
48       * @param pWorkBook the workBook
49       * @param pName     the sheet name
50       * @param pReadOnly is the sheet readOnly?
51       */
52      protected PrometheusSheetSheet(final PrometheusSheetWorkBookCtl pWorkBook,
53                                     final String pName,
54                                     final boolean pReadOnly) {
55          /* Store parameters */
56          theWorkBook = pWorkBook;
57          theSheetName = pName;
58          isReadOnly = pReadOnly;
59      }
60  
61      /**
62       * Obtain the workBook.
63       *
64       * @return the workBook
65       */
66      public PrometheusSheetWorkBookCtl getWorkBook() {
67          return theWorkBook;
68      }
69  
70      /**
71       * Obtain the name of the sheet.
72       *
73       * @return the name
74       */
75      public String getName() {
76          return theSheetName;
77      }
78  
79      /**
80       * Is the sheet readOnly?
81       *
82       * @return true/false
83       */
84      public boolean isReadOnly() {
85          return isReadOnly;
86      }
87  
88      /**
89       * Get row count.
90       *
91       * @return the count of rows
92       */
93      public abstract int getRowCount();
94  
95      /**
96       * Obtain an iterator of non-null rows for the view.
97       *
98       * @param pFirstIndex the first row in the view
99       * @param pLastIndex  the last row in the view
100      * @return the iterator
101      */
102     public abstract ListIterator<PrometheusSheetRow> iteratorForRange(int pFirstIndex,
103                                                                       int pLastIndex);
104 
105     /**
106      * Name a single cell as a range.
107      *
108      * @param pName       the name of the range
109      * @param pSingleCell the cell to name
110      * @throws OceanusException on error
111      */
112     public void declareRange(final String pName,
113                              final PrometheusSheetCellPosition pSingleCell) throws OceanusException {
114         /* declare the range */
115         declareRange(pName, pSingleCell, pSingleCell);
116     }
117 }