KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > TagConfig


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

18 package org.apache.beehive.netui.tags;
19
20 import org.apache.beehive.netui.tags.tree.InheritableState;
21 import org.apache.beehive.netui.util.config.ConfigUtil;
22 import org.apache.beehive.netui.util.config.bean.JspTagConfig;
23
24
25 /**
26  * This class implements a series of static method that will return configuration information. The
27  * information is buffered, and config properties values defined here. The document type configuration
28  * is not found in this class. It is found TagRenderBase {@link org.apache.beehive.netui.tags.rendering.TagRenderingBase}
29  * and the HTML tag {@link org.apache.beehive.netui.tags.html.Html}.
30  */

31 final public class TagConfig
32 {
33     // This is the value of the javascript support for the webapp. This should
34
// be one of the enum values defined above.
35
private static int javascriptMode = -1;
36
37     private static String JavaDoc defaultTreeImageLocation = null;
38
39
40     /**
41      * Return true if the legacy JavaScript support should be written to the output stream.
42      * @return boolean
43      */

44     public static boolean isLegacyJavaScript()
45     {
46         if (javascriptMode == -1) {
47             setLegacyJavaScriptMode();
48         }
49         assert(javascriptMode != -1);
50         return (javascriptMode == JspTagConfig.IdJavascript.INT_LEGACY
51                 || javascriptMode == JspTagConfig.IdJavascript.INT_LEGACY_ONLY);
52     }
53
54     /**
55      * Return true if the default JavaScript support should be written to the output stream.
56      * @return boolean
57      */

58     public static boolean isDefaultJavaScript()
59     {
60         if (javascriptMode == -1) {
61             setLegacyJavaScriptMode();
62         }
63         assert(javascriptMode != -1);
64         return (javascriptMode == JspTagConfig.IdJavascript.INT_DEFAULT
65                 || javascriptMode == JspTagConfig.IdJavascript.INT_LEGACY);
66     }
67
68     /**
69      * This method returns the default location for the tree images. This may be configured by setting
70      * the <tree-image-location> element in the netui.config file to the location of the images.
71      * This location should not include the context path of the webapp or the leading '/', but should be an absolute
72      * path within the webapp.
73      * <p>&lt;tree-image-location>resources/images&lt;/tree-image-location>
74      * </p>
75      * @return the default location of the tree images.
76      */

77     public static String JavaDoc getTreeImageLocation()
78     {
79         if (defaultTreeImageLocation == null) {
80             JspTagConfig tagConfig = ConfigUtil.getConfig().getJspTagConfig();
81             if (tagConfig != null) {
82                 String JavaDoc s = tagConfig.getTreeImageLocation();
83                 defaultTreeImageLocation = (s != null) ? s : InheritableState.DEFAULT_IMAGES;
84             }
85             else
86                 defaultTreeImageLocation = InheritableState.DEFAULT_IMAGES;
87         }
88         assert(defaultTreeImageLocation != null);
89         return defaultTreeImageLocation;
90     }
91
92     /**
93      * This will set the JavaScript support level for the id and name attributes.
94      */

95     private static void setLegacyJavaScriptMode()
96     {
97         JspTagConfig tagConfig = ConfigUtil.getConfig().getJspTagConfig();
98         if (tagConfig != null) {
99             javascriptMode = tagConfig.getIdJavascript().intValue();
100         }
101         else {
102             javascriptMode = JspTagConfig.IdJavascript.INT_DEFAULT;
103         }
104     }
105 }
106
Popular Tags