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

org.zodiac.template.velocity.impl.VelocityTemplateContextImpl Maven / Gradle / Ivy

The newest version!
package org.zodiac.template.velocity.impl;

import java.util.Map;
import java.util.Set;

import org.apache.velocity.VelocityContext;
import org.zodiac.template.base.support.MappedTemplateContext;
import org.zodiac.template.velocity.VelocityTemplateContext;

public class VelocityTemplateContextImpl implements VelocityTemplateContext {

    private final MappedTemplateContext templateContext;

    public VelocityTemplateContextImpl() {
        this.templateContext = new MappedTemplateContext();
    }

    public VelocityTemplateContextImpl(MappedTemplateContext templateContext) {
        this.templateContext = templateContext;
    }

    public VelocityTemplateContextImpl(Map map) {
        this.templateContext = new MappedTemplateContext(map);
    }

    @Override
    public void put(String key, Object value) {
        templateContext.put(key, value);
    }

    @Override
    public Object get(String key) {
        return templateContext.get(key);
    }

    @Override
    public void remove(String key) {
        templateContext.remove(key);
    }

    @Override
    public boolean containsKey(String key) {
        return templateContext.containsKey(key);
    }

    @Override
    public Set keySet() {
        return templateContext.keySet();
    }

    @Override
    public VelocityContext velocityContext() {
        VelocityContext velocityContext = new VelocityContext(templateContextMap());
        return velocityContext;
    }

    protected Map templateContextMap() {
        return templateContext.getMap();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy