Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
VelocityEngine | 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.velocity; | |
21 | ||
22 | import java.io.Reader; | |
23 | import java.io.Writer; | |
24 | import java.util.Properties; | |
25 | ||
26 | import org.apache.velocity.context.Context; | |
27 | import org.xwiki.component.annotation.Role; | |
28 | ||
29 | /** | |
30 | * Initialize a Velocity Engine and make Velocity services available. | |
31 | * | |
32 | * @version $Id: 6ee2403880f274716824a2d64924e65b94c671fd $ | |
33 | */ | |
34 | @Role | |
35 | public interface VelocityEngine | |
36 | { | |
37 | /** | |
38 | * Initializes the Velocity engine by setting its configuration both from the component's configuration and from the | |
39 | * passed properties. This method must be called before any other method from this class can be executed. | |
40 | * | |
41 | * @param properties the properties that will override the static properties defined in the component's | |
42 | * configuration | |
43 | * @throws XWikiVelocityException in case of error | |
44 | */ | |
45 | void initialize(Properties properties) throws XWikiVelocityException; | |
46 | ||
47 | /** | |
48 | * Renders the input string using the context into the output writer. | |
49 | * | |
50 | * @param context the Velocity context to use in rendering the input string | |
51 | * @param out the writer in which to render the output | |
52 | * @param templateName the string to be used as the template name for log messages in case of error. Also used | |
53 | * internally by Velocity as a cache index key for caching macros. | |
54 | * @param source the input string containing the VTL to be rendered | |
55 | * @return true if successful, false otherwise. If false, see the Velocity runtime log | |
56 | * @throws XWikiVelocityException in case of error | |
57 | */ | |
58 | boolean evaluate(Context context, Writer out, String templateName, String source) throws XWikiVelocityException; | |
59 | ||
60 | /** | |
61 | * Renders the input string using the context into the output writer. | |
62 | * | |
63 | * @param context the Velocity context to use in rendering the input string | |
64 | * @param out the writer in which to render the output | |
65 | * @param templateName the string to be used as the template name for log messages in case of error. Also used | |
66 | * internally by Velocity as a cache index key for caching macros. | |
67 | * @param source the input containing the VTL to be rendered, as a Reader | |
68 | * @return false if empty, true otherwise | |
69 | * @throws XWikiVelocityException in case of error | |
70 | */ | |
71 | boolean evaluate(Context context, Writer out, String templateName, Reader source) throws XWikiVelocityException; | |
72 | ||
73 | /** | |
74 | * Clear the internal Velocity Macro cache for the passed namespace. | |
75 | * | |
76 | * @param templateName the namespace for which to remove all cached Velocity macros | |
77 | * @since 2.4M2 | |
78 | */ | |
79 | void clearMacroNamespace(String templateName); | |
80 | ||
81 | /** | |
82 | * Notify that a rendering action is starting in the given namespace. | |
83 | * | |
84 | * @param namespace the namespace being used | |
85 | * @since 2.4RC1 | |
86 | */ | |
87 | void startedUsingMacroNamespace(String namespace); | |
88 | ||
89 | /** | |
90 | * Notify that a rendering action in the given namespace just finished. | |
91 | * | |
92 | * @param namespace the namespace which was used | |
93 | * @since 2.4RC1 | |
94 | */ | |
95 | void stoppedUsingMacroNamespace(String namespace); | |
96 | } |