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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright 2005 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of 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,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop;
  18. /**
  19. * This class is used to evaluate the version information contained in the Manifest of FOP's JAR.
  20. * Note that this class can only find the version information if it's in the org.apache.fop package
  21. * as this package equals the one specified in the manifest.
  22. */
  23. public final class Version {
  24. private Version() { }
  25. /**
  26. * Get the version of FOP
  27. * @return the version string
  28. */
  29. public static String getVersion() {
  30. String version = null;
  31. Package jarinfo = Version.class.getPackage();
  32. if (jarinfo != null) {
  33. version = jarinfo.getImplementationVersion();
  34. }
  35. if (version == null) {
  36. //Fallback if FOP is used in a development environment
  37. String headURL
  38. = "$HeadURL$";
  39. version = headURL;
  40. final String pathPrefix = "/xmlgraphics/fop/";
  41. int pos = version.indexOf(pathPrefix);
  42. if (pos >= 0) {
  43. version = version.substring(pos + pathPrefix.length() - 1, version.length() - 2);
  44. pos = version.indexOf("/src/");
  45. version = version.substring(1, pos);
  46. version = " " + version;
  47. } else {
  48. version = "";
  49. }
  50. version = "SVN" + version;
  51. }
  52. return version;
  53. }
  54. }