1 /* 2 StatCvs - CVS statistics generation 3 Copyright (C) 2002 Lukasz Pekacki <lukasz@pekacki.de> 4 http://statcvs.sf.net/ 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License as published by the Free Software Foundation; either 9 version 2.1 of the License, or (at your option) any later version. 10 11 This library is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with this library; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 20 $RCSfile: DefaultCssHandler.java,v $ 21 $Date: 2008/04/02 11:22:15 $ 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 // do nothing 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 }