org.springside.modules.orm中的page类自我解读
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils; public class Page<T> { /*静态变量,用于设置结果是按照正序排列还是反序排列*/
public static final String ASC = "asc";
public static final String DESC = "desc"; /*当前页码*/
protected int pageNo = 1;
/*页面容量*/
protected int pageSize = 1;
/*orderBy表示通过那个进行排序,比如说:id*/
protected String orderBy = null;
/*order是设置以哪种方式进行排序:可以使ASC也可以是DESC*/
protected String order = null;
/*只是是否自动计算*/
protected boolean autoCount = true; /*以下2个参数常作为 分页所需的"返回结果"! */
//result表示当页面存在的实体类集合。
protected List<T> result = Collections.emptyList();
//totalCount表示当前页面总条数。
protected long totalCount = -1L; public Page() {
} public Page(int pageSize) {
this.setPageSize(pageSize);
} public Page(int pageSize, boolean autoCount) {
this.setPageSize(pageSize);
this.setAutoCount(autoCount);
} public int getPageNo() {
return this.pageNo;
} public void setPageNo(int pageNo) {
this.pageNo = pageNo;
if(pageNo < 1) {
this.pageNo = 1;
} } public int getPageSize() {
return this.pageSize;
} public void setPageSize(int pageSize) {
this.pageSize = pageSize;
if(pageSize < 0) {
this.pageSize = 1;
} } /**
* 获得当前页面第一条数据的排列
* @return
*/
public int getFirst() {
return (this.pageNo - 1) * this.pageSize + 1;
} public String getOrderBy() {
return this.orderBy;
} public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
} public boolean isOrderBySetted() {
return StringUtils.isNotBlank(this.orderBy) && StringUtils.isNotBlank(this.order);
} public String getOrder() {
return this.order;
} public void setOrder(String order) {
String[] orders = StringUtils.split(StringUtils.lowerCase(order), ',');
String[] var6 = orders;
int var5 = orders.length; for(int var4 = 0; var4 < var5; ++var4) {
String orderStr = var6[var4];
if(!StringUtils.equals("desc", orderStr) && !StringUtils.equals("asc", orderStr)) {
throw new IllegalArgumentException("排序方向" + orderStr + "不是合法值");
}
} this.order = StringUtils.lowerCase(order);
} public boolean isAutoCount() {
return this.autoCount;
} public void setAutoCount(boolean autoCount) {
this.autoCount = autoCount;
} public List<T> getResult() {
return this.result;
} public void setResult(List<T> result) {
this.result = result;
} public long getTotalCount() {
return this.totalCount;
} public void setTotalCount(long totalCount) {
this.totalCount = totalCount;
} /**
* 获取一共有多少页(设置的是总条数)
* @return
*/
public long getTotalPages() {
if(this.totalCount < 0L) {
return -1L;
} else {
long count = this.totalCount / (long)this.pageSize;
if(this.totalCount % (long)this.pageSize > 0L) {
++count;
} return count;
}
} /**
* 是否还有下一页
* @return
*/
public boolean isHasNext() {
return (long)(this.pageNo + 1) <= this.getTotalPages();
} /**
* 得到下一页的页码
* @return
*/
public int getNextPage() {
return this.isHasNext()?this.pageNo + 1:this.pageNo;
} /**
* 是否有上一页
* @return
*/
public boolean isHasPre() {
return this.pageNo - 1 >= 1;
} /**
* 得到上一页页码
* @return
*/
public int getPrePage() {
return this.isHasPre()?this.pageNo - 1:this.pageNo;
}
}
对于上述代码需要有几点强调的:
1.Page类本质来讲仅仅是一个辅助类,其中包含的是一些争对分页的辅助数据,具体怎么用,还是需要自己进行处理的。
2.XXX随时补充。。。
org.springside.modules.orm中的page类自我解读的更多相关文章
- 三:理解Page类的运行机制(例:在render方法中生成静态文件)
我这里只写几个常用的事件1.OnPreInit:此事件后将加载个性化信息和主题2.OnInit:初始化页面中服务器控件的默认值但控件的状态没有加载,没有创建控件树3.OnPreLoad:控件完成状态和 ...
- 在jsp中,page指令的()属性用来引入需要的包或类。
在jsp中,page指令的()属性用来引入需要的包或类. A.extends B.import C.language D.contentType 解答:B
- orm中的聚合函数,分组,F/Q查询,字段类,事务
目录 一.聚合函数 1. 基础语法 2. Max Min Sum Avg Count用法 (1) Max()/Min() (2)Avg() (3)Count() (4)聚合函数联用 二.分组查询 1. ...
- 领域模型中的实体类分为四种类型:VO、DTO、DO、PO
http://kb.cnblogs.com/page/522348/ 由于不同的项目和开发人员有不同的命名习惯,这里我首先对上述的概念进行一个简单描述,名字只是个标识,我们重点关注其概念: 概念: V ...
- 【ASP.NET 基础】Page类和回调技术
Page 类有一个 IsPostBack 属性,这个属性用来指示当前页面是第一次加载还是响应了页面上某个控件的服务器事件导致回发而加载. 1.asp.net页面的声明周期 asp.net页面运行的时候 ...
- C#基础系列:实现自己的ORM(反射以及Attribute在ORM中的应用)
反射以及Attribute在ORM中的应用 一. 反射什么是反射?简单点吧,反射就是在运行时动态获取对象信息的方法,比如运行时知道对象有哪些属性,方法,委托等等等等.反射有什么用呢?反射不但让你在运行 ...
- (转载)OC学习篇之---Foundation框架中的其他类(NSNumber,NSDate,NSExcetion)
前一篇说到了Foundation框架中的NSDirctionary类,这一一篇来看一下Foundation的其他常用的类:NSNumber,NSDate,NSException. 注:其实按照Java ...
- 深刻理解Python中的元类metaclass(转)
本文由 伯乐在线 - bigship 翻译 英文出处:stackoverflow 译文:http://blog.jobbole.com/21351/ 译注:这是一篇在Stack overflow上很热 ...
- 非Page类使用session(Httpcontext.session和page.session区别)
ASP.NET中Session高级使用技巧 在开发Aspx .NET软件时,有时需要把常用的东西封装到一个非PAGE类中,文章介绍在非Page类中使用Session的方法. 一.PAGE参数法: 1. ...
随机推荐
- vs 发布web应用程序时,找不到cs文件错误
将*.aspx.*.ascx.*.master所有出错页面文件中的 CodeFile="******.aspx.cs" 批量替换成 Codebehind="******. ...
- linkButton
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...
- C#生成随机汉字
using System; using System.Text; namespace ConsoleApplication { class ChineseCode { ...
- 做.net的早晚会用到,并且网上还没有这方面的正确资料或几乎很少
原文网址:http://www.cnblogs.com/langu/archive/2012/03/23/2413990.html 一直以来,找安装程序的msi源文件路径得到的都是“system32” ...
- JS day01——window对象、执行顺序、线程模型
1.window对象 window对象表示当前浏览器的窗口,它是一个顶级对象,我们创建的所有对象.函数.变量都是window对象的成员. window对象自带了一些非常有用的方法.属性. window ...
- linux 查看磁盘、文件夹、文件大小(df du)
du 查看文件夹大小 1.查看当前文件夹中所有文件夹及其子文件夹的大小,注意是文件夹大小,不是文件 # du -h -rw-r--r-- 1 root root 82785865 6月 9 15:53 ...
- .gitigore 相关
为什么要配置.gitigore 在我们使用git的过程当中,不是任何文件都需要commit到本地或者远程仓库的,比如一些三方库文件.那么作为一个git新手,很多人不知道如何配置.gitignore文件 ...
- [转]理解SSL(https)中的对称加密与非对称加密
加密 解密 Tweet 密码学最早可以追溯到古希腊罗马时代,那时的加密方法很简单:替换字母. 早期的密码学 古希腊人用一种叫 Scytale 的工具加密.更快的工具是 transposition ...
- java基本输入型数据Scanner
import java.util.Scanner; public class Example2_3 { public static void main (String args[ ]){ System ...
- Linux学习 -- Shell编程 -- 字符处理命令
sort排序命令 sort [选项] 文件名 -f 忽略大小m写 -n 按数值型,默认字符串型 -r 反向 -t 指定分隔符 -k n[,m] 指定字段范围,默认行尾 eg. sort -n -t & ...