    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.ecs.ConcreteElement;
    023
    024    import org.apache.turbine.pipeline.PipelineData;
    025    import org.apache.turbine.util.InputFilterUtils;
    026    import org.apache.turbine.util.RunData;
    027
    028    /**
    029     * This is the base class that defines what a Navigation module is.
    030     *
    031     * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
    032     * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    033     * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
    034     * @version $Id: Navigation.java 717934 2008-11-15 21:48:47Z tv $
    035     */
    036    public abstract class Navigation
    037        extends Assembler
    038    {
    039        /** Prefix for navigation related classes and templates */
    040        public static final String PREFIX = "navigations";
    041
    042        /** Property for the size of the navigation cache if caching is on */
    043        public static final String CACHE_SIZE_KEY = "navigation.cache.size";
    044
    045        /** The default size for the navigation cache */
    046        public static final int CACHE_SIZE_DEFAULT = 10;
    047
    048        /** Represents Navigation Objects */
    049        public static final String NAME = "navigation";
    050
    051        /**
    052         * @see org.apache.turbine.modules.Assembler#getPrefix()
    053         */
    054        public String getPrefix()
    055        {
    056            return PREFIX;
    057        }
    058
    059        /**
    060         * A subclass must override this method to build itself.
    061         * Subclasses override this method to store the navigation in
    062         * RunData or to write the navigation to the output stream
    063         * referenced in RunData.
    064         * @deprecated Use PipelineData version instead
    065         *
    066         * @param data Turbine information.
    067         * @exception Exception a generic exception.
    068         */
    069        protected abstract ConcreteElement doBuild(RunData data)
    070            throws Exception;
    071
    072        /**
    073         * Subclasses can override this method to add additional
    074         * functionality.  This method is protected to force clients to
    075         * use NavigationLoader to build a Navigation.
    076         * @deprecated Use PipelineData version instead
    077         * @param data Turbine information.
    078         * @exception Exception a generic exception.
    079         */
    080        protected ConcreteElement build(RunData data)
    081            throws Exception
    082        {
    083            return doBuild(data);
    084        }
    085
    086        /**
    087         * A subclass must override this method to build itself.
    088         * Subclasses override this method to store the navigation in
    089         * RunData or to write the navigation to the output stream
    090         * referenced in RunData.
    091         *
    092         * @param data Turbine information.
    093         * @exception Exception a generic exception.
    094         */
    095        protected ConcreteElement doBuild(PipelineData pipelineData)
    096            throws Exception
    097        {
    098            RunData data = getRunData(pipelineData);
    099            return doBuild(data);
    100        }
    101
    102        /**
    103         * Subclasses can override this method to add additional
    104         * functionality.  This method is protected to force clients to
    105         * use NavigationLoader to build a Navigation.
    106         *
    107         * @param data Turbine information.
    108         * @exception Exception a generic exception.
    109         */
    110        protected ConcreteElement build(PipelineData pipelineData)
    111            throws Exception
    112        {
    113            return doBuild(pipelineData);
    114        }
    115
    116
    117        /**
    118         * This function can/should be used in any screen that will output
    119         * User entered text.  This will help prevent users from entering
    120         * html (<SCRIPT>) tags that will get executed by the browser.
    121         *
    122         * @param s The string to prepare.
    123         * @return A string with the input already prepared.
    124         * @deprecated Use InputFilterUtils.prepareText(String s)
    125         */
    126        public static String prepareText(String s)
    127        {
    128            return InputFilterUtils.prepareText(s);
    129        }
    130    }