this.epilogFile = epilogFile;
this.printer = null;
}
public void convert(Class clazz) throws java.io.IOException {
Template template = fac.createTemplate(templateFile);
try {
if (printer == null) {
if (!outputFile.exists() || outputFile.lastModified() < templateFile.lastModified() || (prologFile != null && outputFile.lastModified() < prologFile.lastModified()) || (epilogFile != null && outputFile.lastModified() < epilogFile.lastModified())) {
printer = new Printer(outputFile);
if (prologFile != null) {
logger.fine("write prolog " + prologFile);
printer.printFile(prologFile);
}
}
}
if (printer != null) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("shortname", clazz);
String javaClassName = clazz.getName();
int index = javaClassName.lastIndexOf(".");
if (index >= 0) {
javaClassName = javaClassName.substring(index + 1);
}
params.put("shortname", javaClassName);
BeanInfo beanInfo = java.beans.Introspector.getBeanInfo(clazz);
params.put("beanInfo", beanInfo);
logger.fine("writer class " + clazz.getName());
template.print(printer, params);
printer.flush();
}
} catch (IntrospectionException itse) {
IOException e = new IOException("Introspection error: " + itse.getMessage());
e.initCause(itse);