    001    package org.apache.turbine.modules;
    002
    003    /*
    004     * Licensed to the Apache Software Foundation (ASF) under one
    005     * or more contributor license agreements.  See the NOTICE file
    006     * distributed with this work for additional information
    007     * regarding copyright ownership.  The ASF licenses this file
    008     * to you under the Apache License, Version 2.0 (the
    009     * "License"); you may not use this file except in compliance
    010     * with the License.  You may obtain a copy of the License at
    011     *
    012     *   http://www.apache.org/licenses/LICENSE-2.0
    013     *
    014     * Unless required by applicable law or agreed to in writing,
    015     * software distributed under the License is distributed on an
    016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    017     * KIND, either express or implied.  See the License for the
    018     * specific language governing permissions and limitations
    019     * under the License.
    020     */
    021
    022    import org.apache.turbine.pipeline.PipelineData;
    023    import org.apache.turbine.util.RunData;
    024
    025    /**
    026     * This is the base class that defines what a Layout module is.
    027     *
    028     * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
    029     * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
    030     * @version $Id: Layout.java 717934 2008-11-15 21:48:47Z tv $
    031     */
    032    public abstract class Layout
    033        extends Assembler
    034    {
    035        /** Prefix for layout related classes and templates */
    036        public static final String PREFIX = "layouts";
    037
    038        /** Property for the size of the layout cache if caching is on */
    039        public static final String CACHE_SIZE_KEY = "layout.cache.size";
    040
    041        /** The default size for the layout cache */
    042        public static final int CACHE_SIZE_DEFAULT = 10;
    043
    044        /** Represents Layout Objects */
    045        public static final String NAME = "layout";
    046
    047        /**
    048         * @see org.apache.turbine.modules.Assembler#getPrefix()
    049         */
    050        public String getPrefix()
    051        {
    052            return PREFIX;
    053        }
    054
    055        /**
    056         * A subclass must override this method to build itself.
    057         * Subclasses override this method to store the layout in RunData
    058         * or to write the layout to the output stream referenced in
    059         * RunData.
    060         * @deprecated Use PipelineData version instead
    061         *
    062         * @param data Turbine information.
    063         * @exception Exception a generic exception.
    064         */
    065        protected abstract void doBuild(RunData data)
    066            throws Exception;
    067
    068        /**
    069         * Subclasses can override this method to add additional
    070         * functionality.  This method is protected to force clients to
    071         * use LayoutLoader to build a Layout.
    072         * @deprecated Use PipelineData version instead
    073         * @param data Turbine information.
    074         * @exception Exception a generic exception.
    075         */
    076        protected void build(RunData data)
    077            throws Exception
    078        {
    079            doBuild(data);
    080        }
    081
    082
    083        /**
    084         * A subclass must override this method to perform itself.  The
    085         * Action can also set the screen that is associated with RunData.
    086         * Should revert to abstract when RunData is gone.
    087         * @param data Turbine information.
    088         * @exception Exception a generic exception.
    089         */
    090        protected void doBuild(PipelineData pipelineData) throws Exception
    091        {
    092            RunData data = getRunData(pipelineData);
    093            doBuild(data);
    094        }
    095
    096        /**
    097         * Subclasses can override this method to add additional
    098         * functionality.  This method is protected to force clients to
    099         * use ActionLoader to perform an Action.
    100         *
    101         * @param data Turbine information.
    102         * @exception Exception a generic exception.
    103         */
    104        protected void build(PipelineData pipelineData) throws Exception
    105        {
    106            doBuild(pipelineData);
    107        }
    108
    109
    110    }