KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > modules > Screen


1 package org.apache.turbine.modules;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import org.apache.ecs.ConcreteElement;
20
21 import org.apache.turbine.util.InputFilterUtils;
22 import org.apache.turbine.util.RunData;
23
24 /**
25  * This is the base class which defines the Screen modules.
26  *
27  * @author <a HREF="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
28  * @author <a HREF="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
29  * @version $Id: Screen.java,v 1.4.2.2 2004/05/20 03:03:52 seade Exp $
30  */

31 public abstract class Screen
32     extends Assembler
33 {
34     /**
35      * A subclass must override this method to build itself.
36      * Subclasses override this method to store the screen in RunData
37      * or to write the screen to the output stream referenced in
38      * RunData.
39      *
40      * @param data Turbine information.
41      * @exception Exception a generic exception.
42      */

43     protected abstract ConcreteElement doBuild(RunData data)
44         throws Exception JavaDoc;
45
46     /**
47      * Subclasses can override this method to add additional
48      * functionality. This method is protected to force clients to
49      * use ScreenLoader to build a Screen.
50      *
51      * @param data Turbine information.
52      * @exception Exception a generic exception.
53      */

54     protected ConcreteElement build(RunData data)
55         throws Exception JavaDoc
56     {
57         return doBuild(data);
58     }
59
60     /**
61      * If the Layout has not been defined by the Screen then set the
62      * layout to be "DefaultLayout". The Screen object can also
63      * override this method to provide intelligent determination of
64      * the Layout to execute. You can also define that logic here as
65      * well if you want it to apply on a global scale. For example,
66      * if you wanted to allow someone to define Layout "preferences"
67      * where they could dynamically change the Layout for the entire
68      * site. The information for the request is passed in with the
69      * RunData object.
70      *
71      * @param data Turbine information.
72      * @return A String with the Layout.
73      */

74     public String JavaDoc getLayout(RunData data)
75     {
76         return data.getLayout();
77     }
78
79     /**
80      * Set the layout for a Screen.
81      *
82      * @param data Turbine information.
83      * @param layout The layout name.
84      */

85     public void setLayout(RunData data, String JavaDoc layout)
86     {
87         data.setLayout(layout);
88     }
89
90     /**
91      * This function can/should be used in any screen that will output
92      * User entered text. This will help prevent users from entering
93      * html (<SCRIPT>) tags that will get executed by the browser.
94      *
95      * @param s The string to prepare.
96      * @return A string with the input already prepared.
97      * @deprecated Use InputFilterUtils.prepareText(String s)
98      */

99     public static String JavaDoc prepareText(String JavaDoc s)
100     {
101         return InputFilterUtils.prepareText(s);
102     }
103
104     /**
105      * This function can/should be used in any screen that will output
106      * User entered text. This will help prevent users from entering
107      * html (<SCRIPT>) tags that will get executed by the browser.
108      *
109      * @param s The string to prepare.
110      * @return A string with the input already prepared.
111      * @deprecated Use InputFilterUtils.prepareTextMinimum(String s)
112      */

113     public static String JavaDoc prepareTextMinimum(String JavaDoc s)
114     {
115         return InputFilterUtils.prepareTextMinimum(s);
116     }
117 }
118
Popular Tags