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