Java paging Query plug-in

Source: Internet
Author: User


Page Result Plugin
Import java.util.List;

public class Pageresult<t> {
/**
* Result set
*/
Private list<t> List;

/**
* Page Info
*/
Private Pagevo page;

Public list<t> getList () {
return list;
}

public void setlist (list<t> List) {
This.list = list;
}

Public Pagevo GetPage () {
return page;
}

public void Setpage (Pagevo page) {
this.page = page;
}
}

Page Plugin
public class Pagevo {
/**
* Total Record Count
*/
private int totalrecords;

/**
* Current Page
*/
private int pageno = 1;
/**
* How many bars are displayed per page
*/
private int pageSize = 10;

/**
* Get the first page
*
* @return
*/
public int Gettoppageno () {
return 1;
}

/**
* Get Previous Page
*
* @return
*/
public int Getpreviouspageno () {
if (PageNo <= 1) {
return 1;
}
return pageNo-1;
}

/**
* Get Next page
*
* @return
*/
public int Getnextpageno () {
if (PageNo >= gettotalpages ()) {//If current is also greater than page number
return gettotalpages () = = 0? 1:gettotalpages (); Return to last page
}
return PageNo + 1;
}

/**
* Get the last page
*
* @return
*/
public int Getlastpageno () {
return gettotalpages () = = 0? 1:gettotalpages (); If the total number of pages is 0 returns 1, the inverse returns the total number of pages
}

/**
* Total pages obtained
*
* @return
*/
public int gettotalpages () {
int total = (totalrecords + pageSize-1)/pageSize;
Return Total <= 0? 1:total; Calculate the total number of pages
}

public int gettotalrecords () {
return totalrecords;
}

public void settotalrecords (int totalrecords) {
This.totalrecords = totalrecords;
}

public int Getpageno () {
if (PageNo < 1) {
PageNo = 1;
}
return pageno;
}

public void Setpageno (int pageno) {
This.pageno = PageNo;
}

public int getpagesize () {
return pageSize;
}

public void setpagesize (int pageSize) {
This.pagesize = pageSize;
}
}



Java paging Query plug-in

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.