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.generate;
22
23 import java.util.List;
24 import java.util.Map;
25
26 import org.apache.tiles.autotag.core.OutputLocator;
27 import org.apache.tiles.autotag.model.TemplateClass;
28 import org.apache.tiles.autotag.model.TemplateSuite;
29
30
31
32
33
34
35
36 class BasicTemplateGenerator implements TemplateGenerator {
37
38
39
40
41 private List<TSGeneratorDirectoryPair> templateSuiteGenerators;
42
43
44
45
46 private List<TCGeneratorDirectoryPair> templateClassGenerators;
47
48
49
50
51 private boolean generatingResources = false;
52
53
54
55
56 private boolean generatingClasses = false;
57
58
59
60
61
62
63
64
65
66 BasicTemplateGenerator(
67 List<TSGeneratorDirectoryPair> templateSuiteGenerators,
68 List<TCGeneratorDirectoryPair> templateClassGenerators,
69 boolean generatingClasses, boolean generatingResources) {
70 this.templateSuiteGenerators = templateSuiteGenerators;
71 this.templateClassGenerators = templateClassGenerators;
72 this.generatingClasses = generatingClasses;
73 this.generatingResources = generatingResources;
74 }
75
76
77
78 @Override
79 public void generate(String packageName, TemplateSuite suite, Map<String, String> parameters,
80 String runtimeClass, String requestClass) {
81 for (TSGeneratorDirectoryPair pair : templateSuiteGenerators) {
82 pair.getGenerator().generate(pair.getOutputLocator(), packageName, suite, parameters);
83 }
84 for (TemplateClass templateClass : suite.getTemplateClasses()) {
85 for (TCGeneratorDirectoryPair pair : templateClassGenerators) {
86 pair.getGenerator().generate(pair.getOutputLocator(), packageName,
87 suite, templateClass, parameters, runtimeClass, requestClass);
88 }
89 }
90 }
91
92
93
94
95
96
97 static class TSGeneratorDirectoryPair {
98
99
100
101 private OutputLocator outputLocator;
102
103
104
105
106 private TemplateSuiteGenerator generator;
107
108
109
110
111
112
113
114 public TSGeneratorDirectoryPair(OutputLocator outputLocator,
115 TemplateSuiteGenerator generator) {
116 this.outputLocator = outputLocator;
117 this.generator = generator;
118 }
119
120
121
122
123
124
125 public OutputLocator getOutputLocator() {
126 return outputLocator;
127 }
128
129
130
131
132
133
134 public TemplateSuiteGenerator getGenerator() {
135 return generator;
136 }
137 }
138
139
140
141
142
143
144 static class TCGeneratorDirectoryPair {
145
146
147
148 private OutputLocator outputLocator;
149
150
151
152
153 private TemplateClassGenerator generator;
154
155
156
157
158
159
160
161 public TCGeneratorDirectoryPair(OutputLocator outputLocator,
162 TemplateClassGenerator generator) {
163 this.outputLocator = outputLocator;
164 this.generator = generator;
165 }
166
167
168
169
170
171
172 public OutputLocator getOutputLocator() {
173 return outputLocator;
174 }
175
176
177
178
179
180
181 public TemplateClassGenerator getGenerator() {
182 return generator;
183 }
184 }
185
186 @Override
187 public boolean isGeneratingResources() {
188 return generatingResources;
189 }
190
191 @Override
192 public boolean isGeneratingClasses() {
193 return generatingClasses;
194 }
195 }