Coverage Report - org.apache.tapestry.contrib.table.model.common.BasicTableModelWrap
 
Classes in this File Line Coverage Branch Coverage Complexity
BasicTableModelWrap
0%
0/16
0%
0/2
1.2
 
 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 org.apache.tapestry.contrib.table.model.IBasicTableModel;
 18  
 import org.apache.tapestry.contrib.table.model.ITableColumn;
 19  
 import org.apache.tapestry.contrib.table.model.ITableColumnModel;
 20  
 import org.apache.tapestry.contrib.table.model.simple.SimpleTableState;
 21  
 
 22  
 import java.util.Iterator;
 23  
 
 24  
 /**
 25  
  * @author mindbridge
 26  
  */
 27  
 public class BasicTableModelWrap extends AbstractTableModel
 28  
 {
 29  
 
 30  
     private static final long serialVersionUID = 1L;
 31  
 
 32  
     private IBasicTableModel m_objBasicTableModel;
 33  
     private ITableColumnModel m_objTableColumnModel;
 34  
 
 35  
     public BasicTableModelWrap(IBasicTableModel objBasicTableModel,
 36  
             ITableColumnModel objColumnModel)
 37  
     {
 38  0
         this(objBasicTableModel, objColumnModel, new SimpleTableState());
 39  0
     }
 40  
 
 41  
     public BasicTableModelWrap(IBasicTableModel objBasicTableModel,
 42  
             ITableColumnModel objColumnModel, SimpleTableState objState)
 43  
     {
 44  0
         super(objState);
 45  0
         m_objBasicTableModel = objBasicTableModel;
 46  0
         m_objTableColumnModel = objColumnModel;
 47  0
     }
 48  
 
 49  
     /**
 50  
      * @see org.apache.tapestry.contrib.table.model.ITableModel#getColumnModel()
 51  
      */
 52  
     public ITableColumnModel getColumnModel()
 53  
     {
 54  0
         return m_objTableColumnModel;
 55  
     }
 56  
 
 57  
     /**
 58  
      * @see org.apache.tapestry.contrib.table.model.common.AbstractTableModel#getRowCount()
 59  
      */
 60  
     public int getRowCount()
 61  
     {
 62  0
         return m_objBasicTableModel.getRowCount();
 63  
     }
 64  
 
 65  
     /**
 66  
      * @see org.apache.tapestry.contrib.table.model.ITableModel#getCurrentPageRows()
 67  
      */
 68  
     public Iterator getCurrentPageRows()
 69  
     {
 70  0
         int nPageSize = getPagingState().getPageSize();
 71  0
         if (nPageSize <= 0) nPageSize = getRowCount();
 72  
 
 73  0
         int nCurrentPage = getPagingState().getCurrentPage();
 74  0
         int nFrom = nCurrentPage * nPageSize;
 75  
 
 76  0
         String strSortColumn = getSortingState().getSortColumn();
 77  0
         ITableColumn objSortColumn = getColumnModel().getColumn(strSortColumn);
 78  0
         boolean bSortOrder = getSortingState().getSortOrder();
 79  
 
 80  0
         return m_objBasicTableModel.getCurrentPageRows(nFrom, nPageSize,
 81  
                 objSortColumn, bSortOrder);
 82  
     }
 83  
 
 84  
 }