1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.kernel.velocity;
24  
25  import com.liferay.portal.SystemException;
26  
27  import java.io.IOException;
28  import java.io.Writer;
29  
30  /**
31   * <a href="VelocityEngineUtil.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Raymond Augé
34   *
35   */
36  public class VelocityEngineUtil {
37  
38      public static void flushTemplate(String resource) {
39          getVelocityEngine().flushTemplate(resource);
40      }
41  
42      public static VelocityEngine getVelocityEngine() {
43          return _velocityEngine;
44      }
45  
46      public static void init() {
47          getVelocityEngine().init();
48      }
49  
50      public static VelocityContext getEmptyContext() {
51          return getVelocityEngine().getEmptyContext();
52      }
53  
54      public static VelocityContext getRestrictedToolsContext() {
55          return getVelocityEngine().getRestrictedToolsContext();
56      }
57  
58      public static VelocityContext getStandardToolsContext() {
59          return getVelocityEngine().getStandardToolsContext();
60      }
61  
62      public static VelocityContext getWrappedRestrictedToolsContext() {
63          return getVelocityEngine().getWrappedRestrictedToolsContext();
64      }
65  
66      public static VelocityContext getWrappedStandardToolsContext() {
67          return getVelocityEngine().getWrappedStandardToolsContext();
68      }
69  
70      public static boolean mergeTemplate(
71              String velocityTemplateId, VelocityContext velocityContext,
72              Writer writer)
73          throws SystemException, IOException {
74  
75          return getVelocityEngine().mergeTemplate(
76              velocityTemplateId, velocityContext, writer);
77      }
78  
79      public static boolean mergeTemplate(
80              String velocityTemplateId, String velocityTemplateContent,
81              VelocityContext velocityContext, Writer writer)
82          throws SystemException, IOException {
83  
84          return getVelocityEngine().mergeTemplate(
85              velocityTemplateId, velocityTemplateContent, velocityContext,
86              writer);
87      }
88  
89      public static boolean resourceExists(String resource) {
90          return getVelocityEngine().resourceExists(resource);
91      }
92  
93      public void setVelocityEngine(VelocityEngine velocityEngine) {
94          _velocityEngine = velocityEngine;
95      }
96  
97      private static VelocityEngine _velocityEngine;
98  
99  }