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

File VelocityManager.java

 

Coverage histogram

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

Code metrics

0
2
2
1
82
20
2
1
1
2
1

Classes

Class Line # Actions
VelocityManager 37 2 0% 2 4
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.velocity;
21   
22    import java.io.Reader;
23    import java.io.Writer;
24   
25    import javax.script.ScriptContext;
26   
27    import org.apache.velocity.VelocityContext;
28    import org.xwiki.component.annotation.Role;
29   
30    /**
31    * Provides access to the main XWiki Velocity objects.
32    *
33    * @since 1.5M2
34    * @version $Id: 28deb701e8e553e3ed33925b6462835fc9f61a66 $
35    */
36    @Role
 
37    public interface VelocityManager
38    {
39    /**
40    * @return the up to date current Velocity Context
41    */
42    VelocityContext getVelocityContext();
43   
44    /**
45    * @return the current Velocity Context without any modification
46    * @since 8.3M1
47    */
 
48  0 toggle default VelocityContext getCurrentVelocityContext()
49    {
50  0 return getVelocityContext();
51    }
52   
53    /**
54    * Get the current Velocity Engine or create one if none has been created.
55    *
56    * @return the current Velocity Engine retrieved from the Execution Context
57    * @throws XWikiVelocityException if the Velocity Engine cannot be created
58    */
59    // TODO: Move the engine creation to some initialization method instead and remove the need for throwing an
60    // exception
61    VelocityEngine getVelocityEngine() throws XWikiVelocityException;
62   
63    /**
64    * Renders the input string using the context into the output writer.
65    * <p>
66    * The current {@link ScriptContext} will be used and updated after the execution.
67    * <p>
68    * Anything set in the current {@link VelocityContext} will also be taken into account.
69    *
70    * @param out the writer in which to render the output
71    * @param templateName the string to be used as the template name for log messages in case of error. Also used
72    * internally by Velocity as a cache index key for caching macros.
73    * @param source the input containing the VTL to be rendered, as a Reader
74    * @return false if empty, true otherwise
75    * @throws XWikiVelocityException in case of error
76    * @since 8.3M1
77    */
 
78  0 toggle default boolean evaluate(Writer out, String templateName, Reader source) throws XWikiVelocityException
79    {
80  0 return getVelocityEngine().evaluate(getVelocityContext(), out, templateName, source);
81    }
82    }