1 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 30 public abstract class AbstractTableModel implements ITableModel, Serializable 31 { 32 private SimpleTableState m_objTableState; 33 34 protected AbstractTableModel() 35 { 36 this(new SimpleTableState()); 37 } 38 39 protected AbstractTableModel(SimpleTableState objTableState) 40 { 41 m_objTableState = objTableState; 42 } 43 44 47 public ITablePagingState getPagingState() 48 { 49 return getState().getPagingState(); 50 } 51 52 55 public ITableSortingState getSortingState() 56 { 57 return getState().getSortingState(); 58 } 59 60 64 public SimpleTableState getState() 65 { 66 return m_objTableState; 67 } 68 69 protected abstract int getRowCount(); 70 71 public int getPageCount() 72 { 73 int nRowCount = getRowCount(); 74 if (nRowCount == 0) 75 return 1; 76 77 int nPageSize = getPagingState().getPageSize(); 78 if (nPageSize <= 0) 79 return 1; 80 81 return (nRowCount - 1) / nPageSize + 1; 82 } 83 84 } 85 | Popular Tags |