01: package liquibase.dbdoc;
02:
03: import java.io.File;
04: import java.io.FileWriter;
05: import java.io.IOException;
06: import java.util.SortedSet;
07:
08: public class HTMLListWriter {
09: private File outputDir;
10: private String directory;
11: private String filename;
12: private String title;
13:
14: public HTMLListWriter(String title, String filename, String subdir,
15: File outputDir) {
16: this .title = title;
17: this .outputDir = outputDir;
18: this .filename = filename;
19: if (!outputDir.exists()) {
20: outputDir.mkdir();
21: }
22: this .directory = subdir;
23: }
24:
25: public void writeHTML(SortedSet objects) throws IOException {
26: FileWriter fileWriter = new FileWriter(new File(outputDir,
27: filename));
28:
29: try {
30: fileWriter.append("<HTML>\n" + "<HEAD>\n" + "<TITLE>\n");
31: fileWriter.append(title);
32: fileWriter
33: .append("\n"
34: + "</TITLE>\n"
35: + "<LINK REL =\"stylesheet\" TYPE=\"text/css\" HREF=\"stylesheet.css\" TITLE=\"Style\">\n"
36: + "</HEAD>\n"
37: + "<BODY BGCOLOR=\"white\">\n"
38: + "<FONT size=\"+1\" CLASS=\"FrameHeadingFont\">\n"
39: + "<B>");
40: fileWriter.append(title);
41: fileWriter
42: .append("</B></FONT>\n"
43: + "<BR>\n"
44: + "<TABLE BORDER=\"0\" WIDTH=\"100%\" SUMMARY=\"\">"
45: + "<TR>\n"
46: + "<TD NOWRAP><FONT CLASS=\"FrameItemFont\">");
47:
48: for (Object object : objects) {
49: fileWriter.append("<A HREF=\"");
50: fileWriter.append(directory);
51: fileWriter.append("/");
52: fileWriter.append(object.toString().toLowerCase());
53: fileWriter.append(getTargetExtension());
54: fileWriter.append("\" target=\"objectFrame\">");
55: fileWriter.append(object.toString());
56: fileWriter.append("</A><BR>\n");
57: }
58:
59: fileWriter.append("</FONT></TD>\n" + "</TR>\n"
60: + "</TABLE>\n" + "\n" + "</BODY>\n" + "</HTML>");
61: } finally {
62: fileWriter.close();
63: }
64: }
65:
66: public String getTargetExtension() {
67: return ".html";
68: }
69: }
|