利用java.util.Collections.sort方法排序

利用java.util.Collections.sort方法排序

None.gif      // 所有选项集合
None.gif
                List lsDefineOptions  =   new  ArrayList();
None.gif                
ExpandedBlockStart.gifContractedBlock.gif                
for ( int  j = 0 ;j < lsOptions.size();j ++ ) dot.gif {
InBlock.gif                    Element option 
= (Element) lsOptions.get(j);
InBlock.gif                    String label 
= option.getAttributeValue("label");
InBlock.gif                    String index 
= option.getAttributeValue("index");
InBlock.gif                    String flowstate 
= option.getAttributeValue("flowstate");
InBlock.gif                    String querySql 
= option.getChildText("query-sql");
InBlock.gif                    
InBlock.gif                    
//操作项对象
InBlock.gif
                    SearchOptionDefine defineOption = new SearchOptionDefine();
InBlock.gif                    defineOption.setLabel(label);
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
if(StringUtils.isNotBlank(index))dot.gif{
InBlock.gif                        defineOption.setIndex(Integer.parseInt(index));
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockStart.gifContractedSubBlock.gif                    
if(StringUtils.isNotBlank(flowstate))dot.gif{
InBlock.gif                        defineOption.setFlowstate(Integer.parseInt(flowstate));
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    defineOption.setQuerySql(querySql);
InBlock.gif                    Log.debug(
"querySql:"+querySql);
InBlock.gif                    
InBlock.gif                    lsDefineOptions.add(defineOption);
ExpandedBlockEnd.gif                }

None.gif                
None.gif                
// 所有选项集合的排序
None.gif
                java.util.Collections.sort(lsDefineOptions);
操作项对象 SearchOptionDefine 必须实现Comparable接口
None.gif package  com.mip.core.objects;
None.gif
None.gif
import  java.io.Serializable;
None.gif
ExpandedBlockStart.gifContractedBlock.gif
/** */ /**
InBlock.gif * <p> 
InBlock.gif * 主题查询对象
InBlock.gif * </p>
InBlock.gif * 
@author Libin
InBlock.gif * @date Mar 29, 2007
InBlock.gif * 
@version 4.0
InBlock.gif *
InBlock.gif * 
@see AnotherClass
ExpandedBlockEnd.gif 
*/

ExpandedBlockStart.gifContractedBlock.gif
public   class  SearchOptionDefine  implements  Serializable,Comparable  dot.gif {
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/** *//**
InBlock.gif     * 
ExpandedSubBlockEnd.gif     
*/

InBlock.gif    
private static final long serialVersionUID = 3256440313546683697L;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/** *//** A int variable 所有状态标志*/
InBlock.gif    
public static final int ALL_STATE=999;
InBlock.gif    
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/** *//**
InBlock.gif     * Constructs a SearchDefine
ExpandedSubBlockEnd.gif     
*/

ExpandedSubBlockStart.gifContractedSubBlock.gif    
public SearchOptionDefine()dot.gif{
InBlock.gif        index
=0;
InBlock.gif        flowstate
=ALL_STATE;
ExpandedSubBlockEnd.gif    }

InBlock.gif    
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/** *//**
InBlock.gif     * 主题查询的每一项定义:
InBlock.gif    *    label:对应下拉框显示的中文名称
InBlock.gif    *    index:排序序号
InBlock.gif    *    flowstate:对应流程状态,结合流程状态来确定是否显示当前选项
InBlock.gif    *    query_sql:原生SQL语句,主题查询的条件
ExpandedSubBlockEnd.gif    
*/
    
InBlock.gif    
private String label;
InBlock.gif    
private Integer index;
InBlock.gif    
private Integer flowstate;
InBlock.gif    
private String querySql;
InBlock.gif    
ExpandedSubBlockStart.gifContractedSubBlock.gif    
public Integer getFlowstate() dot.gif{
InBlock.gif        
return flowstate;
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
public void setFlowstate(Integer flowstate) dot.gif{
InBlock.gif        
this.flowstate = flowstate;
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
public Integer getIndex() dot.gif{
InBlock.gif        
return index;
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
public void setIndex(Integer index) dot.gif{
InBlock.gif        
this.index = index;
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
public String getLabel() dot.gif{
InBlock.gif        
return label;
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
public void setLabel(String label) dot.gif{
InBlock.gif        
this.label = label;
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
public String getQuerySql() dot.gif{
InBlock.gif        
return querySql;
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
public void setQuerySql(String query_sql) dot.gif{
InBlock.gif        
this.querySql = query_sql;
ExpandedSubBlockEnd.gif    }

InBlock.gif    
ExpandedSubBlockStart.gifContractedSubBlock.gif    
public int compareTo(Integer arg0) dot.gif{
InBlock.gif        
return index.compareTo(arg0);
ExpandedSubBlockEnd.gif    }

InBlock.gif    
ExpandedSubBlockStart.gifContractedSubBlock.gif    
public int compareTo(Object obj) dot.gif{
InBlock.gif        
// TODO Auto-generated method stub
InBlock.gif
        return (this.getIndex() - ((SearchOptionDefine)obj).getIndex());
ExpandedSubBlockEnd.gif    }

InBlock.gif    
InBlock.gif    
InBlock.gif    
ExpandedBlockEnd.gif}

None.gif
107198.html

Lib 2007-03-29 13:15 发表评论
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值