All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.template.base.util.TemplateUtil Maven / Gradle / Ivy

The newest version!
package org.zodiac.template.base.util;

import java.io.IOException;
import java.io.OutputStream;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Map;

import org.zodiac.template.base.TemplateContext;
import org.zodiac.template.base.TemplateEngine;
import org.zodiac.template.base.TemplateException;
import org.zodiac.template.base.support.MappedTemplateContext;

public abstract class TemplateUtil {

    public static String writeToString(TemplateEngine templateEngine, String templateLocation,
        Map model) throws TemplateException, IOException {
        return writeToString(templateEngine, templateLocation, new MappedTemplateContext(model));
    }

    public static String writeToString(TemplateEngine templateEngine, String templateLocation,
        TemplateContext templateContext) throws TemplateException, IOException {
        return writeToString(templateEngine, templateLocation, null, templateContext);
    }

    public static String writeToString(TemplateEngine templateEngine, String templateLocation,
        String encoding, TemplateContext templateContext) throws TemplateException, IOException {
        StringWriter result = new StringWriter();
        writeTo(templateEngine, templateLocation, templateContext, result);
        return result.toString();
    }

    public static void writeTo(TemplateEngine templateEngine, String templateLocation,
        Map model, Writer writer) throws TemplateException, IOException {
        writeTo(templateEngine, templateLocation, new MappedTemplateContext(model), writer);
    }

    public static void writeTo(TemplateEngine templateEngine, String templateLocation,
        TemplateContext templateContext, Writer writer) throws TemplateException, IOException {
        templateEngine.writeTo(templateLocation, templateContext, writer);
    }

    public static void writeTo(TemplateEngine templateEngine, String templateLocation,
        Map model, OutputStream ostream) throws TemplateException, IOException {
        writeTo(templateEngine, templateLocation, new MappedTemplateContext(model), ostream);
    }

    public static void writeTo(TemplateEngine templateEngine, String templateLocation, String encoding,
        Map model, OutputStream ostream) throws TemplateException, IOException {
        writeTo(templateEngine, templateLocation, new MappedTemplateContext(model), ostream);
    }

    public static void writeTo(TemplateEngine templateEngine, String templateLocation,
        TemplateContext templateContext, OutputStream ostream) throws TemplateException, IOException {
        templateEngine.writeTo(templateLocation, templateContext, ostream);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy