分页排序小计

霸气de小男生 提交于 2020-01-20 21:22:56
public Sort getSort(Pager pager) {
    Sort sort = null;

    try {
        ArrayList orders;
        int i;
        Sort.Order order;
        if (pager.getExtString().equals("DESC")) {
            if (pager.getSortFields().length == 1) {
                sort = Sort.by(new Sort.Order[]{new Sort.Order(Sort.Direction.DESC, pager.getSortFields()[0])});
            } else {
                orders = new ArrayList();

                for (i = 0; i < pager.getSortFields().length; ++i) {
                    order = new Sort.Order(Sort.Direction.DESC, pager.getSortFields()[i]);
                    orders.add(order);
                }

                sort = Sort.by(orders);
            }
        }

        if (pager.getExtString().equals("ASC")) {
            if (pager.getSortFields().length == 1) {
                sort = Sort.by(new Sort.Order[]{new Sort.Order(Sort.Direction.ASC, pager.getSortFields()[0])});
            } else {
                orders = new ArrayList();

                for (i = 0; i < pager.getSortFields().length; ++i) {
                    order = new Sort.Order(Sort.Direction.ASC, pager.getSortFields()[i]);
                    orders.add(order);
                }

                sort = Sort.by(orders);
            }
        }

        return sort;
    } catch (Exception var6) {
        this.logger.error(var6.toString());
        return new Sort(new Sort.Order[]{new Sort.Order(Sort.Direction.ASC, pager.getSortFields()[0])});
    }
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!