01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //This file is part of KeY - Integrated Deductive Software Design
09: //Copyright (C) 2001-2003 Universitaet Karlsruhe, Germany
10: // and Chalmers University of Technology, Sweden
11: //
12: //The KeY system is protected by the GNU General Public License.
13: //See LICENSE.TXT for details.
14: //
15:
16: package de.uka.ilkd.key.rule.export.html;
17:
18: import java.io.File;
19: import java.util.Iterator;
20: import java.util.LinkedList;
21: import java.util.List;
22:
23: import de.uka.ilkd.key.rule.export.RuleExportModel;
24:
25: public class HTMLContainer {
26: private String rootFolder;
27:
28: // shown in navigation bar, initialized in first run
29: private List fileList = new LinkedList();
30:
31: public HTMLContainer(String rootFolder) {
32: this .rootFolder = rootFolder;
33: }
34:
35: public String getRootFolder() {
36: return rootFolder;
37: }
38:
39: public void setRootFolder(String rootFolder) {
40: this .rootFolder = rootFolder;
41: }
42:
43: public void addFile(HTMLFile file) {
44: //System.out.println("HTMLContainer.addFile(), "+file.getFilename());
45: fileList.add(file);
46: }
47:
48: public Iterator files() {
49: return fileList.iterator();
50: }
51:
52: public void initAllFiles(RuleExportModel model) {
53: final Iterator it = files();
54: while (it.hasNext()) {
55: HTMLFile file = (HTMLFile) it.next();
56: file.init(model);
57: }
58: }
59:
60: public void writeAllFiles() {
61: File f = new File(getRootFolder());
62: if (!f.exists()) {
63: if (!f.mkdirs()) {
64: System.err
65: .println("Could not create output directory:\n "
66: + getRootFolder());
67: return;
68: }
69: } else {
70: if (!f.isDirectory()) {
71: System.err
72: .println("Output path is not a a directory:\n "
73: + getRootFolder());
74: return;
75: }
76: }
77: final Iterator it = files();
78: while (it.hasNext()) {
79: HTMLFile file = (HTMLFile) it.next();
80: //System.out.println ( "HTMLFile.write(), "+file.getFilename() );
81: file.write();
82: }
83: }
84:
85: }
|