Source code: com/aendvari/tethys/tag/notices/NoticesTagData.java
1 /*
2 * NoticesTagData.java
3 *
4 * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5 *
6 * See the file LICENSE for terms of use.
7 *
8 */
9
10 package com.aendvari.tethys.tag.notices;
11
12 import javax.servlet.*;
13 import javax.servlet.http.*;
14 import javax.servlet.jsp.*;
15
16 import com.aendvari.tethys.*;
17 import com.aendvari.tethys.context.*;
18 import com.aendvari.tethys.tag.data.TagData;
19
20 /**
21 * <p>Provides access to notices tag data.</p>
22 *
23 * <p>The objects in this class are created on demand to reduce unnecessary
24 * object creation.</p>
25 *
26 * @author Trevor Milne
27 *
28 */
29
30 public class NoticesTagData extends TagData
31 {
32 /* Variables */
33
34
35 /** Used to obtain tag data instances. */
36 protected static NoticesTagData accessor = new NoticesTagData();
37
38 /** Container for notification message data. */
39 protected NoticesMap noticesMap;
40
41
42 /* Constants */
43
44
45 protected final static String TagDataKey = TagData.TagDataBase + "/notices";
46
47
48 /* Constructors */
49
50
51 /**
52 * Constructs an empty <code>NoticesTagData</code>.
53 *
54 */
55
56 public NoticesTagData()
57 {
58 noticesMap = null;
59 }
60
61
62 /* Access */
63
64
65 /**
66 * Returns the servlet attribute key for this tag data.
67 *
68 * @return The servlet attribute location for this tag data.
69 *
70 */
71
72 protected String getDataKey()
73 {
74 return TagDataKey;
75 }
76
77 /**
78 * Returns a new instance of this tag data.
79 * This method is to be implemented by subclasses.
80 *
81 * @return The new tag data object.
82 *
83 */
84
85 protected TagData createObject()
86 {
87 return new NoticesTagData();
88 }
89
90
91 /** Wraps {@link TagData#getTagData(HttpServletRequest)}. */
92 public static NoticesTagData getData(HttpServletRequest request) { return (NoticesTagData)accessor.getTagData(request); }
93
94 /** Wraps {@link TagData#getTagData(HttpSession)}. */
95 public static NoticesTagData getData(HttpSession session) { return (NoticesTagData)accessor.getTagData(session); }
96
97 /** Wraps {@link TagData#getTagData(ServletContext)}. */
98 public static NoticesTagData getData(ServletContext context) { return (NoticesTagData)accessor.getTagData(context); }
99
100 /** Wraps {@link TagData#getTagData(PageContext)}. */
101 public static NoticesTagData getData(PageContext context) { return (NoticesTagData)accessor.getTagData(context); }
102
103 /** Wraps {@link TagData#getTagData(PageContext, String)}. */
104 public static NoticesTagData getData(PageContext context, String scope) { return (NoticesTagData)accessor.getTagData(context, scope); }
105
106
107 /** Wraps {@link TagData#setTagData(HttpServletRequest, TagData)}. */
108 public static void setData(HttpServletRequest request, NoticesTagData data) { accessor.setTagData(request, data); }
109
110 /** Wraps {@link TagData#setTagData(HttpSession, TagData)}. */
111 public static void setData(HttpSession session, NoticesTagData data) { accessor.setTagData(session, data); }
112
113 /** Wraps {@link TagData#setTagData(ServletContext, TagData)}. */
114 public static void setData(ServletContext context, NoticesTagData data) { accessor.setTagData(context, data); }
115
116 /** Wraps {@link TagData#setTagData(PageContext, String, TagData)}. */
117 public static void setData(PageContext context, String scope, NoticesTagData data) { accessor.setTagData(context, scope, data); }
118
119
120 /* Notices map */
121
122
123 /**
124 * Returns the notices map of this tag data. A default instance will be created.
125 *
126 * @return A {@link NoticesMap} instance.
127 *
128 */
129
130 public NoticesMap getNoticesMap()
131 {
132 // check if object has not been created
133 if (noticesMap == null)
134 {
135 // create a default instance
136 noticesMap = new NoticesMap();
137 }
138
139 return noticesMap;
140 }
141
142 /**
143 * Sets the notices map of this tag data.
144 *
145 * @param setNoticesMap The new {@link NoticesMap}.
146 *
147 */
148
149 public void setNoticesMap(NoticesMap setNoticesMap)
150 {
151 noticesMap = setNoticesMap;
152 }
153 }
154