Java paging algorithm

Source: Internet
Author: User

Package com. Pan. uitl;

Public class pagering {
Private int count;
// Record?
Private int pageindex;
// Webpage?
Private int start;
// Start point
Private int end;
// End
Private int row;
// Number of pages?
Private int pagecount;
// The number of pages after the page?
Private int remainder;
// Remainder

Public int getcount (){
Return count;
}
Public int getpageindex (){
Return pageindex;
}
Public int getstart (){
If (start <0)
Start = 0;
Return start;
}
Public int getend (){
Return end;
}
Public int getrow (){
Return row;
}

Public int getpagecount (){
Return pagecount;
}
Public int getremainder (){
Return remainder;
}
Public pagering (){

}
Public pagering (INT count, int row ){
This. Count = count;
This. Row = row;
Pagecount = count/row;
// Remainder
If (remainder = (count % row ))! = 0 ){
Pagecount ++;
}
// Is the List Index from 0? ��?
// End = row-1;
}
Public void setrow (INT row ){
This. Row = row;
Pagecount = count/row;
// Remainder
If (remainder = (count % row ))! = 0 ){
Pagecount ++;
}
// End = row-1;
}

Public void setpageindex (INT index ){
// Determines whether the index is offside.
If (index <= 0 ){
Index = 1;
}
If (index> pagecount ){
Index = pagecount;
}
// Set the index

Pageindex = index;
// Return data
Start = Index * Row-row;
End = start + row;
// Integer
If (remainder! = 0)
{
If (Index = pagecount? ��? ��
End = start + remainder;
}
}
}

Public int getnextpage (){
If (pageindex <pagecount ){
Return pageindex + 1;
}
Return pageindex;
}
Public String getnext (){
If (pageindex <pagecount ){
Setpageindex (getpageindex () + 1 );
}
Return "";
}
Public int getuppage (){
If (pageindex> 1 ){
Return pageIndex-1;
}
Return pageindex;
}
Public Boolean ishasnextpage (){
Return pageindex <pagecount;
}
Public Boolean ishasuppage (){
Return pageindex> 1;
}
}

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.