| 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.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 | |
|
| 57 | 0 | |
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | 16 | |
| 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 | |
| 111 | |
|
| 112 | |
|
| 113 | 0 | public static CssHandler getCssHandler() { |
| 114 | 0 | return cssHandler; |
| 115 | |
} |
| 116 | |
|
| 117 | 0 | |
| 118 | 0 | |
| 119 | |
|
| 120 | |
|
| 121 | 0 | public static String getProjectName() { |
| 122 | 0 | return projectName; |
| 123 | |
} |
| 124 | |
|
| 125 | 0 | |
| 126 | 0 | |
| 127 | |
|
| 128 | |
|
| 129 | |
public static String getCheckedOutDirectory() { |
| 130 | 0 | return checkedOutDirectory; |
| 131 | |
} |
| 132 | |
|
| 133 | 0 | |
| 134 | 0 | |
| 135 | |
|
| 136 | |
|
| 137 | |
public static String getLogFileName() { |
| 138 | 0 | return logFileName; |
| 139 | 0 | } |
| 140 | |
|
| 141 | 0 | |
| 142 | 0 | |
| 143 | |
|
| 144 | |
|
| 145 | |
public static String getOutputDir() { |
| 146 | 0 | return outputDir; |
| 147 | |
} |
| 148 | 0 | |
| 149 | 0 | |
| 150 | 0 | |
| 151 | 0 | |
| 152 | 0 | |
| 153 | 0 | |
| 154 | |
public static String getNotes() { |
| 155 | 0 | return notes; |
| 156 | |
} |
| 157 | 0 | |
| 158 | 0 | |
| 159 | 0 | |
| 160 | 0 | |
| 161 | 0 | |
| 162 | 0 | |
| 163 | |
public static WebRepositoryIntegration getWebRepository() { |
| 164 | 0 | return webRepository; |
| 165 | |
} |
| 166 | |
|
| 167 | |
|
| 168 | 0 | |
| 169 | 0 | |
| 170 | 0 | |
| 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 | |
| 182 | 0 | |
| 183 | 0 | |
| 184 | 0 | |
| 185 | 0 | |
| 186 | 0 | |
| 187 | 0 | |
| 188 | 0 | |
| 189 | 0 | |
| 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 | |
| 195 | 0 | |
| 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 | |
| 206 | 0 | |
| 207 | 0 | |
| 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 | |
| 219 | 0 | |
| 220 | 0 | |
| 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 | |
|
| 235 | 0 | |
| 236 | 0 | |
| 237 | 0 | |
| 238 | 0 | |
| 239 | 0 | |
| 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 | |
|
| 259 | 0 | |
| 260 | 0 | |
| 261 | 0 | |
| 262 | |
|
| 263 | |
public static void setViewCvsURL(final String url) { |
| 264 | 0 | ConfigurationOptions.webRepository = new ViewCvsIntegration(url); |
| 265 | 0 | } |
| 266 | |
|
| 267 | |
|
| 268 | |
|
| 269 | 0 | |
| 270 | 0 | |
| 271 | 0 | |
| 272 | 0 | |
| 273 | |
|
| 274 | |
public static void setCvswebURL(final String url) { |
| 275 | 0 | ConfigurationOptions.webRepository = new CvswebIntegration(url); |
| 276 | 0 | } |
| 277 | |
|
| 278 | |
|
| 279 | 0 | |
| 280 | 0 | |
| 281 | 0 | |
| 282 | 0 | |
| 283 | 0 | |
| 284 | |
public static void setChoraURL(final String url) { |
| 285 | 0 | ConfigurationOptions.webRepository = new ChoraIntegration(url); |
| 286 | 0 | } |
| 287 | |
|
| 288 | |
|
| 289 | |
|
| 290 | 0 | |
| 291 | 0 | |
| 292 | 0 | |
| 293 | |
|
| 294 | 0 | public static void setJCVSWebURL(final String url) { |
| 295 | 0 | ConfigurationOptions.webRepository = new JCVSWebIntegration(url); |
| 296 | 0 | } |
| 297 | |
|
| 298 | 0 | |
| 299 | |
|
| 300 | |
|
| 301 | |
|
| 302 | 0 | |
| 303 | 0 | |
| 304 | 0 | |
| 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 | |
| 312 | 0 | |
| 313 | 0 | |
| 314 | 0 | |
| 315 | 0 | |
| 316 | 0 | |
| 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 | |
| 324 | 0 | |
| 325 | 0 | |
| 326 | 0 | public static void setProjectName(final String projectName) { |
| 327 | 0 | ConfigurationOptions.projectName = projectName; |
| 328 | 0 | } |
| 329 | 0 | |
| 330 | 0 | |
| 331 | 0 | |
| 332 | 0 | |
| 333 | 0 | |
| 334 | 0 | public static String getLoggingProperties() { |
| 335 | 0 | return loggingProperties; |
| 336 | |
} |
| 337 | 0 | |
| 338 | 0 | |
| 339 | 0 | |
| 340 | 0 | |
| 341 | 0 | public static void setVerboseLogging() { |
| 342 | 0 | ConfigurationOptions.loggingProperties = LOGGING_CONFIG_VERBOSE; |
| 343 | 0 | } |
| 344 | 0 | |
| 345 | 0 | |
| 346 | 0 | |
| 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 | |
| 372 | 0 | |
| 373 | 0 | |
| 374 | 0 | |
| 375 | 0 | |
| 376 | 0 | |
| 377 | |
public static void setIncludePattern(final String patternList) { |
| 378 | 0 | includePattern = new FilePatternMatcher(patternList); |
| 379 | 0 | } |
| 380 | 0 | |
| 381 | |
|
| 382 | 0 | |
| 383 | 0 | |
| 384 | 0 | |
| 385 | 0 | |
| 386 | 0 | |
| 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 | |
| 394 | 0 | |
| 395 | 0 | public static FilePatternMatcher getExcludePattern() { |
| 396 | 0 | return excludePattern; |
| 397 | 0 | } |
| 398 | 0 | |
| 399 | 0 | |
| 400 | 0 | |
| 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 | |
| 456 | 0 | |
| 457 | |
|
| 458 | 0 | public static void setDefaultCssFile(final String cssName) { |
| 459 | 0 | cssHandler = new DefaultCssHandler(cssName); |
| 460 | 0 | } |
| 461 | 0 | |
| 462 | 0 | |
| 463 | 0 | |
| 464 | 0 | |
| 465 | 0 | |
| 466 | 0 | |
| 467 | 0 | |
| 468 | 0 | public static void addNonDeveloperLogin(final String loginName) { |
| 469 | 0 | nonDeveloperLogins.add(loginName); |
| 470 | 0 | } |
| 471 | |
|
| 472 | 0 | |
| 473 | 0 | |
| 474 | 25 | |
| 475 | 0 | |
| 476 | 0 | public static Collection getNonDeveloperLogins() { |
| 477 | 0 | return nonDeveloperLogins; |
| 478 | |
} |
| 479 | 0 | |
| 480 | 0 | |
| 481 | 0 | |
| 482 | 0 | |
| 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 | |
| 508 | |
|
| 509 | |
|
| 510 | |
public static Properties getConfigProperties() { |
| 511 | 0 | return properties; |
| 512 | |
} |
| 513 | |
|
| 514 | |
|
| 515 | |
|
| 516 | 0 | |
| 517 | 0 | |
| 518 | 0 | |
| 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 | |
| 529 | 0 | |
| 530 | |
|
| 531 | 0 | |
| 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 | |
|
| 554 | |
|
| 555 | |
|
| 556 | |
|
| 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 | |
|
| 574 | |
|
| 575 | |
|
| 576 | |
|
| 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 | |
|
| 594 | 0 | |
| 595 | 0 | |
| 596 | |
|
| 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 | |
| 617 | 0 | |
| 618 | |
|
| 619 | |
|
| 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 | |
| 639 | 0 | |
| 640 | |
|
| 641 | |
|
| 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 | |
| 661 | |
|
| 662 | |
|
| 663 | 0 | |
| 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 | |
| 686 | 0 | |
| 687 | |
|
| 688 | 0 | |
| 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 | |
|
| 711 | |
|
| 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 | |
} |