1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.tiles.autotag.model;
22
23 import java.util.Collection;
24 import java.util.LinkedHashMap;
25 import java.util.Map;
26
27
28
29
30
31
32 public class TemplateClass {
33
34
35
36
37 private String name;
38
39
40
41
42 private String tagName;
43
44
45
46
47 private String tagClassPrefix;
48
49
50
51
52 private String documentation;
53
54
55
56
57 private TemplateMethod executeMethod;
58
59
60
61
62
63
64 public TemplateClass(String name) {
65 this(name, null, null, null);
66 }
67
68
69
70
71
72
73
74
75
76 public TemplateClass(String name, String tagName, String tagClassPrefix,
77 TemplateMethod executeMethod) {
78 this.name = name;
79 this.tagName = tagName;
80 this.tagClassPrefix = tagClassPrefix;
81 this.executeMethod = executeMethod;
82 }
83
84
85
86
87
88
89 public String getName() {
90 return name;
91 }
92
93
94
95
96
97
98 public String getSimpleName() {
99 int pos = name.lastIndexOf('.');
100 if (pos >= 0) {
101 return name.substring(pos + 1);
102 }
103 return name;
104 }
105
106
107
108
109
110
111 public String getTagName() {
112 return tagName;
113 }
114
115
116
117
118
119
120 public String getTagClassPrefix() {
121 return tagClassPrefix;
122 }
123
124
125
126
127
128
129 public String getDocumentation() {
130 return documentation;
131 }
132
133
134
135
136
137
138 public void setDocumentation(String documentation) {
139 this.documentation = documentation;
140 }
141
142
143
144
145
146
147 public TemplateMethod getExecuteMethod() {
148 return executeMethod;
149 }
150
151
152
153
154
155
156
157 public Collection<TemplateParameter> getParameters() {
158 Map<String, TemplateParameter> params = new LinkedHashMap<String, TemplateParameter>();
159 fillRegularParameters(params, executeMethod);
160 return params.values();
161 }
162
163
164
165
166
167
168 public boolean hasBody() {
169 return executeMethod.hasBody();
170 }
171
172 @Override
173 public String toString() {
174 return "TemplateClass [name=" + name + ", tagName=" + tagName
175 + ", tagClassPrefix=" + tagClassPrefix + ", documentation="
176 + documentation + ", executeMethod=" + executeMethod + "]";
177 }
178
179
180
181
182
183
184
185 private void fillRegularParameters(Map<String, TemplateParameter> params,
186 TemplateMethod method) {
187 if (method != null) {
188 for (TemplateParameter param : method.getParameters()) {
189 if (!param.isRequest() && !param.isBody()) {
190 params.put(param.getName(), param);
191 }
192 }
193 }
194 }
195 }