⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 processrowscallback.java

📁 exTreme taglib的使用
💻 JAVA
字号:
/* * Copyright 2004 original author or authors. *  * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at *  * http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */package org.extremecomponents.table.callback;import java.util.ArrayList;import java.util.Collection;import java.util.Collections;import java.util.List;import org.apache.commons.beanutils.BeanComparator;import org.apache.commons.collections.CollectionUtils;import org.apache.commons.collections.comparators.NullComparator;import org.apache.commons.collections.comparators.ReverseComparator;import org.extremecomponents.table.bean.Table;import org.extremecomponents.table.core.BaseModel;import org.extremecomponents.table.core.TableConstants;import org.extremecomponents.table.limit.Sort;/** * The default implementation of the callbacks that handle the retrieving, * filtering, and sorting of the collection that gets passed to the * eXtremeTable. *  * @author Jeff Johnston */public final class ProcessRowsCallback implements RetrieveRowsCallback, FilterRowsCallback, SortRowsCallback {    public Collection retrieveRows(BaseModel model)            throws Exception {        Table table = model.getTableHandler().getTable();        Object items = table.getItems();        if (items instanceof Collection) {            return (Collection) items;        } else if (items instanceof String) {            return CallbackUtils.findCollection(model, table);        } else {            throw new Exception("The eXtremeComponent could not find the Collection of Beans (or Map).");        }    }    public Collection filterRows(BaseModel model, Collection rows)            throws Exception {        if (model.getLimit().isFiltered()) {            Collection collection = new ArrayList();            FilterPredicate filterPredicate = new FilterPredicate(model);            CollectionUtils.select(rows, filterPredicate, collection);            return collection;        }                return rows;    }    public Collection sortRows(BaseModel model, Collection rows)            throws Exception {        Sort sort = model.getLimit().getSort();        String property = sort.getProperty();        String sortOrder = sort.getSortOrder();        if (sortOrder.equals(TableConstants.SORT_ASC)) {            BeanComparator comparator = new BeanComparator(property, new NullComparator());            Collections.sort((List) rows, comparator);        } else if (sortOrder.equals(TableConstants.SORT_DESC)) {            BeanComparator reversedNaturalOrderBeanComparator = new BeanComparator(property, new ReverseComparator(                    new NullComparator()));            Collections.sort((List) rows, reversedNaturalOrderBeanComparator);        }        return rows;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -