001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.velocity;
016    
017    import java.io.Writer;
018    
019    /**
020     * @author Raymond Augé
021     */
022    public class VelocityEngineUtil {
023    
024            public static void flushTemplate(String resource) {
025                    getVelocityEngine().flushTemplate(resource);
026            }
027    
028            public static VelocityContext getEmptyContext() {
029                    return getVelocityEngine().getEmptyContext();
030            }
031    
032            public static VelocityContext getRestrictedToolsContext() {
033                    return getVelocityEngine().getRestrictedToolsContext();
034            }
035    
036            public static VelocityContext getStandardToolsContext() {
037                    return getVelocityEngine().getStandardToolsContext();
038            }
039    
040            public static VelocityEngine getVelocityEngine() {
041                    return _velocityEngine;
042            }
043    
044            public static VelocityContext getWrappedRestrictedToolsContext() {
045                    return getVelocityEngine().getWrappedRestrictedToolsContext();
046            }
047    
048            public static VelocityContext getWrappedStandardToolsContext() {
049                    return getVelocityEngine().getWrappedStandardToolsContext();
050            }
051    
052            public static void init() throws Exception {
053                    getVelocityEngine().init();
054            }
055    
056            public static boolean mergeTemplate(
057                            String velocityTemplateId, String velocityTemplateContent,
058                            VelocityContext velocityContext, Writer writer)
059                    throws Exception {
060    
061                    return getVelocityEngine().mergeTemplate(
062                            velocityTemplateId, velocityTemplateContent, velocityContext,
063                            writer);
064            }
065    
066            public static boolean mergeTemplate(
067                            String velocityTemplateId, VelocityContext velocityContext,
068                            Writer writer)
069                    throws Exception {
070    
071                    return getVelocityEngine().mergeTemplate(
072                            velocityTemplateId, velocityContext, writer);
073            }
074    
075            public static boolean resourceExists(String resource) {
076                    return getVelocityEngine().resourceExists(resource);
077            }
078    
079            public void setVelocityEngine(VelocityEngine velocityEngine) {
080                    _velocityEngine = velocityEngine;
081            }
082    
083            private static VelocityEngine _velocityEngine;
084    
085    }