1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.velocity;
16  
17  import java.io.Writer;
18  
19  /**
20   * <a href="VelocityEngineUtil.java.html"><b><i>View Source</i></b></a>
21   *
22   * @author Raymond Augé
23   */
24  public class VelocityEngineUtil {
25  
26      public static void flushTemplate(String resource) {
27          getVelocityEngine().flushTemplate(resource);
28      }
29  
30      public static VelocityContext getEmptyContext() {
31          return getVelocityEngine().getEmptyContext();
32      }
33  
34      public static VelocityContext getRestrictedToolsContext() {
35          return getVelocityEngine().getRestrictedToolsContext();
36      }
37  
38      public static VelocityContext getStandardToolsContext() {
39          return getVelocityEngine().getStandardToolsContext();
40      }
41  
42      public static VelocityEngine getVelocityEngine() {
43          return _velocityEngine;
44      }
45  
46      public static VelocityContext getWrappedRestrictedToolsContext() {
47          return getVelocityEngine().getWrappedRestrictedToolsContext();
48      }
49  
50      public static VelocityContext getWrappedStandardToolsContext() {
51          return getVelocityEngine().getWrappedStandardToolsContext();
52      }
53  
54      public static void init() throws Exception {
55          getVelocityEngine().init();
56      }
57  
58      public static boolean mergeTemplate(
59              String velocityTemplateId, String velocityTemplateContent,
60              VelocityContext velocityContext, Writer writer)
61          throws Exception {
62  
63          return getVelocityEngine().mergeTemplate(
64              velocityTemplateId, velocityTemplateContent, velocityContext,
65              writer);
66      }
67  
68      public static boolean mergeTemplate(
69              String velocityTemplateId, VelocityContext velocityContext,
70              Writer writer)
71          throws Exception {
72  
73          return getVelocityEngine().mergeTemplate(
74              velocityTemplateId, velocityContext, writer);
75      }
76  
77      public static boolean resourceExists(String resource) {
78          return getVelocityEngine().resourceExists(resource);
79      }
80  
81      public void setVelocityEngine(VelocityEngine velocityEngine) {
82          _velocityEngine = velocityEngine;
83      }
84  
85      private static VelocityEngine _velocityEngine;
86  
87  }