public class PageUtil extends Object
| Constructor and Description |
|---|
PageUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
getEnd(int pageNo,
int pageSize)
将页数和每页条目数转换为结束位置
此方法用于不包括结束位置的分页方法 例如: 页码:0,每页10 =》 9 页码:1,每页10 =》 19 …… 当 setFirstPageNo(int)设置为1时:
页码:1,每页10 =》 10
页码:2,每页10 =》 20
……
|
static int |
getFirstPageNo()
获得首页的页码,可以为0或者1
|
static int |
getStart(int pageNo,
int pageSize)
将页数和每页条目数转换为开始位置
此方法用于不包括结束位置的分页方法 例如: 页码:0,每页10 =》 0 页码:1,每页10 =》 10 …… 当 setFirstPageNo(int)设置为1时:
页码:1,每页10 =》 0
页码:2,每页10 =》 10
……
|
static int[] |
rainbow(int currentPage,
int pageCount)
|
static int[] |
rainbow(int pageNo,
int totalPage,
int displayCount)
分页彩虹算法
来自: https://github.com/iceroot/iceroot/blob/master/src/main/java/com/icexxx/util/IceUtil.java 通过传入的信息,生成一个分页列表显示 |
static void |
setFirstPageNo(int customFirstPageNo)
设置首页页码,可以为0或者1
当设置为0时,页码0表示第一页,开始位置为0
当设置为1时,页码1表示第一页,开始位置为0
|
static void |
setOneAsFirstPageNo()
设置首页页码为1
当设置为1时,页码1表示第一页,开始位置为0
|
static Segment<Integer> |
toSegment(int pageNo,
int pageSize)
将页数和每页条目数转换为开始位置和结束位置
此方法用于包括结束位置的分页方法 例如: 页码:0,每页10 =》 [0, 10] 页码:1,每页10 =》 [10, 20] …… 当 setFirstPageNo(int)设置为1时:
页码:1,每页10 =》 [0, 10]
页码:2,每页10 =》 [10, 20]
……
|
static int |
totalPage(int totalCount,
int pageSize)
根据总数计算总页数
|
static int |
totalPage(long totalCount,
int pageSize)
根据总数计算总页数
|
static int[] |
transToStartEnd(int pageNo,
int pageSize)
将页数和每页条目数转换为开始位置和结束位置
此方法用于包括结束位置的分页方法 例如: 页码:0,每页10 =》 [0, 10] 页码:1,每页10 =》 [10, 20] …… 当 setFirstPageNo(int)设置为1时:
页码:1,每页10 =》 [0, 10]
页码:2,每页10 =》 [10, 20]
……
|
public static int getFirstPageNo()
public static void setFirstPageNo(int customFirstPageNo)
当设置为0时,页码0表示第一页,开始位置为0
当设置为1时,页码1表示第一页,开始位置为0
customFirstPageNo - 自定义的首页页码,为0或者1public static void setOneAsFirstPageNo()
当设置为1时,页码1表示第一页,开始位置为0
public static int getStart(int pageNo,
int pageSize)
页码:0,每页10 =》 0 页码:1,每页10 =》 10 ……
当setFirstPageNo(int)设置为1时:
页码:1,每页10 =》 0 页码:2,每页10 =》 10 ……
pageNo - 页码(从0计数)pageSize - 每页条目数public static int getEnd(int pageNo,
int pageSize)
页码:0,每页10 =》 9 页码:1,每页10 =》 19 ……
当setFirstPageNo(int)设置为1时:
页码:1,每页10 =》 10 页码:2,每页10 =》 20 ……
pageNo - 页码(从0计数)pageSize - 每页条目数public static int[] transToStartEnd(int pageNo,
int pageSize)
页码:0,每页10 =》 [0, 10] 页码:1,每页10 =》 [10, 20] ……
当setFirstPageNo(int)设置为1时:
页码:1,每页10 =》 [0, 10] 页码:2,每页10 =》 [10, 20] ……
pageNo - 页码(从0计数)pageSize - 每页条目数public static Segment<Integer> toSegment(int pageNo, int pageSize)
页码:0,每页10 =》 [0, 10] 页码:1,每页10 =》 [10, 20] ……
当setFirstPageNo(int)设置为1时:
页码:1,每页10 =》 [0, 10] 页码:2,每页10 =》 [10, 20] ……
pageNo - 页码(从0计数)pageSize - 每页条目数Segmentpublic static int totalPage(int totalCount,
int pageSize)
totalCount - 总数pageSize - 每页数public static int totalPage(long totalCount,
int pageSize)
totalCount - 总数pageSize - 每页数public static int[] rainbow(int pageNo,
int totalPage,
int displayCount)
pageNo - 当前页totalPage - 总页数displayCount - 每屏展示的页数public static int[] rainbow(int currentPage,
int pageCount)
currentPage - 当前页pageCount - 总页数Copyright © 2025. All rights reserved.