?? basemodel.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.base;import java.util.Collection;import java.util.HashMap;import java.util.Map;import javax.servlet.jsp.PageContext;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.extremecomponents.table.cell.Cell;import org.extremecomponents.table.core.AutoGenerateColumns;import org.extremecomponents.table.core.ParameterRegistry;import org.extremecomponents.table.handler.ColumnHandler;import org.extremecomponents.table.handler.ExportHandler;import org.extremecomponents.table.handler.FilterHandler;import org.extremecomponents.table.handler.FormHandler;import org.extremecomponents.table.handler.PaginationHandler;import org.extremecomponents.table.handler.TableHandler;/** * org.extremecomponents.core.model.BaseModel.java - * * @author phorn */public abstract class BaseModel { private static Log logger = LogFactory.getLog(BaseModel.class); private PageContext pageContext; private ParameterRegistry registry = new ParameterRegistry(this); private ExportHandler exportHandler = new ExportHandler(this); private FilterHandler filterHandler = new FilterHandler(this); private PaginationHandler pageHandler = new PaginationHandler(this); private FormHandler formHandler = new FormHandler(); private ColumnHandler columnHandler = new ColumnHandler(this); private TableHandler tableHandler = new TableHandler(this); //cache out some objects private Map cellCache = new HashMap(); private Map callbacks = new HashMap(); //cache this out AutoGenerateColumns autoGenerateColumns; public BaseModel(PageContext pageContext) { this.pageContext = pageContext; } /** * Access to the Servlet pageContext() */ public PageContext getPageContext() { return pageContext; } /** * A simple implementation of a cache for the Cell definitions. */ public Cell getCachedCell(Class classDefinition) { Cell cell = (Cell) cellCache.get(classDefinition); if (cell == null) { try { Object object = classDefinition.newInstance(); cell = (Cell) object; cellCache.put(classDefinition, cell); if (logger.isDebugEnabled()) { logger.debug("Cache the Cell [" + classDefinition + "]"); } } catch (Exception e) { logger.error("Model.build()", e); } } return cell; } /** * Return the proper callback. The trick here is that could return the same * class for different callbacks. This is a feature so that do not have to * make different classes for each individual callback. */ public Object getCallback(String callbackClassName) throws Exception { Object result = callbacks.get(callbackClassName); if (result != null) { return result; } Class classDefinition = Class.forName(callbackClassName); result = classDefinition.newInstance(); callbacks.put(callbackClassName, result); return result; } public Map getCellCache() { return cellCache; } public ParameterRegistry getRegistry() { return registry; } public ColumnHandler getColumnHandler() { return columnHandler; } public TableHandler getTableHandler() { return tableHandler; } public ExportHandler getExportHandler() { return exportHandler; } public FilterHandler getFilterHandler() { return filterHandler; } public PaginationHandler getPaginationHandler() { return pageHandler; } public FormHandler getFormHandler() { return formHandler; } public AutoGenerateColumns getAutoGenerateColumns() { return autoGenerateColumns; } public void setAutoGenerateColumns(AutoGenerateColumns autoGenerateColumns) { this.autoGenerateColumns = autoGenerateColumns; } public void destroy() { exportHandler.destroy(); exportHandler = null; filterHandler.destroy(); filterHandler = null; formHandler.destroy(); formHandler = null; columnHandler.destroy(); columnHandler = null; tableHandler.destroy(); tableHandler = null; autoGenerateColumns = null; } public abstract Collection execute() throws Exception; public abstract BaseSortHandler getSortHandler(); public abstract BaseViewHandler getViewHandler(); public abstract BaseProperties getProperties(); public abstract BaseResourceBundle getResourceBundle();}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -