1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.exceptions.report.generator;
17
18 import javax.xml.stream.XMLStreamException;
19 import javax.xml.stream.XMLStreamWriter;
20
21 import de.smartics.exceptions.report.data.ExceptionCodeReportItem;
22 import de.smartics.exceptions.report.data.ProjectConfiguration;
23 import de.smartics.exceptions.report.data.StoredExceptionCodesReport;
24 import de.smartics.exceptions.report.renderer.JavadocRenderer;
25 import de.smartics.exceptions.report.utils.CopyReader;
26
27
28
29
30 public abstract class AbstractHtmlReportGenerator extends
31 AbstractXmlReportGenerator
32 {
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 protected AbstractHtmlReportGenerator(final JavadocRenderer renderer)
50 {
51 super(renderer);
52 }
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 @Override
68 protected void writeContent(final XMLStreamWriter xmlWriter,
69 final ProjectConfiguration<XMLStreamWriter> config,
70 final StoredExceptionCodesReport report) throws Exception
71 {
72 xmlWriter.writeStartElement("html");
73 writeHead(xmlWriter, config);
74 xmlWriter.writeStartElement("body");
75
76 xmlWriter.writeStartElement("h1");
77 xmlWriter.writeCharacters(config.getProjectName());
78 xmlWriter.writeEndElement();
79
80 write(xmlWriter, config, report);
81 xmlWriter.writeEndElement();
82 xmlWriter.writeEndElement();
83 }
84
85
86
87
88
89
90
91
92 private void writeHead(final XMLStreamWriter xmlWriter,
93 final ProjectConfiguration<XMLStreamWriter> config)
94 throws XMLStreamException
95 {
96 final String styleSheet = config.getStyleSheet();
97 if (styleSheet != null)
98 {
99 xmlWriter.writeStartElement("head");
100
101 xmlWriter.writeStartElement("title");
102 xmlWriter.writeCharacters(config.getProjectName());
103 xmlWriter.writeEndElement();
104
105 xmlWriter.writeStartElement("link");
106 xmlWriter.writeAttribute("rel", "stylesheet");
107 xmlWriter.writeAttribute("type", "text/css");
108 xmlWriter.writeAttribute("href", styleSheet);
109 xmlWriter.writeEndElement();
110
111 xmlWriter.writeEndElement();
112 }
113 }
114
115
116
117
118 @Override
119 protected void writeInfoHeader(final XMLStreamWriter xmlWriter,
120 final ProjectConfiguration<XMLStreamWriter> config,
121 final String headLine, final ExceptionCodeReportItem item) throws Exception
122 {
123 xmlWriter.writeStartElement("h2");
124 if (headLine != null)
125 {
126 xmlWriter.writeCharacters(headLine);
127 }
128
129 if (headLine != null)
130 {
131 xmlWriter.writeCharacters(": ");
132 }
133 final String className = item.getDeclaringTypeName();
134 xmlWriter.writeCharacters(className);
135 xmlWriter.writeEndElement();
136
137 final String classComment = item.getTypeComment();
138 if (classComment != null)
139 {
140
141 final CopyReader copy = new CopyReader(xmlWriter);
142 xmlWriter.writeStartElement("div");
143 copy.copy(classComment);
144 xmlWriter.writeEndElement();
145 }
146 }
147
148
149
150
151 @Override
152 protected void writeInfoFooter(final XMLStreamWriter xmlWriter,
153 final ProjectConfiguration<XMLStreamWriter> config) throws Exception
154 {
155 xmlWriter.writeEndElement();
156 }
157
158
159
160 }