你换在写n个比较器进行比较吗?
import java.util.Comparator;
import java.util.logging.Logger;
import org.apache.commons.beanutils.BeanUtils;
/**
* 排序的类的应用
* @author bailonggang
* 2008-12-7
* 上午11:21:51
*/
public class CompartorUtil implements Comparator<Object>{
/***对象的升序应用**/
public static final int SORT_DESC=0;
/***对象的降序应用**/
public static final int SORT_ASC=1;
private static Logger logger=Logger.getLogger(CompartorUtil.class.getName());
//排序的属性
private String property;
//排序的类型升降序
private int sortType;
public CompartorUtil(String property,int sortType)
{
this.property=property;
this.sortType=sortType;
}
/**
*排序的实现的类的
*/
@SuppressWarnings("unchecked")
public int compare(Object o1,Object o2) {
try {
String property0=BeanUtils.getProperty(o1, this.property);
String property1=BeanUtils.getProperty(o2, this.property);
int result=0;
result=property0.compareTo(property1);
if(SORT_DESC==this.sortType)
{
result=-result;
}
if(result>=1)
{
return 1;
}else if(result<=-1)
{
return -1;
}
return result;
} catch (Exception e) {
logger.info("对象排序时错误:"+e);
}
return 0;
}
}
如果有什么好的改进请告诉我谢谢,!!!
分享到:
相关推荐
它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。同时Apache音译为阿帕奇,是北美印第安人的一个部落,叫阿帕奇族,在美国的西南部。也是一个基金会...
`TestFTP_ddxc`这个文件可能是一个测试程序,包含了如何使用Apache FTP库进行文件上传和下载的示例代码。在这个程序中,开发者可能演示了如何打开和关闭连接,创建或改变远程目录,上传和下载文件,以及如何处理断点...
使用apatche的jar包 已有 commons beanutils 1 8 3 jar 复制 commons collections 3 2 1 jar 对java util的增强 commons lang 2 5 jar 对java lang的增强 commons logging 1 1 1 jar 日志 ">JSON 类库...
Apache最新的Dcommons-dbcp2-2.7.0和commons-pool2-2.7.0数据源及数据库连接池Jar包
- **元数据管理**:Kylin使用HBase和HDFS来存储元数据,确保高可用性和持久性。 3. **与HBase的关系**: - **数据存储**:在Kylin中,预计算的立方体数据默认存储在HBase中,利用其列式存储和分布式特性,实现...
* 使用apatche的jar包 * commons-beanutils-1.8.3.jar(复制) * commons-collections-3.2.1.jar(对java.util的增强) * commons-lang-2.5.jar(对java.lang的增强) * commons-logging-1.1.1.jar(日志 )
* 使用apatche的jar包 * commons-beanutils-1.8.3.jar(复制) * commons-collections-3.2.1.jar(对java.util的增强) * commons-lang-2.5.jar(对java.lang的增强) * commons-logging-1.1.1.jar(日志 )
Alog日志系统原名Logs,现...a.Apatche服务器请在设置后,复制rewrite目录下.htaccess文件到网站根目录。 b.IIS服务器请在设置后,复制rewrite目录下httpd.ini文件到网站根目录。 c.其他服务器,如Nginx等参照设置。
URL路由开关说明当URL路由设置为开启时页面路径将使用伪静态,请根据服务器情况设置响应的伪静态规则。a.Apatche服务器请在设置后,复制rewrite目录下.htaccess文件到网站根目录。b.IIS服务器请在设置后,复制...
CloudTest is an open source project initiated by the individual, which is distributed on Apatche Licenses 2.0 releases. Every organization or individual is fully granted for viewing its source code or...
apatche开源项目echo的第三版示例,全用的javascript,强烈建议那些想写桌面型的胖客户端看看。其中的源码都可以下载的,或者用那些chm查看器解压缩就可以了
URL路由开关说明 --------------------------------------------------------- 当URL路由设置为开启时页面路径将使用伪静态,请根据服务器情 况设置响应的伪静态规则。 a.Apatche服务器请在设置后,复制rewrite目录...
vRules4j是由个人发起的开源项目,它基于Apatche Licenses 2.0 免费发布。任何组织或者个人都可以查看其源码并根据自己的需要修改源码,同时在商业应用中具有最大的授权许可。具体Licenses 条款请参阅...