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