KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > rendering > AbstractHtmlState


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.rendering;
19
20 import java.util.HashMap JavaDoc;
21 import java.util.Map JavaDoc;
22
23 /**
24  * This class extends the <code>AbstractAttributeState</code> to add support for HTML.
25  * This class add support for the <code>id</code>, <code>style</code>, and <code>class</code>
26  * attributes. In addition, there is a <code>Map</code> that supports the JavaScript
27  * event attributes.
28  */

29 public class AbstractHtmlState extends AbstractAttributeState
30 {
31     /**
32      * Define the Attribute Map for the JavaScript event handler attributes.
33      */

34     public static final int ATTR_JAVASCRIPT = 12;
35
36     /**
37      * The HTML <code>id</code> attribute.
38      */

39     public String JavaDoc id;
40
41     /**
42      * The HTML <code>style</code> attribute.
43      */

44     public String JavaDoc style;
45
46     /**
47      * The HTML <code>class</code> attribute.
48      */

49     public String JavaDoc styleClass;
50
51     private HashMap JavaDoc _jsMap = null; // Map used to hold the registered JavaScript attributes.
52

53     /**
54      * Return the Map Containing the JavaScript entries.
55      * @return a <code>Map</code> of the JavaScript attributes.
56      */

57     public HashMap JavaDoc getEventMap()
58     {
59         return _jsMap;
60     }
61
62     /**
63      * Initialize the state.
64      */

65     public void clear()
66     {
67         super.clear();
68
69         if (_jsMap != null)
70             _jsMap.clear();
71
72         id = null;
73         style = null;
74         styleClass = null;
75     }
76
77     /**
78      * This method will return the map that represents the passed in <code>type</code>. The boolean flag
79      * </code>createIfNull</code> indicates that the map should be created or not if it's null. This
80      * class defines two maps defined by <code>@see #ATTR_STYLE</code> and <code>ATTR_JAVASCRIPT</code>
81      * @param type <code>integer</code> type indentifying the map to be created.
82      * @param createIfNull <code>boolean</code> flag indicating if the map should be created if it doesn't exist.
83      * @return The map or null
84      * @see #ATTR_JAVASCRIPT
85      */

86     public Map JavaDoc selectMap(int type, boolean createIfNull)
87     {
88         if (type == ATTR_JAVASCRIPT) {
89             if (_jsMap == null && createIfNull)
90                 _jsMap = new HashMap JavaDoc();
91             return _jsMap;
92         }
93         return super.selectMap(type, createIfNull);
94     }
95 }
96
Popular Tags