br.com.objectos.way.etc.ResourceCopyEval Maven / Gradle / Ivy
The newest version!
/*
* ResourceCopyEval.java criado em 15/12/2013
*
* Propriedade de Objectos Fábrica de Software LTDA.
* Reprodução parcial ou total proibida.
*/
package br.com.objectos.way.etc;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import com.github.mustachejava.Mustache;
import com.google.common.base.Charsets;
import com.google.common.io.ByteSource;
import com.google.common.io.Files;
/**
* @author [email protected] (Marcio Endo)
*/
class ResourceCopyEval extends ResourceCopy {
public ResourceCopyEval(ResourceSet set, Resource resource) {
super(set, resource);
}
@Override
void copy(String resourceName, ByteSource source, File file) throws IOException {
Reader reader = source.asCharSource(Charsets.UTF_8).openStream();
Mustache mustache = set.compileMustache(reader, resourceName);
BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
Object context = set.getContext();
mustache.execute(writer, context).flush();
}
}