net.jcreate.e3.table.model.AbstractDataModel.java Source code

Java tutorial

Introduction

Here is the source code for net.jcreate.e3.table.model.AbstractDataModel.java

Source

/*
 * Copyright 2002-2005 the 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.
 */

/**
 *  E3??QQ:21523645 
 */
package net.jcreate.e3.table.model;

import java.util.Map;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import net.jcreate.e3.table.DataModel;
import net.jcreate.e3.table.PageInfo;
import net.jcreate.e3.table.SortInfo;

/**
 * ????? ,??hasNext,next??
 * @author 
 *
 */
public abstract class AbstractDataModel implements DataModel {

    private final Log logger = LogFactory.getLog(AbstractDataModel.class);

    /**
     * ?
     * @param pItem next?
     * @param pProperty ??
     * @return ?
     */
    public Object getCellValue(Object pItem, String pProperty) {
        if (pItem == null) {
            return null;
        }
        Object itemValue = null;
        if (pItem instanceof Map) {
            itemValue = ((Map) pItem).get(pProperty);
        } else {
            try {
                itemValue = PropertyUtils.getProperty(pItem, pProperty);
            } catch (Exception ex) {
                if (logger.isDebugEnabled()) {
                    logger.debug(":" + pItem.getClass().getName() + "?:" + pProperty);
                }
            } //end try-catch
        } //end else
        return itemValue;
    }

    private final PageInfo navInfo;
    private final SortInfo sortInfo;

    public AbstractDataModel() {
        this.navInfo = null;
        this.sortInfo = null;

    }

    public AbstractDataModel(SortInfo pSortInfo, PageInfo pNavInfo) {
        this.navInfo = pNavInfo;
        this.sortInfo = pSortInfo;

    }

    /**
     * ??
     * @return
     */
    public PageInfo getNavInfo() {
        return navInfo;
    }

    /**
     * ???
     * @return
     */
    public SortInfo getSortInfo() {
        return sortInfo;
    }

}