001/******************************************************************************* 002 * This software is provided as a supplement to the authors' textbooks on digital 003 * image processing published by Springer-Verlag in various languages and editions. 004 * Permission to use and distribute this software is granted under the BSD 2-Clause 005 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause). 006 * Copyright (c) 2006-2016 Wilhelm Burger, Mark J. Burge. All rights reserved. 007 * Visit http://imagingbook.com for additional details. 008 *******************************************************************************/ 009 010package imagingbook; 011 012import java.util.jar.Attributes; 013import java.util.jar.Manifest; 014 015import imagingbook.lib.util.FileUtils; 016 017public abstract class Info { 018 019 /** 020 * Reads version information from the MANIFEST.MF file of the JAR file from 021 * which this class was loaded. 022 * 023 * @return A string with the version information. 024 * The string "UNKNOWN" is returned if the class was not loaded from a JAR file or if 025 * the version information could not be determined. 026 */ 027 public static String getVersionInfo() { 028 Manifest mf = FileUtils.getJarManifest(Info.class); 029 if (mf == null) { 030 return "UNKNOWN"; 031 } 032 //IJ.log("listing attributes"); 033 Attributes attr = mf.getMainAttributes(); 034 String version = null; 035 String buildDate = null; 036 try { 037 version = attr.getValue("Implementation-Version"); 038 buildDate = attr.getValue("Build-Date"); 039 } catch (IllegalArgumentException e) { } 040 return version + " (" + buildDate + ")"; 041 } 042 043 044 /** 045 * Defined {@literal public} to show in JavaDoc. 046 * Obsolete (reset to {@literal private} again). 047 * @deprecated 048 */ 049 private static final int VERSION = 99999999; 050 051 /** 052 * This method is deprecated, version dates are not maintained any longer. Use 053 * the method {@link getVersionInfo} to retrieve the Maven build version instead. 054 * 055 * @return The current version of the 'imagingbook' library as an 8-digit integer, 056 * eg 20130721 (in YYYYMMDD-format). 057 * @deprecated 058 */ 059 public static int getVersion() { 060 return VERSION; 061 } 062 063 064}