1 package org.apache.turbine.modules;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.ecs.ConcreteElement;
23
24 import org.apache.turbine.pipeline.PipelineData;
25 import org.apache.turbine.util.InputFilterUtils;
26 import org.apache.turbine.util.RunData;
27
28 /**
29 * This is the base class that defines what a Navigation module is.
30 *
31 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
32 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
33 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
34 * @version $Id: Navigation.java 717934 2008-11-15 21:48:47Z tv $
35 */
36 public abstract class Navigation
37 extends Assembler
38 {
39 /** Prefix for navigation related classes and templates */
40 public static final String PREFIX = "navigations";
41
42 /** Property for the size of the navigation cache if caching is on */
43 public static final String CACHE_SIZE_KEY = "navigation.cache.size";
44
45 /** The default size for the navigation cache */
46 public static final int CACHE_SIZE_DEFAULT = 10;
47
48 /** Represents Navigation Objects */
49 public static final String NAME = "navigation";
50
51 /**
52 * @see org.apache.turbine.modules.Assembler#getPrefix()
53 */
54 public String getPrefix()
55 {
56 return PREFIX;
57 }
58
59 /**
60 * A subclass must override this method to build itself.
61 * Subclasses override this method to store the navigation in
62 * RunData or to write the navigation to the output stream
63 * referenced in RunData.
64 * @deprecated Use PipelineData version instead
65 *
66 * @param data Turbine information.
67 * @exception Exception a generic exception.
68 */
69 protected abstract ConcreteElement doBuild(RunData data)
70 throws Exception;
71
72 /**
73 * Subclasses can override this method to add additional
74 * functionality. This method is protected to force clients to
75 * use NavigationLoader to build a Navigation.
76 * @deprecated Use PipelineData version instead
77 * @param data Turbine information.
78 * @exception Exception a generic exception.
79 */
80 protected ConcreteElement build(RunData data)
81 throws Exception
82 {
83 return doBuild(data);
84 }
85
86 /**
87 * A subclass must override this method to build itself.
88 * Subclasses override this method to store the navigation in
89 * RunData or to write the navigation to the output stream
90 * referenced in RunData.
91 *
92 * @param data Turbine information.
93 * @exception Exception a generic exception.
94 */
95 protected ConcreteElement doBuild(PipelineData pipelineData)
96 throws Exception
97 {
98 RunData data = getRunData(pipelineData);
99 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 }