1 package org.apache.velocity.tools.plugin.taglib.model;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.HashMap;
23 import java.util.Map;
24
25 import org.apache.commons.digester.annotations.rules.BeanPropertySetter;
26 import org.apache.commons.digester.annotations.rules.ObjectCreate;
27 import org.apache.commons.digester.annotations.rules.SetTop;
28
29
30
31
32 @ObjectCreate(pattern = "taglib/tag/attribute")
33 public class Attribute
34 {
35
36
37
38
39 private static Map<String, String> primitive2wrapped;
40
41 static {
42 primitive2wrapped = new HashMap<String, String>();
43 primitive2wrapped.put("byte", Byte.class.getName());
44 primitive2wrapped.put("short", Short.class.getName());
45 primitive2wrapped.put("int", Integer.class.getName());
46 primitive2wrapped.put("long", Long.class.getName());
47 primitive2wrapped.put("float", Float.class.getName());
48 primitive2wrapped.put("double", Double.class.getName());
49 primitive2wrapped.put("char", Character.class.getName());
50 primitive2wrapped.put("boolean", Boolean.class.getName());
51 }
52
53
54
55
56 @BeanPropertySetter(pattern = "taglib/tag/attribute/name")
57 private String name;
58
59
60
61
62 @BeanPropertySetter(pattern = "taglib/tag/attribute/description")
63 private String description;
64
65
66
67
68 @BeanPropertySetter(pattern = "taglib/tag/attribute/required")
69 private boolean required = false;
70
71
72
73
74 @BeanPropertySetter(pattern = "taglib/tag/attribute/rtexprvalue")
75 private boolean rtexprvalue = false;
76
77
78
79
80 @BeanPropertySetter(pattern = "taglib/tag/attribute/type")
81 private String type;
82
83
84
85
86 private Tag tag;
87
88
89
90
91
92
93 public String getName()
94 {
95 return name;
96 }
97
98
99
100
101
102
103 public void setName(String name)
104 {
105 this.name = name;
106 }
107
108
109
110
111
112
113 public String getDescription()
114 {
115 return description;
116 }
117
118
119
120
121
122
123 public void setDescription(String description)
124 {
125 this.description = description;
126 }
127
128
129
130
131
132
133 public boolean isRequired()
134 {
135 return required;
136 }
137
138
139
140
141
142
143 public void setRequired(boolean required)
144 {
145 this.required = required;
146 }
147
148
149
150
151
152
153 public boolean isRtexprvalue()
154 {
155 return rtexprvalue;
156 }
157
158
159
160
161
162
163 public void setRtexprvalue(boolean rtexprvalue)
164 {
165 this.rtexprvalue = rtexprvalue;
166 }
167
168
169
170
171
172
173 public String getType()
174 {
175 return type;
176 }
177
178
179
180
181
182
183 public void setType(String type)
184 {
185 this.type = type;
186 }
187
188
189
190
191
192
193 @SetTop(pattern="taglib/tag/attribute")
194 public void setJTag(Tag tag)
195 {
196 this.tag = tag;
197 }
198
199
200
201
202
203
204 public Tag getTag()
205 {
206 return tag;
207 }
208
209
210
211
212
213
214 public String getWrappedType() {
215 if (type == null) {
216 return String.class.getName();
217 }
218 String retValue = primitive2wrapped.get(type);
219 if (retValue == null) {
220 retValue = type;
221 }
222 return retValue;
223 }
224
225
226
227
228
229
230 public String getSetterName() {
231 return "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
232 }
233
234 @Override
235 public String toString()
236 {
237 return "Attribute [name=" + name + ", description=" + description
238 + ", required=" + required + ", rtexprvalue=" + rtexprvalue
239 + ", type=" + type + "]";
240 }
241
242 }