You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Version.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.shared;
  17. import java.io.Serializable;
  18. public class Version implements Serializable {
  19. /**
  20. * The version number of this release. For example "6.2.0". Always in the
  21. * format "major.minor.revision[.build]". The build part is optional. All of
  22. * major, minor, revision must be integers.
  23. */
  24. private static final String VERSION;
  25. /**
  26. * Major version number. For example 6 in 6.2.0.
  27. */
  28. private static final int VERSION_MAJOR;
  29. /**
  30. * Minor version number. For example 2 in 6.2.0.
  31. */
  32. private static final int VERSION_MINOR;
  33. /**
  34. * Version revision number. For example 0 in 6.2.0.
  35. */
  36. private static final int VERSION_REVISION;
  37. /**
  38. * Build identifier. For example "nightly-20091123-c9963" in
  39. * 6.2.0.nightly-20091123-c9963.
  40. */
  41. private static final String VERSION_BUILD;
  42. /* Initialize version numbers from string replaced by build-script. */
  43. static {
  44. if ("${project.version}".equals("${" + "project.version" + "}")) {
  45. VERSION = "9.9.9.INTERNAL-DEBUG-BUILD";
  46. } else {
  47. VERSION = "${project.version}";
  48. }
  49. final String[] digits = VERSION.split("\\.", 4);
  50. VERSION_MAJOR = Integer.parseInt(digits[0]);
  51. VERSION_MINOR = Integer.parseInt(digits[1]);
  52. VERSION_REVISION = Integer.parseInt(digits[2]);
  53. if (digits.length == 4) {
  54. VERSION_BUILD = digits[3];
  55. } else {
  56. VERSION_BUILD = "";
  57. }
  58. }
  59. public static String getFullVersion() {
  60. return VERSION;
  61. }
  62. public static int getMajorVersion() {
  63. return VERSION_MAJOR;
  64. }
  65. public static int getMinorVersion() {
  66. return VERSION_MINOR;
  67. }
  68. public static int getRevision() {
  69. return VERSION_REVISION;
  70. }
  71. public static String getBuildIdentifier() {
  72. return VERSION_BUILD;
  73. }
  74. }