Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
TemplateManager | 35 | 0 | - | 0 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.template; | |
21 | ||
22 | import java.io.Writer; | |
23 | ||
24 | import org.xwiki.component.annotation.Role; | |
25 | import org.xwiki.rendering.block.XDOM; | |
26 | import org.xwiki.skin.Skin; | |
27 | ||
28 | /** | |
29 | * Internal toolkit to experiment on wiki bases templates. | |
30 | * | |
31 | * @version $Id: 8346cf9a68db59ccd9c34034423279f40a8b080e $ | |
32 | * @since 7.0M1 | |
33 | */ | |
34 | @Role | |
35 | public interface TemplateManager | |
36 | { | |
37 | /** | |
38 | * Parse the template with the provided name and return it as {@link XDOM}. | |
39 | * <p> | |
40 | * Any failure is "printed" in the returned {@link XDOM}. | |
41 | * | |
42 | * @param template the template | |
43 | * @return the XDOM source of the template | |
44 | * @since 8.3RC1 | |
45 | */ | |
46 | XDOM getXDOMNoException(Template template); | |
47 | ||
48 | /** | |
49 | * Parse the template with the provided name and return it as {@link XDOM}. | |
50 | * <p> | |
51 | * Any failure is "printed" in the returned {@link XDOM}. | |
52 | * | |
53 | * @param templateName the name of the template | |
54 | * @return the XDOM source of the template | |
55 | */ | |
56 | XDOM getXDOMNoException(String templateName); | |
57 | ||
58 | /** | |
59 | * Parse the template with the provided name and return it as {@link XDOM}. | |
60 | * | |
61 | * @param template the template | |
62 | * @return the XDOM source of the template | |
63 | * @throws Exception when failing to parse the template | |
64 | * @since 8.3RC1 | |
65 | */ | |
66 | XDOM getXDOM(Template template) throws Exception; | |
67 | ||
68 | /** | |
69 | * Parse the template with the provided name and return it as {@link XDOM}. | |
70 | * | |
71 | * @param templateName the name of the template | |
72 | * @return the XDOM source of the template | |
73 | * @throws Exception when failing to parse the template | |
74 | */ | |
75 | XDOM getXDOM(String templateName) throws Exception; | |
76 | ||
77 | /** | |
78 | * Execute and return the template as {@link XDOM}. | |
79 | * <p> | |
80 | * Any failure is "printed" in the returned {@link XDOM}. | |
81 | * | |
82 | * @param template the template | |
83 | * @return the {@link XDOM} result of the template execution | |
84 | * @since 8.3RC1 | |
85 | */ | |
86 | XDOM executeNoException(Template template); | |
87 | ||
88 | /** | |
89 | * Execute and return the template as {@link XDOM}. | |
90 | * <p> | |
91 | * Any failure is "printed" in the returned {@link XDOM}. | |
92 | * | |
93 | * @param templateName the name of the template | |
94 | * @return the {@link XDOM} result of the template execution | |
95 | */ | |
96 | XDOM executeNoException(String templateName); | |
97 | ||
98 | /** | |
99 | * Execute and return the template as {@link XDOM}. | |
100 | * | |
101 | * @param template the template | |
102 | * @return the {@link XDOM} result of the template execution | |
103 | * @throws Exception when failing to parse the template | |
104 | * @since 8.3RC1 | |
105 | */ | |
106 | XDOM execute(Template template) throws Exception; | |
107 | ||
108 | /** | |
109 | * Execute and return the template as {@link XDOM}. | |
110 | * | |
111 | * @param templateName the name of the template | |
112 | * @return the {@link XDOM} result of the template execution | |
113 | * @throws Exception when failing to parse the template | |
114 | */ | |
115 | XDOM execute(String templateName) throws Exception; | |
116 | ||
117 | /** | |
118 | * Execute and render the template in current target syntax. | |
119 | * <p> | |
120 | * Any failure is "printed" in the returned result. | |
121 | * | |
122 | * @param templateName the name of the template | |
123 | * @return the result of the execution of the template in the current target syntax | |
124 | */ | |
125 | String renderNoException(String templateName); | |
126 | ||
127 | /** | |
128 | * Execute and render the template in current target syntax. | |
129 | * | |
130 | * @param templateName the name of the template | |
131 | * @return the result of the execution of the template in the current target syntax | |
132 | * @throws Exception when failing to render the template | |
133 | */ | |
134 | String render(String templateName) throws Exception; | |
135 | ||
136 | /** | |
137 | * Execute and render the template in current target syntax. | |
138 | * | |
139 | * @param template the template | |
140 | * @param writer the writer containing the result of the execution and rendering | |
141 | * @since 8.3RC1 | |
142 | */ | |
143 | void renderNoException(Template template, Writer writer); | |
144 | ||
145 | /** | |
146 | * Execute and render the template in current target syntax. | |
147 | * | |
148 | * @param templateName the name of the template | |
149 | * @param writer the writer containing the result of the execution and rendering | |
150 | */ | |
151 | void renderNoException(String templateName, Writer writer); | |
152 | ||
153 | /** | |
154 | * Execute and render the template in current target syntax. | |
155 | * | |
156 | * @param template the name of the template | |
157 | * @param writer the writer containing the result of the execution and rendering | |
158 | * @throws Exception when failing to render the template | |
159 | */ | |
160 | void render(Template template, Writer writer) throws Exception; | |
161 | ||
162 | /** | |
163 | * Execute and render the template in current target syntax. | |
164 | * | |
165 | * @param templateName the name of the template | |
166 | * @param writer the writer containing the result of the execution and rendering | |
167 | * @throws Exception when failing to render the template | |
168 | */ | |
169 | void render(String templateName, Writer writer) throws Exception; | |
170 | ||
171 | /** | |
172 | * Execute and render the template in current target syntax from the passed skin. When the template is not found in | |
173 | * the passed skin it fallback on skin parent etc. | |
174 | * | |
175 | * @param templateName the name of the template | |
176 | * @param skin the skin | |
177 | * @return the result of the execution of the template in the current target syntax | |
178 | * @throws Exception when failing to render the template | |
179 | */ | |
180 | String renderFromSkin(String templateName, Skin skin) throws Exception; | |
181 | ||
182 | /** | |
183 | * Execute and render the template in current target syntax from the passed skin. When the template is not found in | |
184 | * the passed skin it fallback on skin parent etc. | |
185 | * | |
186 | * @param templateName the name of the template | |
187 | * @param skin the skin | |
188 | * @param writer the writer containing the result of the execution and rendering | |
189 | * @throws Exception when failing to render the template | |
190 | */ | |
191 | void renderFromSkin(String templateName, Skin skin, Writer writer) throws Exception; | |
192 | ||
193 | /** | |
194 | * Search the template with passed name in the passed skin. | |
195 | * <p> | |
196 | * Does not fallback on parent skin. | |
197 | * | |
198 | * @param templateName the name of the template | |
199 | * @param skin the skin | |
200 | * @return the template | |
201 | */ | |
202 | Template getSkinTemplate(String templateName, Skin skin); | |
203 | ||
204 | /** | |
205 | * Search the template with passed name in the passed skin. | |
206 | * <p> | |
207 | * Fallback on parent skin. | |
208 | * | |
209 | * @param templateName the name of the template | |
210 | * @param skin the skin | |
211 | * @return the template | |
212 | */ | |
213 | Template getTemplate(String templateName, Skin skin); | |
214 | ||
215 | /** | |
216 | * Search everywhere for the template with passed name depending on the current context (current skin, etc). | |
217 | * | |
218 | * @param templateName the name of the template | |
219 | * @return the template | |
220 | */ | |
221 | Template getTemplate(String templateName); | |
222 | } |