All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xdev.db.DBPager Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
package xdev.db;

/*-
 * #%L
 * XDEV Application Framework
 * %%
 * Copyright (C) 2003 - 2020 XDEV Software
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */


/**
 * Interface for result pagers. It provides methods for scrolling forward,
 * backward, jump to the first or the last page and others.
 * 
 * @author XDEV Software (HL)
 * @since 4.0
 */
public interface DBPager extends AutoCloseable
{
	/**
	 * @return the datasource of this pager
	 */
	public DBDataSource getDataSource();
	
	
	/**
	 * @return true if the pager can go forward
	 */
	public boolean hasNextPage();
	
	
	/**
	 * @return true if the pager can go backward
	 */
	public boolean hasPreviousPage();
	
	
	/**
	 * Scrolls to the next Page
	 * 
	 * @throws DBException
	 */
	public Result nextPage() throws DBException;
	
	
	/**
	 * Scrolls to the previous Page
	 * 
	 * @throws DBException
	 */
	public Result previousPage() throws DBException;
	
	
	/**
	 * Scrolls to the first Page
	 * 
	 * @throws DBException
	 */
	public Result firstPage() throws DBException;
	
	
	/**
	 * Scrolls to the last Page
	 * 
	 * @throws DBException
	 */
	public Result lastPage() throws DBException;
	
	
	/**
	 * Scrolls to the given pageNumber
	 * 
	 * @param page
	 */
	public Result gotoPage(final int page) throws DBException;
	
	
	/**
	 * Scrolls to the given row
	 * 
	 * @param row
	 */
	public Result gotoRow(final int row) throws DBException;
	
	
	/**
	 * returns the number of the current Page
	 * 
	 * @return int
	 */
	public int getCurrentPageIndex();
	
	
	/**
	 * returns the number of the last Page
	 * 
	 * @return int
	 */
	public int getMaxPageIndex();
	
	
	/**
	 * Sets the number of rows to be shown on a page and returns the new result
	 * of the current page.
	 * 
	 * @param rowsPerPage
	 *            int
	 */
	public Result setRowsPerPage(final int rowsPerPage) throws DBException;
	
	
	/**
	 * Returns the number of rows to be shown on a page.
	 * 
	 * @return rowsPerPage int
	 */
	public int getRowsPerPage();
	
	
	/**
	 * Returns the number of all rows, returned from the database
	 * 
	 * @return totalRows int
	 */
	public int getTotalRows();
	
	
	/**
	 * Closes the pager and its underlying resources.
	 */
	public void close() throws DBException;
	
	
	/**
	 * @return true if this pager or an underlying resource has
	 *         been closed, false otherwise
	 */
	public boolean isClosed() throws DBException;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy