1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.template

File TemplateManager.java

 

Coverage histogram

../../../img/srcFileCovDistChart0.png
86% of files have more coverage

Code metrics

0
1
1
1
239
35
1
1
1
1
1

Classes

Class Line # Actions
TemplateManager 36 1 0% 1 2
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

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.model.reference.DocumentReference;
26    import org.xwiki.rendering.block.XDOM;
27    import org.xwiki.skin.Skin;
28   
29    /**
30    * Internal toolkit to experiment on wiki-based templates.
31    *
32    * @version $Id: 0a9958d25bfecc166b6d36f8baee842ce10c4d9d $
33    * @since 7.0M1
34    */
35    @Role
 
36    public interface TemplateManager
37    {
38    /**
39    * Parse the template with the provided name and return it as {@link XDOM}.
40    * <p>
41    * Any failure is "printed" in the returned {@link XDOM}.
42    *
43    * @param template the template
44    * @return the XDOM source of the template
45    * @since 8.3RC1
46    */
47    XDOM getXDOMNoException(Template template);
48   
49    /**
50    * Parse the template with the provided name and return it as {@link XDOM}.
51    * <p>
52    * Any failure is "printed" in the returned {@link XDOM}.
53    *
54    * @param templateName the name of the template
55    * @return the XDOM source of the template
56    */
57    XDOM getXDOMNoException(String templateName);
58   
59    /**
60    * Parse the template with the provided name and return it as {@link XDOM}.
61    *
62    * @param template the template
63    * @return the XDOM source of the template
64    * @throws Exception when failing to parse the template
65    * @since 8.3RC1
66    */
67    XDOM getXDOM(Template template) throws Exception;
68   
69    /**
70    * Parse the template with the provided name and return it as {@link XDOM}.
71    *
72    * @param templateName the name of the template
73    * @return the XDOM source of the template
74    * @throws Exception when failing to parse the template
75    */
76    XDOM getXDOM(String templateName) throws Exception;
77   
78    /**
79    * Execute and return the template as {@link XDOM}.
80    * <p>
81    * Any failure is "printed" in the returned {@link XDOM}.
82    *
83    * @param template the template
84    * @return the {@link XDOM} result of the template execution
85    * @since 8.3RC1
86    */
87    XDOM executeNoException(Template template);
88   
89    /**
90    * Execute and return the template as {@link XDOM}.
91    * <p>
92    * Any failure is "printed" in the returned {@link XDOM}.
93    *
94    * @param templateName the name of the template
95    * @return the {@link XDOM} result of the template execution
96    */
97    XDOM executeNoException(String templateName);
98   
99    /**
100    * Execute and return the template as {@link XDOM}.
101    *
102    * @param template the template
103    * @return the {@link XDOM} result of the template execution
104    * @throws Exception when failing to parse the template
105    * @since 8.3RC1
106    */
107    XDOM execute(Template template) throws Exception;
108   
109    /**
110    * Execute and return the template as {@link XDOM}.
111    *
112    * @param templateName the name of the template
113    * @return the {@link XDOM} result of the template execution
114    * @throws Exception when failing to parse the template
115    */
116    XDOM execute(String templateName) throws Exception;
117   
118    /**
119    * Execute and render the template in current target syntax.
120    * <p>
121    * Any failure is "printed" in the returned result.
122    *
123    * @param templateName the name of the template
124    * @return the result of the execution of the template in the current target syntax
125    */
126    String renderNoException(String templateName);
127   
128    /**
129    * Execute and render the template in current target syntax.
130    *
131    * @param templateName the name of the template
132    * @return the result of the execution of the template in the current target syntax
133    * @throws Exception when failing to render the template
134    */
135    String render(String templateName) throws Exception;
136   
137    /**
138    * Execute and render the template in current target syntax.
139    *
140    * @param template the template
141    * @param writer the writer containing the result of the execution and rendering
142    * @since 8.3RC1
143    */
144    void renderNoException(Template template, Writer writer);
145   
146    /**
147    * Execute and render the template in current target syntax.
148    *
149    * @param templateName the name of the template
150    * @param writer the writer containing the result of the execution and rendering
151    */
152    void renderNoException(String templateName, Writer writer);
153   
154    /**
155    * Execute and render the template in current target syntax.
156    *
157    * @param template the name of the template
158    * @param writer the writer containing the result of the execution and rendering
159    * @throws Exception when failing to render the template
160    */
161    void render(Template template, Writer writer) throws Exception;
162   
163    /**
164    * Execute and render the template in current target syntax.
165    *
166    * @param templateName the name of the template
167    * @param writer the writer containing the result of the execution and rendering
168    * @throws Exception when failing to render the template
169    */
170    void render(String templateName, Writer writer) throws Exception;
171   
172    /**
173    * Execute and render the template in current target syntax from the passed skin. When the template is not found in
174    * the passed skin it fallback on skin parent etc.
175    *
176    * @param templateName the name of the template
177    * @param skin the skin
178    * @return the result of the execution of the template in the current target syntax
179    * @throws Exception when failing to render the template
180    */
181    String renderFromSkin(String templateName, Skin skin) throws Exception;
182   
183    /**
184    * Execute and render the template in current target syntax from the passed skin. When the template is not found in
185    * the passed skin it fallback on skin parent etc.
186    *
187    * @param templateName the name of the template
188    * @param skin the skin
189    * @param writer the writer containing the result of the execution and rendering
190    * @throws Exception when failing to render the template
191    */
192    void renderFromSkin(String templateName, Skin skin, Writer writer) throws Exception;
193   
194    /**
195    * Search the template with passed name in the passed skin.
196    * <p>
197    * Does not fallback on parent skin.
198    *
199    * @param templateName the name of the template
200    * @param skin the skin
201    * @return the template
202    */
203    Template getSkinTemplate(String templateName, Skin skin);
204   
205    /**
206    * Search the template with passed name in the passed skin.
207    * <p>
208    * Fallback on parent skin.
209    *
210    * @param templateName the name of the template
211    * @param skin the skin
212    * @return the template
213    */
214    Template getTemplate(String templateName, Skin skin);
215   
216    /**
217    * Search everywhere for the template with passed name depending on the current context (current skin, etc).
218    *
219    * @param templateName the name of the template
220    * @return the template
221    */
222    Template getTemplate(String templateName);
223   
224    /**
225    * Create a new template using a given content and a specific author.
226    *
227    * @param content the template content
228    * @param author the template author
229    * @return the template
230    * @throws Exception if an error occurred during template instanciation
231    * @since 9.6RC1
232    */
 
233  0 toggle default Template createStringTemplate(String content, DocumentReference author) throws Exception
234    {
235  0 throw new UnsupportedOperationException(
236    "org.xwiki.template.TemplateManager#createStringTemplate() "
237    + "has been called without being reimplemented.");
238    }
239    }