Gets the package information an @return String
()
| 516 | * @return String |
| 517 | */ |
| 518 | public String getBuildVersion() { |
| 519 | String buildVersion = "x"; |
| 520 | try { |
| 521 | if (getClass().getPackage().getImplementationVersion() != null) { |
| 522 | buildVersion = getClass().getPackage().getImplementationVersion(); |
| 523 | } |
| 524 | } catch (Exception e) { |
| 525 | // oh well |
| 526 | } |
| 527 | InputStream stream = null; |
| 528 | try { |
| 529 | stream = getClass().getClassLoader().getResourceAsStream("build.properties"); |
| 530 | if (stream != null) { |
| 531 | Properties p = new Properties(); |
| 532 | p.load(stream); |
| 533 | final String prop = "BUILD_NUMBER"; |
| 534 | if (p.containsKey(prop) && p.getProperty(prop) != null && |
| 535 | !"x".equalsIgnoreCase(p.getProperty(prop))) { |
| 536 | buildVersion += " (Build: " + p.getProperty(prop) + ")"; |
| 537 | } |
| 538 | } |
| 539 | } catch (IOException e) { |
| 540 | // oh well |
| 541 | } finally { |
| 542 | if (stream != null) { |
| 543 | try { |
| 544 | stream.close(); |
| 545 | } catch (IOException e) { |
| 546 | // oh well |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | return buildVersion; |
| 551 | } |
| 552 | |
| 553 | /** |
| 554 | * This interface is used to go from an interface to its concrete implementation. |