Coverage Report - net.sf.statcvs.output.ConfigurationOptions
 
Classes in this File Line Coverage Branch Coverage Complexity
ConfigurationOptions
7%
38/527
0%
0/314
2.39
 
 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: ConfigurationOptions.java,v $
 21  
         $Date: 2009/08/21 23:06:51 $ 
 22  
 */
 23  
 package net.sf.statcvs.output;
 24  
 
 25  
 import java.awt.Color;
 26  
 import java.io.BufferedReader;
 27  
 import java.io.File;
 28  
 import java.io.FileInputStream;
 29  
 import java.io.FileNotFoundException;
 30  
 import java.io.FileReader;
 31  
 import java.io.IOException;
 32  
 import java.io.InputStream;
 33  
 import java.net.MalformedURLException;
 34  
 import java.net.URL;
 35  
 import java.util.ArrayList;
 36  
 import java.util.Collection;
 37  
 import java.util.List;
 38  
 import java.util.Properties;
 39  
 import java.util.regex.Pattern;
 40  
 import java.util.regex.PatternSyntaxException;
 41  
 
 42  
 import net.sf.statcvs.pages.MarkupSyntax;
 43  
 import net.sf.statcvs.util.FilePatternMatcher;
 44  
 import net.sf.statcvs.util.FileUtils;
 45  
 import net.sf.statcvs.util.StringUtils;
 46  
 import net.sf.statcvs.weblinks.bugs.BugTracker;
 47  
 import net.sf.statcvs.weblinks.bugs.Bugzilla;
 48  
 import net.sf.statcvs.weblinks.bugs.Mantis;
 49  
 
 50  
 import org.jfree.chart.renderer.category.BarRenderer;
 51  
 import org.jfree.chart.renderer.category.StandardBarPainter;
 52  
 import org.jfree.chart.renderer.xy.StandardXYBarPainter;
 53  
 import org.jfree.chart.renderer.xy.XYBarRenderer;
 54  
 
 55  
 /**
 56  
  * Class for storing all command line parameters. The parameters
 57  0
  * are set by the {@link net.sf.statcvs.Main#main} method. Interested classes
 58  
  * can read all parameter values from here.
 59  
  * 
 60  
  * TODO: Should be moved to more appropriate package and made non-public
 61  
  * 
 62  
  * @author jentzsch
 63  16
  * @version $Id: ConfigurationOptions.java,v 1.40 2009/08/21 23:06:51 benoitx Exp $
 64  16
  */
 65  16
 public class ConfigurationOptions {
 66  16
 
 67  16
     private static final String LOGGING_CONFIG_DEFAULT = "logging.properties";
 68  16
     private static final String LOGGING_CONFIG_VERBOSE = "logging-verbose.properties";
 69  32
     private static final String LOGGING_CONFIG_DEBUG = "logging-debug.properties";
 70  16
 
 71  32
     private static String headerUrl = null;
 72  32
     private static String footerUrl = null;
 73  16
     private static String logFileName = null;
 74  32
     private static String checkedOutDirectory = null;
 75  16
     private static String projectName = null;
 76  16
     private static String outputDir = "";
 77  32
     private static String loggingProperties = LOGGING_CONFIG_DEFAULT;
 78  16
     private static String notesFile = null;
 79  0
     private static String notes = null;
 80  32
 
 81  24
     private static FilePatternMatcher includePattern = null;
 82  24
     private static FilePatternMatcher excludePattern = null;
 83  16
 
 84  16
     private static Collection nonDeveloperLogins = new ArrayList();
 85  8
     private static boolean enableTwitterButton = true;
 86  0
 
 87  8
     private static CssHandler cssHandler = new DefaultCssHandler("objectlab-statcvs.css");
 88  16
     private static String charSet = "ISO-8859-1";
 89  16
     private static WebRepositoryIntegration webRepository = null;
 90  8
     private static Pattern symbolicNamesPattern;
 91  0
 
 92  8
     private static BugTracker webBugTracker = BugTracker.NO_BUG_TRACKER;
 93  16
     private static String outputFormat = "html";
 94  16
     private static Properties properties = new Properties();
 95  8
 
 96  
     static {
 97  0
         XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter());
 98  0
         BarRenderer.setDefaultBarPainter(new StandardBarPainter());
 99  0
     }
 100  
 
 101  0
     public static String getCharSet() {
 102  0
         return charSet;
 103  0
     }
 104  
 
 105  0
     public static void setCharSet(final String cs) {
 106  0
         charSet = cs;
 107  0
     }
 108  
 
 109  0
     /**
 110  0
      * returns the {@link CssHandler}
 111  
      * @return the CssHandler
 112  
      */
 113  0
     public static CssHandler getCssHandler() {
 114  0
         return cssHandler;
 115  
     }
 116  
 
 117  0
     /**
 118  0
      * Method getProjectName.
 119  
      * @return String name of the project
 120  
      */
 121  0
     public static String getProjectName() {
 122  0
         return projectName;
 123  
     }
 124  
 
 125  0
     /**
 126  0
      * Method getCheckedOutDirectory.
 127  
      * @return String name of the checked out directory
 128  
      */
 129  
     public static String getCheckedOutDirectory() {
 130  0
         return checkedOutDirectory;
 131  
     }
 132  
 
 133  0
     /**
 134  0
      * Method getLogfilename.
 135  
      * @return String name of the logfile to be parsed
 136  
      */
 137  
     public static String getLogFileName() {
 138  0
         return logFileName;
 139  0
     }
 140  
 
 141  0
     /**
 142  0
      * Returns the outputDir.
 143  
      * @return String output Directory
 144  
      */
 145  
     public static String getOutputDir() {
 146  0
         return outputDir;
 147  
     }
 148  0
 
 149  0
     /**
 150  0
      * Returns the report notes (from "-notes filename" switch) or <tt>null</tt>
 151  0
      * if not specified
 152  0
      * @return the report notes
 153  0
      */
 154  
     public static String getNotes() {
 155  0
         return notes;
 156  
     }
 157  0
 
 158  0
     /**
 159  0
      * Returns a {@link WebRepositoryIntegration} object if the user
 160  0
      * has specified a URL to one. <tt>null</tt> otherwise.
 161  0
      * @return the web repository
 162  0
      */
 163  
     public static WebRepositoryIntegration getWebRepository() {
 164  0
         return webRepository;
 165  
     }
 166  
 
 167  
     /**
 168  0
      * Sets the checkedOutDirectory.
 169  0
      * @param checkedOutDirectory The checkedOutDirectory to set
 170  0
      * @throws ConfigurationException if directory does not exist
 171  0
      */
 172  0
     public static void setCheckedOutDirectory(final String checkedOutDirectory) throws ConfigurationException {
 173  0
         final File directory = new File(checkedOutDirectory);
 174  0
         if (!directory.exists() || !directory.isDirectory()) {
 175  0
             throw new ConfigurationException("directory does not exist: " + checkedOutDirectory);
 176  0
         }
 177  0
         ConfigurationOptions.checkedOutDirectory = checkedOutDirectory;
 178  0
     }
 179  0
 
 180  
     /**
 181  0
      * Sets the cssFile. Currently, the css file can be any local file or
 182  0
      * a HTTP URL. If it is a local file, a copy will be included in the
 183  0
      * output directory. If this method is never called, a default CSS file
 184  0
      * will be generated in the output directory.
 185  0
      *
 186  0
      * @param cssFile The cssFile to set
 187  0
      * @throws ConfigurationException if the specified CSS file can not be
 188  0
      * accessed from local file system or from URL source, or if the specified
 189  0
      * CSS file is local and does not exist
 190  0
      */
 191  0
     public static void setCssFile(final String cssFile) throws ConfigurationException {
 192  0
         try {
 193  0
             final URL url = new URL(cssFile);
 194  0
             //            if (!url.getProtocol().equals("http")) {
 195  0
             //                throw new ConfigurationException("Only HTTP URLs or local files allowed for -css");
 196  0
             //            }
 197  0
             cssHandler = new UrlCssHandler(url);
 198  0
         } catch (final MalformedURLException isLocalFile) {
 199  0
             cssHandler = new LocalFileCssHandler(cssFile);
 200  0
         }
 201  0
         cssHandler.checkForMissingResources();
 202  0
     }
 203  0
 
 204  
     /**
 205  0
      * Sets the logFileName.
 206  0
      * @param logFileName The logFileName to set
 207  0
      * @throws ConfigurationException if the file does not exist
 208  0
      */
 209  0
     public static void setLogFileName(final String logFileName) throws ConfigurationException {
 210  0
         final File inputFile = new File(logFileName);
 211  0
         if (!inputFile.exists()) {
 212  0
             throw new ConfigurationException("Specified logfile not found: " + logFileName);
 213  
         }
 214  0
         ConfigurationOptions.logFileName = logFileName;
 215  0
     }
 216  
 
 217  0
     /**
 218  0
      * Sets the outputDir.
 219  0
      * @param outputDir The outputDir to set
 220  0
      * @throws ConfigurationException if the output directory cannot be created
 221  0
      */
 222  0
     public static void setOutputDir(String outputDir) throws ConfigurationException {
 223  0
         if (!outputDir.endsWith(FileUtils.getDirSeparator())) {
 224  0
             outputDir += FileUtils.getDefaultDirSeparator();
 225  0
         }
 226  0
         final File outDir = new File(outputDir);
 227  0
         if (!outDir.exists() && !outDir.mkdirs()) {
 228  0
             throw new ConfigurationException("Can't create output directory: " + outputDir);
 229  0
         }
 230  0
         ConfigurationOptions.outputDir = outputDir;
 231  0
     }
 232  
 
 233  0
     /**
 234  
      * Sets the name of the notes file. The notes file will be included
 235  0
      * on the index page of the output. It must contain a valid
 236  0
      * block-level HTML fragment (for example
 237  0
      * <tt>"&lt;p&gt;Some notes&lt;/p&gt;"</tt>) 
 238  0
      * @param notesFile a local filename
 239  0
      * @throws ConfigurationException if the file is not found or can't be read
 240  0
      */
 241  0
     public static void setNotesFile(final String notesFile) throws ConfigurationException {
 242  0
         final File f = new File(notesFile);
 243  0
         if (!f.exists()) {
 244  0
             throw new ConfigurationException("Notes file not found: " + notesFile);
 245  0
         }
 246  0
         if (!f.canRead()) {
 247  0
             throw new ConfigurationException("Can't read notes file: " + notesFile);
 248  0
         }
 249  0
         ConfigurationOptions.notesFile = notesFile;
 250  0
         try {
 251  0
             notes = readNotesFile();
 252  0
         } catch (final IOException e) {
 253  0
             throw new ConfigurationException(e.getMessage());
 254  0
         }
 255  0
     }
 256  
 
 257  
     /**
 258  
      * Sets the URL to a <a href="http://viewcvs.sourceforge.net/">ViewCVS</a>
 259  0
      * web-based CVS browser. This must be the URL at which the checked-out
 260  0
      * module's root can be viewed in ViewCVS.
 261  0
      * @param url URL to a ViewCVS repository
 262  
      */
 263  
     public static void setViewCvsURL(final String url) {
 264  0
         ConfigurationOptions.webRepository = new ViewCvsIntegration(url);
 265  0
     }
 266  
 
 267  
     /**
 268  
      * Sets the URL to a 
 269  0
      * <a href="http://www.freebsd.org/projects/cvsweb.html">cvsweb</a>
 270  0
      * web-based CVS browser. This must be the URL at which the checked-out
 271  0
      * module's root can be viewed in cvsweb.
 272  0
      * @param url URL to a cvsweb repository
 273  
      */
 274  
     public static void setCvswebURL(final String url) {
 275  0
         ConfigurationOptions.webRepository = new CvswebIntegration(url);
 276  0
     }
 277  
 
 278  
     /**
 279  0
      * Sets the URL to a <a href="http://www.horde.org/chora/">Chora</a>
 280  0
      * web-based CVS browser. This must be the URL at which the checked-out
 281  0
      * module's root can be viewed in Chora.
 282  0
      * @param url URL to a cvsweb repository
 283  0
      */
 284  
     public static void setChoraURL(final String url) {
 285  0
         ConfigurationOptions.webRepository = new ChoraIntegration(url);
 286  0
     }
 287  
 
 288  
     /**
 289  
      * Sets the URL to a <a href="http://www.jcvs.org/jcvsweb/">JCVSWeb</a>
 290  0
      * web-based CVS browser. This must be the URL at which the checked-out
 291  0
      * module's root can be viewed in JCVSWeb.
 292  0
      * @param url URL to a JCVSWeb repository
 293  
      */
 294  0
     public static void setJCVSWebURL(final String url) {
 295  0
         ConfigurationOptions.webRepository = new JCVSWebIntegration(url);
 296  0
     }
 297  
 
 298  0
     /**
 299  
      * Sets the URL to a <a href="http://www.viewvc.org/">ViewVC</a> web-based CVS/SVN browser. 
 300  
      * This must be the URL at which the checked-out module's
 301  
      * root can be viewed in ViewVC.
 302  0
      * 
 303  0
      * @param url
 304  0
      *            URL to a ViewVC repository
 305  0
      */
 306  0
     public static void setViewVcURL(final String url) {
 307  0
         ConfigurationOptions.webRepository = new ViewVcIntegration(url);
 308  0
     }
 309  
 
 310  0
     /**
 311  0
      * Sets the URL to a <a href="http://trac.edgewall.org/wiki/TracBrowser">Trac</a> web-based SVN browser and issue tracking. 
 312  0
      * This must be the URL at which the checked-out module's
 313  0
      * root can be viewed in Trac 
 314  0
      * 
 315  0
      * @param url
 316  0
      *            URL to a Trac website
 317  0
      */
 318  0
     public static void setViewTracURL(final String url) {
 319  0
         ConfigurationOptions.webRepository = new TracIntegration(url);
 320  0
     }
 321  0
 
 322  0
     /**
 323  0
      * Sets a project title to be used in the reports
 324  0
      * @param projectName The project title to be used in the reports
 325  0
      */
 326  0
     public static void setProjectName(final String projectName) {
 327  0
         ConfigurationOptions.projectName = projectName;
 328  0
     }
 329  0
 
 330  0
     /**
 331  0
      * Gets the name of the logging properties file
 332  0
      * @return the name of the logging properties file
 333  0
      */
 334  0
     public static String getLoggingProperties() {
 335  0
         return loggingProperties;
 336  
     }
 337  0
 
 338  0
     /**
 339  0
      * Sets the logging level to verbose
 340  0
      */
 341  0
     public static void setVerboseLogging() {
 342  0
         ConfigurationOptions.loggingProperties = LOGGING_CONFIG_VERBOSE;
 343  0
     }
 344  0
 
 345  0
     /**
 346  0
      * Sets the logging level to debug
 347  0
      */
 348  0
     public static void setDebugLogging() {
 349  0
         ConfigurationOptions.loggingProperties = LOGGING_CONFIG_DEBUG;
 350  0
     }
 351  0
 
 352  0
     private static String readNotesFile() throws IOException {
 353  0
         BufferedReader r = null;
 354  0
         final StringBuffer result = new StringBuffer();
 355  0
         try {
 356  0
             r = new BufferedReader(new FileReader(notesFile));
 357  0
             String line = r.readLine();
 358  0
             while (line != null) {
 359  0
                 result.append(line);
 360  0
                 line = r.readLine();
 361  
             }
 362  0
         } finally {
 363  0
             if (r != null) {
 364  0
                 r.close();
 365  0
             }
 366  0
         }
 367  0
         return result.toString();
 368  0
     }
 369  
 
 370  
     /**
 371  0
      * Sets a file include pattern list. Only files matching one of the
 372  0
      * patterns will be included in the analysis.
 373  0
      * @param patternList a list of Ant-style wildcard patterns, seperated
 374  0
      *                    by : or ;
 375  0
      * @see net.sf.statcvs.util.FilePatternMatcher
 376  0
      */
 377  
     public static void setIncludePattern(final String patternList) {
 378  0
         includePattern = new FilePatternMatcher(patternList);
 379  0
     }
 380  0
 
 381  
     /**
 382  0
      * Sets a file exclude pattern list. Files matching any of the
 383  0
      * patterns will be excluded from the analysis.
 384  0
      * @param patternList a list of Ant-style wildcard patterns, seperated
 385  0
      *                    by : or ;
 386  0
      * @see net.sf.statcvs.util.FilePatternMatcher
 387  0
      */
 388  0
     public static void setExcludePattern(final String patternList) {
 389  0
         excludePattern = new FilePatternMatcher(patternList);
 390  0
     }
 391  0
 
 392  0
     /**
 393  0
      * @return Returns the excludePattern.
 394  0
      */
 395  0
     public static FilePatternMatcher getExcludePattern() {
 396  0
         return excludePattern;
 397  0
     }
 398  0
 
 399  0
     /**
 400  0
      * @return Returns the includePattern.
 401  2
      */
 402  0
     public static FilePatternMatcher getIncludePattern() {
 403  0
         return includePattern;
 404  0
     }
 405  0
 
 406  0
     public static void setSymbolicNamesPattern(final String symbolicNamesPattern) throws ConfigurationException {
 407  0
         try {
 408  0
             ConfigurationOptions.symbolicNamesPattern = Pattern.compile(symbolicNamesPattern);
 409  0
         } catch (final PatternSyntaxException e) {
 410  0
             throw new ConfigurationException("Invalid regular expression for tags: " + e.getLocalizedMessage());
 411  0
         }
 412  0
     }
 413  6
 
 414  0
     public static Pattern getSymbolicNamesPattern() {
 415  0
         return symbolicNamesPattern;
 416  0
     }
 417  0
 
 418  0
     public static void setBugzillaUrl(final String bugzillaUrl) {
 419  0
         ConfigurationOptions.webBugTracker = new Bugzilla(bugzillaUrl);
 420  0
     }
 421  
 
 422  0
     public static void setMantisUrl(final String mantisUrl) {
 423  0
         ConfigurationOptions.webBugTracker = new Mantis(mantisUrl);
 424  0
     }
 425  0
 
 426  0
     public static BugTracker getWebBugtracker() {
 427  0
         return ConfigurationOptions.webBugTracker;
 428  0
     }
 429  0
 
 430  0
     public static void setOutputFormat(final String outputFormat) throws ConfigurationException {
 431  0
         if (!"html".equals(outputFormat) && !"xdoc".equals(outputFormat) && !"xml".equals(outputFormat)) {
 432  0
             throw new ConfigurationException("Invalid output format, use only 'html', 'xdoc' or 'xml'");
 433  4
         }
 434  4
         ConfigurationOptions.outputFormat = outputFormat;
 435  0
     }
 436  0
 
 437  0
     public static String getOutputFormat() {
 438  0
         return outputFormat;
 439  0
     }
 440  0
 
 441  0
     public static MarkupSyntax getMarkupSyntax() {
 442  0
         if ("xdoc".equals(outputFormat)) {
 443  0
             return ReportConfig.XDOC;
 444  0
         } else if ("xml".equals(outputFormat)) {
 445  0
             return ReportConfig.XML;
 446  0
         }
 447  0
         return ReportConfig.HTML;
 448  0
     }
 449  0
 
 450  
     public static void setWebRepositoryIntegration(final WebRepositoryIntegration webRepo) {
 451  0
         webRepository = webRepo;
 452  0
     }
 453  0
 
 454  0
     /**
 455  0
     * Allow change between css that are shipped with the tool.
 456  0
     * @param cssName statcvs.css or objectlab-statcvs-xdoc.css
 457  
     */
 458  0
     public static void setDefaultCssFile(final String cssName) {
 459  0
         cssHandler = new DefaultCssHandler(cssName);
 460  0
     }
 461  0
 
 462  0
     /**
 463  0
      * Excludes a login name from charts and reports that compare
 464  0
      * several developers. Useful to reduce the noise from admin
 465  0
      * accounts.
 466  0
      * @param loginName A login name
 467  0
      */
 468  0
     public static void addNonDeveloperLogin(final String loginName) {
 469  0
         nonDeveloperLogins.add(loginName);
 470  0
     }
 471  
 
 472  0
     /**
 473  0
      * Gets login names that should be excluded from charts and
 474  25
      * reports that compare several developers.
 475  0
      */
 476  0
     public static Collection getNonDeveloperLogins() {
 477  0
         return nonDeveloperLogins;
 478  
     }
 479  0
 
 480  0
     /**
 481  0
      * Set the config file that may contain user details.
 482  0
      * @param propertiesFilename
 483  0
      */
 484  0
     public static void setConfigFile(final String propertiesFilename) throws ConfigurationException {
 485  0
         if (propertiesFilename != null) {
 486  75
             InputStream is = null;
 487  0
             try {
 488  0
                 is = new FileInputStream(propertiesFilename);
 489  0
                 properties.load(is);
 490  0
             } catch (final FileNotFoundException e) {
 491  0
                 throw new ConfigurationException("Unable to find the configuration file " + propertiesFilename);
 492  0
             } catch (final IOException e) {
 493  0
                 throw new ConfigurationException("Problem reading the configuration file " + propertiesFilename);
 494  0
             } finally {
 495  0
                 if (is != null) {
 496  0
                     try {
 497  0
                         is.close();
 498  0
                     } catch (final IOException e) {
 499  0
                         throw new ConfigurationException("Problem closing stream to the configuration file " + propertiesFilename);
 500  0
                     }
 501  
                 }
 502  0
             }
 503  
         }
 504  0
     }
 505  
 
 506  50
     /**
 507  50
      * The config properties.
 508  
      * @return
 509  
      */
 510  
     public static Properties getConfigProperties() {
 511  0
         return properties;
 512  
     }
 513  
 
 514  
     /**
 515  
      * Return a String prop.
 516  0
      * @param propName
 517  0
      * @param defaultValue
 518  0
      * @return
 519  0
      */
 520  0
     public static String getConfigStringProperty(final String propName, final String defaultValue) {
 521  0
         if (properties != null) {
 522  0
             return properties.getProperty(propName, defaultValue);
 523  0
         }
 524  0
         return defaultValue;
 525  0
     }
 526  0
 
 527  0
     /**
 528  0
      * Return a list of String prop.
 529  0
      * @param propName
 530  
      * @param defaultValue
 531  0
      * @return List (could be empty)
 532  0
      */
 533  
     public static List getConfigStringListProperty(final String propName, final String defaultValue) {
 534  0
         if (properties != null) {
 535  0
             return StringUtils.listify(properties.getProperty(propName, defaultValue), ",");
 536  
         }
 537  0
         return StringUtils.listify(defaultValue, ",");
 538  
     }
 539  
 
 540  
     public static String getConfigStringProperty(final String propName, final String fallBackPropName, final String defaultValue) {
 541  0
         if (properties != null) {
 542  0
             final String val = properties.getProperty(propName);
 543  0
             if (val != null) {
 544  0
                 return val;
 545  0
             } else {
 546  0
                 return properties.getProperty(fallBackPropName, defaultValue);
 547  0
             }
 548  0
         }
 549  0
         return defaultValue;
 550  
     }
 551  0
 
 552  0
     /**
 553  
      * Return a Integer prop.
 554  
      * @param propName
 555  
      * @param defaultValue
 556  
      * @return
 557  
      */
 558  
     public static Integer getConfigIntegerProperty(final String propName, final Integer defaultValue) {
 559  0
         if (properties != null) {
 560  0
             final String val = properties.getProperty(propName);
 561  0
             if (val != null) {
 562  0
                 try {
 563  0
                     return Integer.valueOf(val);
 564  0
                 } catch (final NumberFormatException e) {
 565  0
                     return defaultValue;
 566  0
                 }
 567  0
             }
 568  0
         }
 569  0
         return defaultValue;
 570  
     }
 571  0
 
 572  0
     /**
 573  
      * Return a Float prop.
 574  
      * @param propName
 575  
      * @param defaultValue
 576  
      * @return
 577  
      */
 578  
     public static Float getConfigIntegerProperty(final String propName, final Float defaultValue) {
 579  0
         if (properties != null) {
 580  0
             final String val = properties.getProperty(propName);
 581  0
             if (val != null) {
 582  0
                 try {
 583  0
                     return Float.valueOf(val);
 584  0
                 } catch (final NumberFormatException e) {
 585  0
                     return defaultValue;
 586  0
                 }
 587  0
             }
 588  0
         }
 589  0
         return defaultValue;
 590  0
     }
 591  0
 
 592  0
     /**
 593  
      * Return a String prop.
 594  0
      * @param propName
 595  0
      * @param defaultValue
 596  
      * @return
 597  
      */
 598  
     public static Color getConfigColorProperty(final String propName, final Color defaultValue) {
 599  0
         if (properties != null) {
 600  0
             String val = properties.getProperty(propName);
 601  0
             if (val != null) {
 602  0
                 if (val.startsWith("#")) {
 603  0
                     val = val.substring(1);
 604  0
                 }
 605  0
                 val = val.toLowerCase();
 606  0
                 if (val.length() > 6) {
 607  0
                     return defaultValue;
 608  0
                 }
 609  0
                 return new Color(Integer.parseInt(val, 16));
 610  0
             }
 611  0
         }
 612  0
         return defaultValue;
 613  0
     }
 614  0
 
 615  
     /**
 616  0
      * Return a Integer prop.
 617  0
      * @param propName
 618  
      * @param defaultValue
 619  
      * @return
 620  
      */
 621  
     public static Integer getConfigIntegerProperty(final String propName, final String fallBackPropName, final Integer defaultValue) {
 622  0
         if (properties != null) {
 623  0
             final String val = properties.getProperty(propName);
 624  0
             if (val != null) {
 625  
                 try {
 626  0
                     return Integer.valueOf(val);
 627  0
                 } catch (final NumberFormatException e) {
 628  0
                     return defaultValue;
 629  0
                 }
 630  0
             } else {
 631  0
                 return getConfigIntegerProperty(fallBackPropName, defaultValue);
 632  0
             }
 633  0
         }
 634  0
         return defaultValue;
 635  0
     }
 636  0
 
 637  
     /**
 638  0
      * Return a Float prop.
 639  0
      * @param propName
 640  
      * @param defaultValue
 641  
      * @return
 642  
      */
 643  
     public static Float getConfigFloatProperty(final String propName, final String fallBackPropName, final Float defaultValue) {
 644  0
         if (properties != null) {
 645  0
             final String val = properties.getProperty(propName);
 646  0
             if (val != null) {
 647  
                 try {
 648  0
                     return Float.valueOf(val);
 649  0
                 } catch (final NumberFormatException e) {
 650  0
                     return defaultValue;
 651  0
                 }
 652  0
             } else {
 653  0
                 return getConfigIntegerProperty(fallBackPropName, defaultValue);
 654  0
             }
 655  0
         }
 656  0
         return defaultValue;
 657  0
     }
 658  0
 
 659  0
     /**
 660  0
      * Return a Boolean prop.
 661  
      * @param propName
 662  
      * @param defaultValue
 663  0
      * @return
 664  0
      */
 665  
     public static Boolean getConfigBooleanProperty(final String propName, final String fallBackPropName, final Boolean defaultValue) {
 666  0
         if (properties != null) {
 667  0
             String val = properties.getProperty(propName);
 668  0
             if (val != null) {
 669  
                 try {
 670  0
                     return Boolean.valueOf(val);
 671  0
                 } catch (final NumberFormatException e) {
 672  0
                     return defaultValue;
 673  0
                 }
 674  0
             } else {
 675  0
                 val = properties.getProperty(fallBackPropName);
 676  0
                 if (val != null) {
 677  0
                     return Boolean.valueOf(val);
 678  0
                 }
 679  0
             }
 680  0
         }
 681  0
         return defaultValue;
 682  0
     }
 683  0
 
 684  0
     /**
 685  0
      * Return a Color prop.
 686  0
      * @param propName
 687  
      * @param defaultValue
 688  0
      * @return
 689  0
      */
 690  
     public static Color getConfigColorProperty(final String propName, final String fallBackPropName, final Color defaultValue) {
 691  0
         if (properties != null) {
 692  0
             String val = properties.getProperty(propName);
 693  0
             if (val != null) {
 694  0
                 if (val.startsWith("#")) {
 695  0
                     val = val.substring(1);
 696  
                 }
 697  0
                 val = val.toLowerCase();
 698  0
                 if (val.length() > 6) {
 699  0
                     return defaultValue;
 700  
                 }
 701  0
                 return new Color(Integer.parseInt(val, 16));
 702  
             } else {
 703  0
                 return getConfigColorProperty(fallBackPropName, defaultValue);
 704  
             }
 705  
         }
 706  0
         return defaultValue;
 707  
     }
 708  
 
 709  
     /**
 710  
      * Enable/disable the Twitter "Tweet This" Buttons.
 711  
      * @param value
 712  
      */
 713  
     public static void setEnableTwitterButton(boolean value) {
 714  0
         enableTwitterButton = value;
 715  0
     }
 716  
 
 717  
     public static boolean isEnableTwitterButton() {
 718  0
         return enableTwitterButton;
 719  
     }
 720  
 
 721  
     public static String getHeaderUrl() {
 722  0
         return headerUrl;
 723  
     }
 724  
 
 725  
     public static void setHeaderUrl(String headerUrl) {
 726  0
         ConfigurationOptions.headerUrl = headerUrl;
 727  0
     }
 728  
 
 729  
     public static String getFooterUrl() {
 730  0
         return footerUrl;
 731  
     }
 732  
 
 733  
     public static void setFooterUrl(String footerUrl) {
 734  0
         ConfigurationOptions.footerUrl = footerUrl;
 735  0
     }
 736  
 }