List of usage examples for java.lang Package getImplementationVersion
public String getImplementationVersion()
From source file:org.springsource.sinspctr.BannerUtils.java
public static String getVersion() { final Package pkg = BannerUtils.class.getPackage(); String version = null;/* w ww . j av a 2 s. c om*/ if (pkg != null) { version = pkg.getImplementationVersion(); } return (version != null ? version : "Unknown Version"); }
From source file:org.apache.camel.util.PackageHelper.java
/** * Returns true if the version number of the given package name can be found and is greater than or equal to the minimum version. * * For package names which include multiple dots, the dots are removed. So for example a spring version of 2.5.1 is converted to * 2.51 so you can assert that its >= 2.51 (so above 2.50 and less than 2.52 etc). * * @param packageName the Java package name to compare * @param minimumVersion the minimum version number * @return true if the package name can be determined and if its greater than or equal to the minimum value *///from w ww . j a v a 2s . c o m public static boolean isValidVersion(String packageName, double minimumVersion) { try { Package spring = Package.getPackage(packageName); if (spring != null) { String value = spring.getImplementationVersion(); if (value != null) { // lets remove any extra dots in the string... int idx = value.indexOf('.'); if (idx >= 0) { StringBuilder buffer = new StringBuilder(value.substring(0, ++idx)); int i = idx; for (int size = value.length(); i < size; i++) { char ch = value.charAt(i); if (Character.isDigit(ch)) { buffer.append(ch); } } value = buffer.toString(); } if (ObjectHelper.isNotEmpty(value)) { double number = Double.parseDouble(value); return number >= minimumVersion; } else { LOG.debug("Failed to find out version from package: " + packageName); } } } } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to find out version from package: " + packageName, e); } } return true; }
From source file:org.sourceforge.net.javamail4ews.util.Util.java
public static String getVersion() { Package lPackage = Util.class.getPackage(); return lPackage.getImplementationVersion(); }
From source file:com.callidusrobotics.command.CommandFactory.java
private static boolean isDebugMode() { final Package myPackage = CommandFactory.class.getPackage(); return (myPackage.getImplementationTitle() == null || myPackage.getImplementationVersion() == null); }
From source file:by.stub.utils.StringUtils.java
public static String constructUserAgentName() { final Package pkg = StringUtils.class.getPackage(); final String implementationVersion = StringUtils.isSet(pkg.getImplementationVersion()) ? pkg.getImplementationVersion() : "x.x.xx"; return String.format("stubby4j/%s (HTTP stub client request)", implementationVersion); }
From source file:org.ut.biolab.medsavant.shared.util.VersionSettings.java
public static String getVersionString() { String version = UNDEFINED_VERSION; Package aPackage = VersionSettings.class.getPackage(); if (aPackage != null) { version = aPackage.getImplementationVersion(); if (version == null) { version = aPackage.getSpecificationVersion(); }/* w ww . j a v a2 s. c o m*/ } if (version == null) { version = UNDEFINED_VERSION; } //Allow version to be overridden from command line. return System.getProperty("medsavant.version", version); }
From source file:ubicrypt.UbiCrypt.java
public static String getVersion() { String version = null;/* w ww . j av a 2s.c o m*/ // try to load from maven properties first try { try (final InputStream is = UbiCrypt.class.getResourceAsStream("META-INF/MANIFEST.MF")) { if (is != null) { Manifest manifest = new Manifest(is); version = manifest.getMainAttributes().getValue("Implementation-Version"); } } } catch (final Exception e) { // ignore } // fallback to using Java API if (version == null) { final Package aPackage = UbiCrypt.class.getPackage(); if (aPackage != null) { version = aPackage.getImplementationVersion(); if (version == null) { version = aPackage.getSpecificationVersion(); } } } if (version == null) { // we could not compute the version so use a blank version = ""; } return version; }
From source file:davmail.DavGateway.java
/** * Get current DavMail version.//from w ww . jav a 2s . co m * * @return current version */ public static String getCurrentVersion() { Package davmailPackage = DavGateway.class.getPackage(); String currentVersion = davmailPackage.getImplementationVersion(); if (currentVersion == null) { currentVersion = ""; } return currentVersion; }
From source file:org.dcm4che2.tool.rgb2ybr.Rgb2Ybr.java
private static CommandLine parse(String[] args) { Options opts = new Options(); opts.addOption("p", "partial", false, "convert to YBR_PARTIAL instead to YBR_FULL (=default)"); opts.addOption("i", "invers", false, "convert from YBR_* to RGB"); opts.addOption("h", "help", false, "print this message"); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null;/*from ww w . j av a 2 s. c o m*/ try { cl = new PosixParser().parse(opts, args); } catch (ParseException e) { exit("rgb2ybr: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = Rgb2Ybr.class.getPackage(); System.out.println("rgb2ybr v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption('h') || cl.getArgList().size() != 2) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }
From source file:org.dcm4che2.tool.pdf2dcm.Pdf2Dcm.java
private static CommandLine parse(String[] args) { Options opts = new Options(); OptionBuilder.withArgName("charset"); OptionBuilder.hasArg();/*from w w w . ja va2 s .co m*/ OptionBuilder.withDescription("Specific Character Set, ISO_IR 100 by default"); opts.addOption(OptionBuilder.create("cs")); OptionBuilder.withArgName("size"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Buffer size used for copying PDF to DICOM file, 8192 by default"); opts.addOption(OptionBuilder.create("bs")); OptionBuilder.withArgName("file"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Configuration file specifying DICOM attribute values"); opts.addOption(OptionBuilder.create("c")); opts.addOption("ivrle", false, "use Implicit VR Little Endian instead " + "Explicit VR Little Endian Transfer Syntax for DICOM encoding."); opts.addOption("h", "help", false, "print this message"); OptionBuilder.withArgName("prefix"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Generate UIDs with given prefix," + "1.2.40.0.13.1.<host-ip> by default."); opts.addOption(OptionBuilder.create("uid")); opts.addOption("V", "version", false, "print the version information and exit"); CommandLine cl = null; try { cl = new GnuParser().parse(opts, args); } catch (ParseException e) { exit("pdf2dcm: " + e.getMessage()); throw new RuntimeException("unreachable"); } if (cl.hasOption('V')) { Package p = Pdf2Dcm.class.getPackage(); System.out.println("pdf2dcm v" + p.getImplementationVersion()); System.exit(0); } if (cl.hasOption('h') || cl.getArgList().size() != 2) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE); System.exit(0); } return cl; }