liquibase.dbdoc.HTMLListWriter Maven / Gradle / Ivy
package liquibase.dbdoc;
import liquibase.configuration.GlobalConfiguration;
import liquibase.configuration.LiquibaseConfiguration;
import liquibase.util.StringUtils;
import java.io.*;
import java.util.SortedSet;
public class HTMLListWriter {
private File outputDir;
private String directory;
private String filename;
private String title;
public HTMLListWriter(String title, String filename, String subdir, File outputDir) {
this.title = title;
this.outputDir = outputDir;
this.filename = filename;
if (!outputDir.exists()) {
outputDir.mkdir();
}
this.directory = subdir;
}
public void writeHTML(SortedSet objects) throws IOException {
Writer fileWriter = new OutputStreamWriter(new FileOutputStream(new File(outputDir, filename)), LiquibaseConfiguration.getInstance().getConfiguration(GlobalConfiguration.class).getOutputEncoding());
try {
fileWriter.append("\n" + "\n" + "\n");
fileWriter.append(title);
fileWriter.append("\n" + " \n" + "\n" + "\n" + "\n" + "\n" + "");
fileWriter.append(title);
fileWriter.append("\n" + "
\n" + "" + "\n" + "");
for (Object object : objects) {
fileWriter.append("");
fileWriter.append(StringUtils.escapeHtml(object.toString()));
fileWriter.append("
\n");
}
fileWriter.append(" \n" +
" \n" +
"
\n" +
"\n" +
"\n" +
"");
} finally {
fileWriter.close();
}
}
public String getTargetExtension() {
return ".html";
}
}