Java Code Examples for org.osgi.framework.Version#getMicro()

The following examples show how to use org.osgi.framework.Version#getMicro() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BundleManifestTask.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * If we have a bundle version suffix add it to the 
 * <code>Bundle-Version</code> attribute.
 */
private void appendVersionSuffix(Manifest mf)
{
  if (versionSuffix != null && !versionSuffix.equals("")) {
    final Manifest.Attribute bundleVerAttr
      = mf.getMainSection().getAttribute("Bundle-Version");
    if (null!=bundleVerAttr) {
      final Version ver = new Version(bundleVerAttr.getValue());
      String q = ver.getQualifier();
      int major = ver.getMajor();
      int minor = ver.getMinor();
      int micro = ver.getMicro();
      if (q.length() == 0) {
        bundleVerAttr.setValue(new Version(major, minor, micro, versionSuffix).toString());
      } else if (!q.endsWith(versionSuffix)) {
        bundleVerAttr.setValue(new Version(major, minor, micro, q + "-" + versionSuffix).toString());
      }
    }
  }
}
 
Example 2
Source File: BundleLocator.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Get the set of version patterns (partial versions) used in the
 * keys in replacement filters for the given version.
 * @param version The version to create patterns for.
 * @return Set of version patterns.
 */
private static String[] getVersionPatterns(Version version)
{
  if (null==version) {
    return new String[]{"-N.N.N"};
  }

  final String qualifier = version.getQualifier();
  final boolean usesQualifier = null != qualifier && qualifier.length() > 0;
  final String[] res = new String[usesQualifier ? 5 : 4];

  res[0] = "-N.N.N";
  res[1] = "-" +version.getMajor() +".N.N";
  res[2] = "-" +version.getMajor() +"." +version.getMinor() +".N";
  res[3] = "-" +version.getMajor() +"." +version.getMinor()
    +"." +version.getMicro();
  if (usesQualifier) {
    res[4] = "-" +version.getMajor() +"." +version.getMinor()
      +"." +version.getMicro() +"." +version.getQualifier();
  }

  return res;
}
 
Example 3
Source File: Utilities.java    From sarl with Apache License 2.0 6 votes vote down vote up
private static int compareVersionsNoQualifier(Version firstVersion, Version secondVersion) {
	if (firstVersion == secondVersion) {
		return 0;
	}

	int result = firstVersion.getMajor() - secondVersion.getMajor();
	if (result != 0) {
		return result;
	}

	result = firstVersion.getMinor() - secondVersion.getMinor();
	if (result != 0) {
		return result;
	}

	return firstVersion.getMicro() - secondVersion.getMicro();
}
 
Example 4
Source File: M2EUtilities.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Compute the theoretic version just before the given one.
 *
 * @param vers the version.
 * @return the previous version.
 * @since 0.10
 */
@SuppressWarnings("checkstyle:magicnumber")
public static Version getPreviousOsgiVersion(Version vers) {
	int major = vers.getMajor();
	int minor = vers.getMinor();
	int micro = vers.getMicro();
	if (micro <= 0) {
		micro = MAX_NUMBER;
		--minor;
	}
	if (minor <= 0) {
		micro = MAX_NUMBER;
		minor = MAX_NUMBER;
		--major;
	}
	return new Version(major, minor, micro);
}
 
Example 5
Source File: TestAssertions.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Assert if the two OSGI version are equal.
 *
 * @param expected the expected value.
 * @param actual the actual value.
 */
public static void assertOsgiVersionEquals(Version expected, Version actual) {
	if (Objects.equal(expected, actual)) {
		return;
	}
	if (expected == null) {
		fail("Version not null");
	}
	if (actual == null) {
		fail("Unexpected null value");
	}
	if (expected.getMajor() == actual.getMajor()
			&& expected.getMinor() == actual.getMinor()
			&& expected.getMicro() == actual.getMicro()) {
		if (!Strings.isNullOrEmpty(expected.getQualifier())) {
			final String expectedQualifier = expected.getQualifier();
			if ("qualifier".equals(expectedQualifier)) {
				if (!Strings.isNullOrEmpty(actual.getQualifier())) {
					return;
				}
			}
			if (Objects.equal(expected, actual.getQualifier())) {
				return;
			}
		} else {
			return;
		}
	}
	throw new AssertionFailedError("Not same versions", expected.toString(), actual.toString());
}
 
Example 6
Source File: OSGiMainLookup.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public @Override SpecificationVersion getSpecificationVersion() {
    Version v = b.getVersion();
    return new SpecificationVersion(v.getMajor() % 100 + "." + v.getMinor() + "." + v.getMicro());
}
 
Example 7
Source File: ReleaseNotes.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected String getCurrentVersion() {
	Version currentVersion = Activator.getDefault().getBundle().getVersion();
	return "" + currentVersion.getMajor() + "." + currentVersion.getMinor() + "." + currentVersion.getMicro();
}
 
Example 8
Source File: GoPreferencePage.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
protected static String getVersionText() {
	Version version = GoCorePlugin.getDefault().getBundle().getVersion();
	
	return version.getMajor() + "." + version.getMinor() + "." + version.getMicro();
}