package be.nikiroo.fanfix.library; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; import be.nikiroo.utils.IOUtils; import be.nikiroo.utils.streams.ReplaceInputStream; public class Template { private Class location; private String name; private Map values = new HashMap(); private Map valuesTemplate = new HashMap(); private Map> valuesTemplateList = new HashMap>(); public Template(Class location, String name) { this.location = location; this.name = name; } public synchronized InputStream read() throws IOException { String from[] = new String[values.size() + valuesTemplate.size() + valuesTemplateList.size()]; String to[] = new String[from.length]; int i = 0; for (String key : values.keySet()) { from[i] = "${" + key + "}"; to[i] = values.get(key); i++; } for (String key : valuesTemplate.keySet()) { InputStream value = valuesTemplate.get(key).read(); try { from[i] = "${" + key + "}"; to[i] = IOUtils.readSmallStream(value); } finally { value.close(); } i++; } for (String key : valuesTemplateList.keySet()) { List