01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /* $Id: Version.java 426576 2006-07-28 15:44:37Z jeremias $ */
19:
20: package org.apache.fop;
21:
22: /**
23: * This class is used to evaluate the version information contained in the Manifest of FOP's JAR.
24: * Note that this class can only find the version information if it's in the org.apache.fop package
25: * as this package equals the one specified in the manifest.
26: */
27: public final class Version {
28:
29: private Version() {
30: }
31:
32: /**
33: * Get the version of FOP
34: * @return the version string
35: */
36: public static String getVersion() {
37: String version = null;
38: Package jarinfo = Version.class.getPackage();
39: if (jarinfo != null) {
40: version = jarinfo.getImplementationVersion();
41: }
42: if (version == null) {
43: //Fallback if FOP is used in a development environment
44: String headURL = "$HeadURL: https://svn.apache.org/repos/asf/xmlgraphics/fop/tags/fop-0_94/src/java/org/apache/fop/Version.java $";
45: version = headURL;
46: final String pathPrefix = "/xmlgraphics/fop/";
47: int pos = version.indexOf(pathPrefix);
48: if (pos >= 0) {
49: version = version.substring(pos + pathPrefix.length()
50: - 1, version.length() - 2);
51: pos = version.indexOf("/src/");
52: version = version.substring(1, pos);
53: version = " " + version;
54: } else {
55: version = "";
56: }
57: version = "SVN" + version;
58: }
59: return version;
60: }
61:
62: }
|