1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.statcvs.output;
24
25 import java.io.File;
26 import java.io.IOException;
27 import java.util.logging.Logger;
28
29 import net.sf.statcvs.Main;
30 import net.sf.statcvs.pages.ReportSuiteMaker;
31 import net.sf.statcvs.util.FileUtils;
32
33 /**
34 * CSS handler for a CSS file included in the distribution JAR file.
35 *
36 * @author Richard Cyganiak
37 */
38 public class DefaultCssHandler implements CssHandler {
39
40 private static Logger logger = Logger.getLogger("net.sf.statcvs.output.CssHandler");
41
42 private final String filename;
43
44 /**
45 * Creates a new DefaultCssHandler for a CSS file in the
46 * <code>/src/net/sf/statcvs/web-files/</code> folder of the distribution JAR.
47 * This must be a filename only, without a directory.
48 * @param filename Name of the css file
49 */
50 public DefaultCssHandler(final String filename) {
51 this.filename = filename;
52 }
53
54 /**
55 * @see net.sf.statcvs.output.CssHandler#getLink()
56 */
57 public String getLink() {
58 return filename;
59 }
60
61 /**
62 * No external resources are necessary for default CSS files, so
63 * nothing is done here
64 * @see net.sf.statcvs.output.CssHandler#checkForMissingResources()
65 */
66 public void checkForMissingResources() throws ConfigurationException {
67
68 }
69
70 /**
71 * Extracts the CSS file from the distribution JAR and saves it
72 * into the output directory
73 * @see net.sf.statcvs.output.CssHandler#createOutputFiles()
74 */
75 public void createOutputFiles() throws IOException {
76 final String destination = ConfigurationOptions.getOutputDir() + filename;
77 logger.info("Creating CSS file at '" + destination + "'");
78 FileUtils.copyFile(Main.class.getResourceAsStream(ReportSuiteMaker.WEB_FILE_PATH + filename), new File(destination));
79 }
80
81 /**
82 * toString
83 * @return string
84 */
85 public String toString() {
86 return "default CSS file (" + filename + ")";
87 }
88 }