org.eclipse.equinox.p2.metadata.Version.compareTo()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(76)

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

Version.compareTo介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.equinox.p2/ui

private int compare(Version versionA, Version versionB) {
  if (versionA != null && versionB != null)
    return versionA.compareTo(versionB);
  return 0;
}

代码示例来源:origin: org.eclipse.equinox.p2/metadata

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

代码示例来源:origin: org.eclipse.equinox.p2/metadata

private void validateRange() {
  int cmp = minVersion.compareTo(maxVersion);
  if (!(cmp < 0 || (cmp == 0 && includeMin && includeMax)))
    throw new IllegalArgumentException(NLS.bind(Messages.range_min_0_is_not_less_then_range_max_1, minVersion, maxVersion));
}

代码示例来源:origin: org.eclipse.equinox.p2/metadata

/**
 * Returns whether the given version is included in this VersionRange.
 * This will depend on the minimum and maximum versions of this VersionRange
 * and the given version.
 * 
 * @param version a version to be tested for inclusion in this VersionRange. 
 * (may be <code>null</code>)
 * @return <code>true</code> if the version is include, 
 * <code>false</code> otherwise 
 */
public boolean isIncluded(Version version) {
  if (version == null)
    return false;
  if (minVersion == maxVersion)
    // Can only happen when both includeMin and includeMax are true
    return minVersion.equals(version);
  int minCheck = includeMin ? 0 : -1;
  int maxCheck = includeMax ? 0 : 1;
  return minVersion.compareTo(version) <= minCheck && maxVersion.compareTo(version) >= maxCheck;
}

代码示例来源:origin: com.github.pms1.tppt/tppt-mirror-application

@SafeVarargs
private final boolean diff(String ids, Set<IInstallableUnit>... data) {
  if (ids.length() != data.length)
    throw new IllegalArgumentException();
  Set<IInstallableUnit> all = new TreeSet<>((a, b) -> {
    int diff = a.getId().compareTo(b.getId());
    if (diff != 0)
      return diff;
    return a.getVersion().compareTo(b.getVersion());
  });
  for (Set<IInstallableUnit> d : data)
    all.addAll(d);
  Map<String, Integer> count = new TreeMap<>();
  for (IInstallableUnit iu : all) {
    String out = "";
    for (int i = 0; i != data.length; ++i)
      out += data[i].contains(iu) ? ids.charAt(i) : " ";
    if (out.contains(" "))
      System.out.println(out + " " + iu.getId() + " " + iu.getVersion());
    count.put(out, count.getOrDefault(out, 0) + 1);
  }
  for (Entry<String, Integer> e : count.entrySet())
    System.out.println(e.getKey() + " = " + e.getValue());
  return count.size() != 1;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.engine

@Override
  public int compare(IInstallableUnit iu1, IInstallableUnit iu2) {
    int IdCompare = iu1.getId().compareTo(iu2.getId());
    if (IdCompare != 0)
      return IdCompare;
    return iu1.getVersion().compareTo(iu2.getVersion());
  }
});

代码示例来源:origin: org.eclipse.equinox.p2/metadata

public int compareTo(IInstallableUnit other) {
  int cmp = getId().compareTo(other.getId());
  if (cmp == 0)
    cmp = getVersion().compareTo(other.getVersion());
  return cmp;
}

代码示例来源:origin: org.eclipse.equinox.p2/metadata

public int compareTo(IInstallableUnit other) {
  int cmp = getId().compareTo(other.getId());
  if (cmp == 0)
    cmp = getVersion().compareTo(other.getVersion());
  return cmp;
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.engine

public int compare(IInstallableUnit iu1, IInstallableUnit iu2) {
    int IdCompare = iu1.getId().compareTo(iu2.getId());
    if (IdCompare != 0)
      return IdCompare;
    return iu1.getVersion().compareTo(iu2.getVersion());
  }
});

代码示例来源:origin: ifedorenko/p2-browser

@Override
  public int compare( IInstallableUnit u1, IInstallableUnit u2 )
  {
    if ( u1 != null && u2 != null )
    {
      if ( u1.getId().equalsIgnoreCase( u2.getId() ) )
      {
        return u1.getVersion().compareTo( u2.getVersion() );
      }
      return u1.getId().compareToIgnoreCase( u2.getId() );
    }
    throw new IllegalArgumentException();
  }
}

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.p2.repository

if (version.compareTo(Version.createOSGi(1, 0, 0)) < 0)
  return new LocationProperties();
if (version.compareTo(Version.createOSGi(1, 0, 0)) == 0) {
  if (locationProperties.initVersion1(properties))
    return locationProperties;

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

/**
 * Returns a Collection<IInstallableUnit> of the installable units that contain the samples
 * to be installed.
 */
protected Collection<IInstallableUnit> findSampleIUs(URI location, SubMonitor monitor) throws ProvisionException {
  IMetadataRepository repository = provUI.loadMetadataRepository(location, false, monitor.split(5));
  IQueryResult<IInstallableUnit> allSamples = repository.query(getSampleFeatureQuery(), monitor.split(5));
  if (allSamples.isEmpty()) {
    throw new ProvisionException(NLS.bind(PDEUIMessages.ShowSampleAction_NoSamplesFound, location.toString()));
  }
  IInstallableUnit toInstall = null;
  for (Iterator<IInstallableUnit> iterator = allSamples.iterator(); iterator.hasNext();) {
    IInstallableUnit current = iterator.next();
    if (toInstall == null || toInstall.getVersion().compareTo(current.getVersion()) < 0) {
      toInstall = current;
    }
  }
  Collection<IInstallableUnit> result = new ArrayList<>(1);
  result.add(toInstall);
  return result;
}

代码示例来源:origin: org.eclipse.equinox.p2/repository

if (version.compareTo(Version.createOSGi(1, 0, 0)) < 0)
  return new LocationProperties();
if (version.compareTo(Version.createOSGi(1, 0, 0)) == 0) {
  if (locationProperties.initVersion1(properties))
    return locationProperties;

代码示例来源:origin: org.eclipse.equinox.p2/ui

public static AvailableIUElement[] requestToElement(Remedy remedy, boolean installMode) {
  if (remedy == null)
    return new AvailableIUElement[0];
  ArrayList<AvailableIUElement> temp = new ArrayList<AvailableIUElement>();
  IUElementListRoot root = new IUElementListRoot();
  for (Iterator<RemedyIUDetail> iterator = remedy.getIusDetails().iterator(); iterator.hasNext();) {
    RemedyIUDetail iuDetail = iterator.next();
    if (iuDetail.getStatus() == RemedyIUDetail.STATUS_NOT_ADDED)
      continue;
    AvailableIUElement element = new AvailableIUElement(root, iuDetail.getIu(), ProvisioningUI.getDefaultUI().getProfileId(), true);
    if (iuDetail.getBeingInstalledVersion() != null && iuDetail.getRequestedVersion() != null && iuDetail.getBeingInstalledVersion().compareTo(iuDetail.getRequestedVersion()) < 0 && !installMode)
      element.setImageOverlayId(ProvUIImages.IMG_INFO);
    else if (iuDetail.getStatus() == RemedyIUDetail.STATUS_REMOVED)
      element.setImageId(ProvUIImages.IMG_REMOVED);
    temp.add(element);
  }
  return temp.toArray(new AvailableIUElement[temp.size()]);
}

代码示例来源:origin: org.eclipse.equinox.p2/metadata

public VersionRange intersect(VersionRange r2) {
  int minCompare = minVersion.compareTo(r2.getMinimum());
  int maxCompare = maxVersion.compareTo(r2.getMaximum());
  int minMaxCmp = resultMin.compareTo(resultMax);
  if (minMaxCmp < 0 || (minMaxCmp == 0 && resultMinIncluded && resultMaxIncluded))
    return new VersionRange(resultMin, resultMinIncluded, resultMax, resultMaxIncluded);

代码示例来源:origin: org.eclipse.tycho/org.eclipse.tycho.p2.resolver.impl

} else if (swtHost.getVersion().compareTo(Version.createOSGi(3, 104, 0)) >= 0) {
    for (IProvidedCapability provided : iu.getProvidedCapabilities()) {
      if ("osgi.fragment".equals(provided.getNamespace()) && "org.eclipse.swt".equals(provided.getName())) {
        if (swtFragment == null || swtFragment.getVersion().compareTo(iu.getVersion()) < 0) {
          swtFragment = iu;

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

@Override
  public int compare(Object o1, Object o2) {
    BundleInfo b1 = ((TargetBundle) o1).getBundleInfo();
    BundleInfo b2 = ((TargetBundle) o2).getBundleInfo();
    try {
      Version v1 = Version.create(b1.getVersion());
      Version v2 = Version.create(b2.getVersion());
      return v1.compareTo(v2);
    } catch (IllegalArgumentException e) {
      // If one of the bundles has a bad version
      PDECore.log(e);
      return b1.getVersion().compareTo(b2.getVersion());
    }
  }
});

代码示例来源:origin: org.eclipse.equinox.p2.ui.sdk/scheduler

public String getIUNameWithDetail(IInstallableUnit iu) {
  IQueryResult<IInstallableUnit> results = profile.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), null);
  String text = iu.getProperty(IProfile.PROP_NAME, null);
  text = (text != null) ? text : iu.getId();
  if (!results.isEmpty()) {
    boolean hasHigherVersion = false;
    boolean hasEqualVersion = false;
    for (IInstallableUnit installedIU : results.toSet()) {
      int compareValue = installedIU.getVersion().compareTo(iu.getVersion());
      if (compareValue > 0) {
        hasHigherVersion = true;
        break;
      } else if (compareValue == 0)
        hasEqualVersion = true;
    }
    if (hasHigherVersion)
      return NLS.bind(ProvUIMessages.AbstractImportPage_HigherVersionInstalled, text);
    else if (hasEqualVersion)
      return NLS.bind(ProvUIMessages.AbstractImportPage_SameVersionInstalled, text);
  }
  return text;
}

代码示例来源:origin: org.eclipse.equinox.p2/ui

/**
 * Compute information about this IU. This computes whether or
 * not this IU is installed and / or updated.
 */
private InformationCache computeIUInformation(IInstallableUnit iu) {
  boolean isUpdate = false;
  boolean isInstalled = false;
  boolean isPatch = iu == null ? false : QueryUtil.isPatch(iu);
  if (profile != null && iu != null) {
    isInstalled = !profile.query(QueryUtil.createIUQuery(iu), null).isEmpty();
    Iterator<IInstallableUnit> iter = profile.query(new UserVisibleRootQuery(), null).iterator();
    while (iter.hasNext()) {
      IInstallableUnit installed = iter.next();
      if (iu.getUpdateDescriptor() != null && iu.getUpdateDescriptor().isUpdateOf(installed) && (!iu.getId().equals(installed.getId()) || installed.getVersion().compareTo(iu.getVersion()) < 0)) {
        isUpdate = true;
        break;
      }
    }
  }
  return new InformationCache(iu, isUpdate, isInstalled, isPatch);
}

代码示例来源:origin: org.eclipse.equinox.p2/ui

if (result == 0) {
  result = iu2.getVersion().compareTo(iu1.getVersion());

相关文章