001    // Copyright 2004, 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry.contrib.table.model.simple;
016    
017    import java.io.Serializable;
018    
019    import org.apache.tapestry.contrib.table.model.ITablePagingState;
020    
021    /**
022     * A minimal implementation of 
023     * {@link org.apache.tapestry.contrib.table.model.ITablePagingState}.
024     * 
025     * @author mindbridge
026     */
027    public class SimpleTablePagingState implements ITablePagingState, Serializable
028    {
029            private static final long serialVersionUID = 1L;
030    
031            private static final int DEFAULT_PAGE_SIZE = 10;
032    
033        private int m_nPageSize;
034        private int m_nCurrentPage;
035    
036        public SimpleTablePagingState()
037        {
038            this(DEFAULT_PAGE_SIZE, 0);
039        }
040    
041        public SimpleTablePagingState(int nPageSize, int nCurrentPage) {
042            m_nPageSize = nPageSize;
043            m_nCurrentPage = nCurrentPage;
044        }
045        
046        /**
047         * Returns the pageSize.
048         * @return int
049         */
050        public int getPageSize()
051        {
052            return m_nPageSize;
053        }
054    
055        /**
056         * Sets the pageSize.
057         * @param pageSize The pageSize to set
058         */
059        public void setPageSize(int pageSize)
060        {
061            m_nPageSize = pageSize;
062        }
063    
064        /**
065         * Returns the currentPage.
066         * @return int
067         */
068        public int getCurrentPage()
069        {
070            return m_nCurrentPage;
071        }
072    
073        /**
074         * Sets the currentPage.
075         * @param currentPage The currentPage to set
076         */
077        public void setCurrentPage(int currentPage)
078        {
079            m_nCurrentPage = currentPage;
080        }
081    
082    }