Coverage Report - org.kuali.rice.kns.web.struts.form.KualiTableRenderFormMetadata
 
Classes in this File Line Coverage Branch Coverage Complexity
KualiTableRenderFormMetadata
0%
0/45
0%
0/2
1.042
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kns.web.struts.form;
 17  
 
 18  
 import org.kuali.rice.kns.util.TableRenderUtil;
 19  
 
 20  
 /**
 21  
  * This class holds the metadata necessary to render a table when displaytag is not being used.
 22  
  */
 23  
 public class KualiTableRenderFormMetadata {
 24  
     private int viewedPageNumber;
 25  
     private int totalNumberOfPages;
 26  
     private int firstRowIndex;
 27  
     private int lastRowIndex;
 28  
     private int switchToPageNumber;
 29  
     
 30  
     /**
 31  
      * The number of rows that match the query criteria
 32  
      */
 33  
     private int resultsActualSize;
 34  
     
 35  
     /**
 36  
      * The number of rows that match the query criteria or
 37  
      *  the max results limit size (if applicable), whichever is less
 38  
      */
 39  
     private int resultsLimitedSize;
 40  
     
 41  
     /**
 42  
      * when the looked results screen was rendered, the index of the column that the results were sorted on.  -1 for unknown, index numbers
 43  
      * starting at 0
 44  
      */
 45  
     private int previouslySortedColumnIndex;
 46  
     
 47  
     /**
 48  
      * Comment for <code>columnToSortIndex</code>
 49  
      */
 50  
     private int columnToSortIndex;
 51  
 
 52  
     private boolean sortDescending;
 53  
     
 54  0
     public KualiTableRenderFormMetadata() {
 55  0
         sortDescending = false;
 56  0
     }
 57  
     
 58  
     /**
 59  
      * Gets the columnToSortIndex attribute. 
 60  
      * @return Returns the columnToSortIndex.
 61  
      */
 62  
     public int getColumnToSortIndex() {
 63  0
         return columnToSortIndex;
 64  
     }
 65  
 
 66  
     /**
 67  
      * Sets the columnToSortIndex attribute value.
 68  
      * @param columnToSortIndex The columnToSortIndex to set.
 69  
      */
 70  
     public void setColumnToSortIndex(int columnToSortIndex) {
 71  0
         this.columnToSortIndex = columnToSortIndex;
 72  0
     }
 73  
 
 74  
     /**
 75  
      * Gets the previouslySortedColumnIndex attribute. 
 76  
      * @return Returns the previouslySortedColumnIndex.
 77  
      */
 78  
     public int getPreviouslySortedColumnIndex() {
 79  0
         return previouslySortedColumnIndex;
 80  
     }
 81  
 
 82  
     /**
 83  
      * Sets the previouslySortedColumnIndex attribute value.
 84  
      * @param previouslySortedColumnIndex The previouslySortedColumnIndex to set.
 85  
      */
 86  
     public void setPreviouslySortedColumnIndex(int previouslySortedColumnIndex) {
 87  0
         this.previouslySortedColumnIndex = previouslySortedColumnIndex;
 88  0
     }
 89  
 
 90  
     /**
 91  
      * Gets the resultsActualSize attribute. 
 92  
      * @return Returns the resultsActualSize.
 93  
      */
 94  
     public int getResultsActualSize() {
 95  0
         return resultsActualSize;
 96  
     }
 97  
 
 98  
     /**
 99  
      * Sets the resultsActualSize attribute value.
 100  
      * @param resultsActualSize The resultsActualSize to set.
 101  
      */
 102  
     public void setResultsActualSize(int resultsActualSize) {
 103  0
         this.resultsActualSize = resultsActualSize;
 104  0
     }
 105  
 
 106  
     /**
 107  
      * Gets the resultsLimitedSize attribute. 
 108  
      * @return Returns the resultsLimitedSize.
 109  
      */
 110  
     public int getResultsLimitedSize() {
 111  0
         return resultsLimitedSize;
 112  
     }
 113  
 
 114  
     /**
 115  
      * Sets the resultsLimitedSize attribute value.
 116  
      * @param resultsLimitedSize The resultsLimitedSize to set.
 117  
      */
 118  
     public void setResultsLimitedSize(int resultsLimitedSize) {
 119  0
         this.resultsLimitedSize = resultsLimitedSize;
 120  0
     }
 121  
 
 122  
     /**
 123  
      * Gets the switchToPageNumber attribute. 
 124  
      * @return Returns the switchToPageNumber.
 125  
      */
 126  
     public int getSwitchToPageNumber() {
 127  0
         return switchToPageNumber;
 128  
     }
 129  
 
 130  
     /**
 131  
      * Sets the switchToPageNumber attribute value.
 132  
      * @param switchToPageNumber The switchToPageNumber to set.
 133  
      */
 134  
     public void setSwitchToPageNumber(int switchToPageNumber) {
 135  0
         this.switchToPageNumber = switchToPageNumber;
 136  0
     }
 137  
 
 138  
     /**
 139  
      * Gets the viewedPageNumber attribute. 
 140  
      * @return Returns the viewedPageNumber.
 141  
      */
 142  
     public int getViewedPageNumber() {
 143  0
         return viewedPageNumber;
 144  
     }
 145  
 
 146  
     /**
 147  
      * Sets the viewedPageNumber attribute value.
 148  
      * @param viewedPageNumber The viewedPageNumber to set.
 149  
      */
 150  
     public void setViewedPageNumber(int viewedPageNumber) {
 151  0
         this.viewedPageNumber = viewedPageNumber;
 152  0
     }
 153  
 
 154  
     /**
 155  
      * Gets the totalNumberOfPages attribute. 
 156  
      * @return Returns the totalNumberOfPages.
 157  
      */
 158  
     public int getTotalNumberOfPages() {
 159  0
         return totalNumberOfPages;
 160  
     }
 161  
 
 162  
     /**
 163  
      * Sets the totalNumberOfPages attribute value.
 164  
      * @param totalNumberOfPages The totalNumberOfPages to set.
 165  
      */
 166  
     public void setTotalNumberOfPages(int totalNumberOfPages) {
 167  0
         this.totalNumberOfPages = totalNumberOfPages;
 168  0
     }
 169  
 
 170  
     /**
 171  
      * Gets the firstRowIndex attribute. 
 172  
      * @return Returns the firstRowIndex.
 173  
      */
 174  
     public int getFirstRowIndex() {
 175  0
         return firstRowIndex;
 176  
     }
 177  
 
 178  
     /**
 179  
      * Sets the firstRowIndex attribute value.
 180  
      * @param firstRowIndex The firstRowIndex to set.
 181  
      */
 182  
     public void setFirstRowIndex(int firstRowIndex) {
 183  0
         this.firstRowIndex = firstRowIndex;
 184  0
     }
 185  
 
 186  
     /**
 187  
      * Gets the lastRowIndex attribute. 
 188  
      * @return Returns the lastRowIndex.
 189  
      */
 190  
     public int getLastRowIndex() {
 191  0
         return lastRowIndex;
 192  
     }
 193  
 
 194  
     /**
 195  
      * Sets the lastRowIndex attribute value.
 196  
      * @param lastRowIndex The lastRowIndex to set.
 197  
      */
 198  
     public void setLastRowIndex(int lastRowIndex) {
 199  0
         this.lastRowIndex = lastRowIndex;
 200  0
     }
 201  
 
 202  
     /**
 203  
      * Gets the sortDescending attribute. 
 204  
      * @return Returns the sortDescending.
 205  
      */
 206  
     public boolean isSortDescending() {
 207  0
         return sortDescending;
 208  
     }
 209  
 
 210  
     /**
 211  
      * Sets the sortDescending attribute value.
 212  
      * @param sortDescending The sortDescending to set.
 213  
      */
 214  
     public void setSortDescending(boolean sortDescending) {
 215  0
         this.sortDescending = sortDescending;
 216  0
     }
 217  
     
 218  
     /**
 219  
      * Sets the paging form parameters to go to the first page of the list
 220  
      * 
 221  
      * @param listSize size of table being rendered
 222  
      * @param maxRowsPerPage
 223  
      */
 224  
     public void jumpToFirstPage(int listSize, int maxRowsPerPage) {
 225  0
         jumpToPage(0, listSize, maxRowsPerPage);
 226  0
     }
 227  
 
 228  
     /**
 229  
      * Sets the paging form parameters to go to the last page of the list
 230  
      * 
 231  
      * @param listSize size of table being rendered
 232  
      * @param maxRowsPerPage
 233  
      */
 234  
     public void jumpToLastPage(int listSize, int maxRowsPerPage) {
 235  0
         jumpToPage(TableRenderUtil.computeTotalNumberOfPages(listSize, maxRowsPerPage) - 1, listSize, maxRowsPerPage);
 236  0
     }
 237  
     
 238  
     /**
 239  
      * Sets the paging form parameters to go to the specified page of the list
 240  
      * 
 241  
      * @param pageNumber first page is 0, must be non-negative.  If the list is not large enough to have the page specified, then
 242  
      *   this method will be equivalent to calling jumpToLastPage.
 243  
      * @param listSize size of table being rendered
 244  
      * @param maxRowsPerPage
 245  
      * 
 246  
      * @see KualiTableRenderFormMetadata#jumpToLastPage(int, int)
 247  
      */
 248  
     public void jumpToPage(int pageNumber, int listSize, int maxRowsPerPage) {
 249  0
         int totalPages = TableRenderUtil.computeTotalNumberOfPages(listSize, maxRowsPerPage);
 250  0
         setTotalNumberOfPages(totalPages);
 251  0
         if (pageNumber >= totalPages) {
 252  0
             pageNumber = totalPages - 1;
 253  
         }
 254  0
         setViewedPageNumber(pageNumber);
 255  0
         setFirstRowIndex(TableRenderUtil.computeStartIndexForPage(pageNumber, listSize, maxRowsPerPage));
 256  0
         setLastRowIndex(TableRenderUtil.computeLastIndexForPage(pageNumber, listSize, maxRowsPerPage));
 257  0
     }
 258  
     
 259  
 }