Show HTMLIndexReport.java syntax highlighted
/*
* This file is distributed under the GPL v2 as part of teastats site statistics package
* http://teastats.sourceforge.net
*/
package net.time4tea.webstats.report;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.Configuration;
import freemarker.template.SimpleHash;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import net.time4tea.webstats.freemarker.ResourceTemplateLoader;
import net.time4tea.webstats.statistic.StatisticMap;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
/**
* Originally richja Apr 23, 2006
*/
public class HTMLIndexReport {
private List<StatisticMap> statisticMaps = new ArrayList<StatisticMap>();
public void add(StatisticMap statisticMap) {
statisticMaps.add(statisticMap);
}
public void process(Writer writer) throws IOException, TemplateException {
applyTemplate(writer);
}
private void applyTemplate(Writer writer) throws TemplateException, IOException {
SimpleHash modelRoot = new SimpleHash();
BeansWrapper beansWrapper = new BeansWrapper();
TemplateModel templateModel = beansWrapper.wrap(statisticMaps);
modelRoot.put("reports", templateModel);
Configuration configuration = new Configuration();
configuration.setTemplateLoader(new ResourceTemplateLoader(this));
Template template = configuration.getTemplate("index.ftl");
template.process(modelRoot, writer);
}
}
See more files for this project here