org.osgi.framework.Version.compareTo()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.osgi.framework.Version.compareTo()方法的一些代码示例,展示了Version.compareTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.compareTo()方法的具体详情如下:
包路径:org.osgi.framework.Version
类名称:Version
方法名:compareTo

Version.compareTo介绍

[英]Compares this Version object to another object.

A version is considered to be less than another version if its major component is less than the other version's major component, or the major components are equal and its minor component is less than the other version's minor component, or the major and minor components are equal and its micro component is less than the other version's micro component, or the major, minor and micro components are equal and it's qualifier component is less than the other version's qualifier component (using String.compareTo).

A version is considered to be equal to another version if the major, minor and micro components are equal and the qualifier component is equal (using String.compareTo).
[中]将此Version对象与另一个对象进行比较。
如果一个版本的主要组件小于另一个版本的主要组件,或者主要组件相等且次要组件小于另一个版本的次要组件,则认为该版本小于另一个版本,或者主组件和次组件相等,其微组件小于另一版本的微组件,或者主组件、次组件和微组件相等,其限定组件小于另一版本的限定组件(使用String.compareTo)。
如果主要、次要和微观成分相等,且限定成分相等(使用[$2$]),则一个版本被视为等同于另一个版本。

代码示例

代码示例来源:origin: org.osgi/org.osgi.core

/**
 * Internal isEmpty behavior.
 * 
 * @return {@code true} if this version range is empty; {@code false}
 *         otherwise.
 */
private boolean isEmpty0() {
  if (right == null) { // infinity
    return false;
  }
  int comparison = left.compareTo(right);
  if (comparison == 0) { // endpoints equal
    return !leftClosed || !rightClosed;
  }
  return comparison > 0; // true if left > right
}

代码示例来源:origin: org.osgi/org.osgi.core

/**
 * Returns whether this version range includes the specified version.
 * 
 * @param version The version to test for inclusion in this version range.
 * @return {@code true} if the specified version is included in this version
 *         range; {@code false} otherwise.
 */
public boolean includes(Version version) {
  if (empty) {
    return false;
  }
  if (left.compareTo(version) >= (leftClosed ? 1 : 0)) {
    return false;
  }
  if (right == null) {
    return true;
  }
  return right.compareTo(version) >= (rightClosed ? 0 : 1);
}

代码示例来源:origin: org.osgi/org.osgi.core

int comparison = endpointLeft.compareTo(range.left);
if (comparison == 0) {
  closedLeft = closedLeft && range.leftClosed;
    closedRight = range.rightClosed;
  } else {
    comparison = endpointRight.compareTo(range.right);
    if (comparison == 0) {
      closedRight = closedRight && range.rightClosed;

代码示例来源:origin: org.osgi/org.osgi.core

return adjacent1.compareTo(right) >= 0;
return adjacent2.compareTo(right) >= 0;

代码示例来源:origin: org.apache.felix/org.osgi.compendium

.compareTo(endMatchVersion) >= 0);
this.listenerFilter = endMatchSupported ? filter.toString() : null;
this.filter = filter;

代码示例来源:origin: com.atlassian.jira/jira-core

private static VersionAndFile useNewestVersion(final VersionAndFile left, final VersionAndFile right)
{
  return left.version.compareTo(right.version) < 0 ?
      right :
      left;
}

代码示例来源:origin: protegeproject/protege

@Override
public int compareTo(Object o) {
  if (o instanceof VersionComponent) {
    return this.version.compareTo(((VersionComponent) o).version);
  }
  else {
    return 1;
  }
}

代码示例来源:origin: io.fabric8.patch/patch-management

@Override
  public int compare(Version o1, Version o2) {
    return o2.compareTo(o1);
  }
});

代码示例来源:origin: org.eclipse/osgi

@Override
  public int compare(Bundle b1, Bundle b2) {
    return b2.getVersion().compareTo(b1.getVersion());
  }
});

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.osgi

@Override
  public int compare(Bundle b1, Bundle b2) {
    return b2.getVersion().compareTo(b1.getVersion());
  }
});

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.osgi

@Override
  public int compare(Bundle b1, Bundle b2) {
    return b2.getVersion().compareTo(b1.getVersion());
  }
});

代码示例来源:origin: org.eclipse/org.eclipse.osgi

@SuppressWarnings("deprecation")
private void generateProvidePackage() {
  Set<String> exports = getExports();
  if (exports != null && exports.size() != 0) {
    generatedManifest.put(TARGET31.compareTo(target) <= 0 ? Constants.EXPORT_PACKAGE : Constants.PROVIDE_PACKAGE, getStringFromCollection(exports, LIST_SEPARATOR));
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.osgi

private String getSymbolicNameEntry() {
  // false is the default, so don't bother adding anything 
  if (!pluginInfo.isSingleton())
    return pluginInfo.getUniqueId();
  StringBuffer result = new StringBuffer(pluginInfo.getUniqueId());
  result.append(SEMICOLON);
  result.append(Constants.SINGLETON_DIRECTIVE);
  String assignment = TARGET31.compareTo(target) <= 0 ? ":=" : "="; //$NON-NLS-1$ //$NON-NLS-2$
  result.append(assignment).append("true"); //$NON-NLS-1$
  return result.toString();
}

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.osgi

@SuppressWarnings("deprecation")
private void generateProvidePackage() {
  Set<String> exports = getExports();
  if (exports != null && exports.size() != 0) {
    generatedManifest.put(TARGET31.compareTo(target) <= 0 ? Constants.EXPORT_PACKAGE : Constants.PROVIDE_PACKAGE, getStringFromCollection(exports, LIST_SEPARATOR));
  }
}

代码示例来源:origin: apache/karaf

private int compareVersions(Capability cap1, Capability cap2, String attribute) {
  Version v1 = (!cap1.getAttributes().containsKey(attribute))
      ? Version.emptyVersion
      : (Version) cap1.getAttributes().get(attribute);
  Version v2 = (!cap2.getAttributes().containsKey(attribute))
      ? Version.emptyVersion
      : (Version) cap2.getAttributes().get(attribute);
  // Compare these in reverse order, since we want
  // highest version to have priority.
  return v2.compareTo(v1);
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.osgi

@Override
  public int compare(ModuleRevision r1, ModuleRevision r2) {
    // we only care about versions here
    return -(r1.getVersion().compareTo(r2.getVersion()));
  }
});

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi

@Override
  public int compare(ModuleRevision r1, ModuleRevision r2) {
    // we only care about versions here
    return -(r1.getVersion().compareTo(r2.getVersion()));
  }
});

代码示例来源:origin: stackoverflow.com

private Boolean processPluginUpgrading() {
  final Version version = getDefault().getBundle().getVersion();
  final IPreferenceStore preferenceStore = getDefault().getPreferenceStore();
  final String preferenceName = "lastVersionActivated";
  final String lastVersionActivated = preferenceStore.getString(preferenceName);
  final boolean upgraded = 
      "".equals(lastVersionActivated)
      || (version.compareTo(new Version(lastVersionActivated)) > 0);
  preferenceStore.setValue(preferenceName, version.toString());
  return upgraded;
}

代码示例来源:origin: org.eclipse/org.eclipse.osgi

private Version getHighestVersionMatch(Version version, VersionRange[] ranges) {
  Version highest = Version.emptyVersion;
  for (int i = 0; i < ranges.length; i++) {
    if (ranges[i].isIncluded(version) && highest.compareTo(ranges[i].getMinimum()) < 0)
      highest = ranges[i].getMinimum();
  }
  return highest;
}

代码示例来源:origin: org.apache.servicemix.kernel/org.apache.servicemix.kernel.main

public int compare(Object o1, Object o2)
  {
    Version v1 = ((BundleImpl) o1).getCurrentModule().getVersion();
    Version v2 = ((BundleImpl) o2).getCurrentModule().getVersion();
    // Compare in reverse order to get descending sort.
    return v2.compareTo(v1);
  }
});

相关文章