Clover coverage report - Code Coverage for tapestry-contrib release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:12:41 EDT
file stats: LOC: 85   Methods: 6
NCLOC: 41   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
AbstractTableModel.java 0% 0% 0% 0%
coverage
 1   
 // Copyright 2004, 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 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.tapestry.contrib.table.model.common;
 16   
 
 17   
 import java.io.Serializable;
 18   
 
 19   
 import org.apache.tapestry.contrib.table.model.ITableModel;
 20   
 import org.apache.tapestry.contrib.table.model.ITablePagingState;
 21   
 import org.apache.tapestry.contrib.table.model.ITableSortingState;
 22   
 import org.apache.tapestry.contrib.table.model.simple.SimpleTableState;
 23   
 
 24   
 /**
 25   
  * A base table model that implements the handling of the model state.
 26   
  * Used by most standard ITableModel implementations.
 27   
  * 
 28   
  * @author mindbridge
 29   
  */
 30   
 public abstract class AbstractTableModel implements ITableModel, Serializable
 31   
 {
 32   
     private SimpleTableState m_objTableState;
 33   
 
 34  0
     protected AbstractTableModel()
 35   
     {
 36  0
         this(new SimpleTableState());
 37   
     }
 38   
 
 39  0
     protected AbstractTableModel(SimpleTableState objTableState)
 40   
     {
 41  0
         m_objTableState = objTableState;
 42   
     }
 43   
     
 44   
     /**
 45   
      * @see org.apache.tapestry.contrib.table.model.ITableModel#getPagingState()
 46   
      */
 47  0
     public ITablePagingState getPagingState()
 48   
     {
 49  0
         return getState().getPagingState();
 50   
     }
 51   
 
 52   
     /**
 53   
      * @see org.apache.tapestry.contrib.table.model.ITableModel#getSortingState()
 54   
      */
 55  0
     public ITableSortingState getSortingState()
 56   
     {
 57  0
         return getState().getSortingState();
 58   
     }
 59   
 
 60   
     /**
 61   
      * Returns the tableState.
 62   
      * @return SimpleTableState
 63   
      */
 64  0
     public SimpleTableState getState()
 65   
     {
 66  0
         return m_objTableState;
 67   
     }
 68   
 
 69   
     protected abstract int getRowCount();
 70   
     
 71  0
     public int getPageCount()
 72   
     {
 73  0
         int nRowCount = getRowCount();
 74  0
         if (nRowCount == 0)
 75  0
             return 1;
 76   
 
 77  0
         int nPageSize = getPagingState().getPageSize();
 78  0
         if (nPageSize <= 0)
 79  0
             return 1;
 80   
 
 81  0
         return (nRowCount - 1) / nPageSize + 1;
 82   
     }
 83   
     
 84   
 }
 85