private boolean matchesVersion(String expectedVersionRangeExpression, Version actualVersion) { if (expectedVersionRangeExpression != null) { try { VersionRange versionRange = new VersionRange(expectedVersionRangeExpression); if (!versionRange.isIncluded(actualVersion)) { return false; } } catch (IllegalArgumentException e) { // ignore } } return true; }
@Override public boolean isIncluded(String version) { return fRange.isIncluded(new Version(version)); }
public Bundle[] getBundles(String symbolicName, String versionRange) { if (symbolicName == null) { throw new IllegalArgumentException(); } AbstractBundle bundles[] = framework.getBundleBySymbolicName(symbolicName); if (bundles == null) return null; if (versionRange == null) { AbstractBundle[] result = new AbstractBundle[bundles.length]; System.arraycopy(bundles, 0, result, 0, result.length); return result; } // This code depends on the array of bundles being in descending // version order. List<AbstractBundle> result = new ArrayList<AbstractBundle>(bundles.length); VersionRange range = new VersionRange(versionRange); for (int i = 0; i < bundles.length; i++) { if (range.isIncluded(bundles[i].getVersion())) { result.add(bundles[i]); } } if (result.size() == 0) return null; return result.toArray(new AbstractBundle[result.size()]); }
public Bundle[] getBundles(String symbolicName, String versionRange) { if (symbolicName == null) { throw new IllegalArgumentException(); } AbstractBundle bundles[] = framework.getBundleBySymbolicName(symbolicName); if (bundles == null) return null; if (versionRange == null) { AbstractBundle[] result = new AbstractBundle[bundles.length]; System.arraycopy(bundles, 0, result, 0, result.length); return result; } // This code depends on the array of bundles being in descending // version order. List<AbstractBundle> result = new ArrayList<AbstractBundle>(bundles.length); VersionRange range = new VersionRange(versionRange); for (int i = 0; i < bundles.length; i++) { if (range.isIncluded(bundles[i].getVersion())) { result.add(bundles[i]); } } if (result.size() == 0) return null; return result.toArray(new AbstractBundle[result.size()]); }
private static ExportPackageDescription findExportPackage(ImportPackageSpecification packageName, ExportPackageDescription[] exports) { List<ExportPackageDescription> matches = new ArrayList<ExportPackageDescription>(2); for (ExportPackageDescription pkg : exports) { if (packageName.getName().equals(pkg.getName()) && packageName.getVersionRange().isIncluded(pkg.getVersion())) { matches.add(pkg); } } int size = matches.size(); if (size == 0) { return null; } else if (size == 1) { return matches.get(0); } else { Collections.sort(matches, ExportPackageComparator.INSTANCE); return matches.get(0); } }
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; }
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; }
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; }
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; }
/** * Check if hostVersion is greater or equal fragmentVersion, or is included in fragment version range * @param hostVersion Version * @param versionOrRange Version or VersionRange * @return true if matches, false otherwise */ private boolean versionMatches(Version hostVersion, String versionOrRange) { if (versionOrRange == null) { return true; } try { Version version = Version.parseVersion(versionOrRange); if (hostVersion.compareTo(version) >= 0) return true; } catch (IllegalArgumentException e) { // wrong formatting, try VersionRange } try { VersionRange range = new VersionRange(versionOrRange); if (range.isIncluded(hostVersion)) return true; } catch (IllegalArgumentException e2) { // wrong range formatting } return false; }
String versionStr = model.getPluginBase().getVersion(); Version version = VersionUtil.validateVersion(versionStr).isOK() ? new Version(versionStr) : Version.emptyVersion; if (range == null || range.isIncluded(version)) { results.add(model);
public boolean isSatisfiedBy(BaseDescription supplier) { if (!(supplier instanceof BundleDescriptionImpl)) return false; BundleDescriptionImpl candidate = (BundleDescriptionImpl) supplier; if (candidate.getHost() != null) return false; Map<String, ?> requiredAttrs = getAttributes(); if (requiredAttrs != null) { Map<String, ?> prividerAttrs = candidate.getAttributes(); if (prividerAttrs == null) return false; for (String key : requiredAttrs.keySet()) { Object requiredValue = requiredAttrs.get(key); Object prividedValue = prividerAttrs.get(key); if (prividedValue == null || !requiredValue.equals(prividedValue)) return false; } } String[] mandatory = (String[]) candidate.getDirective(Constants.MANDATORY_DIRECTIVE); if (!hasMandatoryAttributes(mandatory)) return false; if (getName() != null && getName().equals(candidate.getSymbolicName()) && (getVersionRange() == null || getVersionRange().isIncluded(candidate.getVersion()))) return true; return false; }
public boolean isSatisfiedBy(BaseDescription supplier) { if (!(supplier instanceof BundleDescriptionImpl)) return false; BundleDescriptionImpl candidate = (BundleDescriptionImpl) supplier; if (candidate.getHost() != null) return false; Map<String, ?> requiredAttrs = getAttributes(); if (requiredAttrs != null) { Map<String, ?> prividerAttrs = candidate.getAttributes(); if (prividerAttrs == null) return false; for (String key : requiredAttrs.keySet()) { Object requiredValue = requiredAttrs.get(key); Object prividedValue = prividerAttrs.get(key); if (prividedValue == null || !requiredValue.equals(prividedValue)) return false; } } String[] mandatory = (String[]) candidate.getDirective(Constants.MANDATORY_DIRECTIVE); if (!hasMandatoryAttributes(mandatory)) return false; if (getName() != null && getName().equals(candidate.getSymbolicName()) && (getVersionRange() == null || getVersionRange().isIncluded(candidate.getVersion()))) return true; return false; }
public boolean isSatisfiedBy(BaseDescription supplier) { if (!(supplier instanceof BundleDescriptionImpl)) return false; BundleDescriptionImpl candidate = (BundleDescriptionImpl) supplier; if (candidate.getHost() != null) return false; Map<String, ?> requiredAttrs = getAttributes(); if (requiredAttrs != null) { Map<String, ?> prividerAttrs = candidate.getAttributes(); if (prividerAttrs == null) return false; for (String key : requiredAttrs.keySet()) { Object requiredValue = requiredAttrs.get(key); Object prividedValue = prividerAttrs.get(key); if (prividedValue == null || !requiredValue.equals(prividedValue)) return false; } } String[] mandatory = (String[]) candidate.getDirective(Constants.MANDATORY_DIRECTIVE); if (!hasMandatoryAttributes(mandatory)) return false; if (getName() != null && getName().equals(candidate.getSymbolicName()) && (getVersionRange() == null || getVersionRange().isIncluded(candidate.getVersion()))) return true; return false; }
public boolean isSatisfiedBy(BaseDescription supplier) { if (!(supplier instanceof BundleDescriptionImpl)) return false; BundleDescriptionImpl candidate = (BundleDescriptionImpl) supplier; if (candidate.getHost() != null) return false; Map<String, ?> requiredAttrs = getAttributes(); if (requiredAttrs != null) { Map<String, ?> prividerAttrs = candidate.getAttributes(); if (prividerAttrs == null) return false; for (String key : requiredAttrs.keySet()) { Object requiredValue = requiredAttrs.get(key); Object prividedValue = prividerAttrs.get(key); if (prividedValue == null || !requiredValue.equals(prividedValue)) return false; } } String[] mandatory = (String[]) candidate.getDirective(Constants.MANDATORY_DIRECTIVE); if (!hasMandatoryAttributes(mandatory)) return false; if (getName() != null && getName().equals(candidate.getSymbolicName()) && (getVersionRange() == null || getVersionRange().isIncluded(candidate.getVersion()))) return true; return false; }
public boolean isSatisfiedBy(BaseDescription supplier) { if (!(supplier instanceof BundleDescriptionImpl)) return false; BundleDescriptionImpl candidate = (BundleDescriptionImpl) supplier; if (candidate.getHost() != null) return false; Map<String, ?> requiredAttrs = getAttributes(); if (requiredAttrs != null) { Map<String, ?> prividerAttrs = candidate.getAttributes(); if (prividerAttrs == null) return false; for (String key : requiredAttrs.keySet()) { Object requiredValue = requiredAttrs.get(key); Object prividedValue = prividerAttrs.get(key); if (prividedValue == null || !requiredValue.equals(prividedValue)) return false; } } String[] mandatory = (String[]) candidate.getDirective(Constants.MANDATORY_DIRECTIVE); if (!hasMandatoryAttributes(mandatory)) return false; if (getName() != null && getName().equals(candidate.getSymbolicName()) && (getVersionRange() == null || getVersionRange().isIncluded(candidate.getVersion()))) return true; return false; }
public boolean isSatisfiedBy(BaseDescription supplier) { if (!(supplier instanceof BundleDescriptionImpl)) return false; BundleDescriptionImpl candidate = (BundleDescriptionImpl) supplier; if (candidate.getHost() != null) return false; Map<String, ?> requiredAttrs = getAttributes(); if (requiredAttrs != null) { Map<String, ?> prividerAttrs = candidate.getAttributes(); if (prividerAttrs == null) return false; for (String key : requiredAttrs.keySet()) { Object requiredValue = requiredAttrs.get(key); Object prividedValue = prividerAttrs.get(key); if (prividedValue == null || !requiredValue.equals(prividedValue)) return false; } } String[] mandatory = (String[]) candidate.getDirective(Constants.MANDATORY_DIRECTIVE); if (!hasMandatoryAttributes(mandatory)) return false; if (getName() != null && getName().equals(candidate.getSymbolicName()) && (getVersionRange() == null || getVersionRange().isIncluded(candidate.getVersion()))) return true; return false; }
private static void addImportedPackages(IBundlePluginModelBase base, HashSet<String> existingImports) { HashMap<String, ImportPackageObject> map = getImportPackages(base); if (map == null) { return; } ExportPackageDescription exported[] = PDECore.getDefault().getModelManager().getState().getState().getExportedPackages(); for (int i = 0; i < exported.length; i++) { // iterate through all the exported packages ImportPackageObject ipo = map.get(exported[i].getName()); // if we find an exported package that matches a pkg in the map, then the exported package matches a package on our import-package statement if (ipo != null) { // check version to make sure we only add bundles from valid packages String version = ipo.getVersion(); if (version != null) { try { if (!new VersionRange(version).isIncluded(exported[i].getVersion())) { continue; // NFE if ImportPackageObject's version is improperly formatted - ignore any matching imported packages since version is invalid } } catch (NumberFormatException e) { continue; } } existingImports.add(exported[i].getSupplier().getSymbolicName()); } } }
public static int getMatchRule(VersionRange versionRange) { if (versionRange == null || versionRange.getMinimum() == null) return IMatchRules.NONE; Version minimum = versionRange.getMinimum(); Version maximum = versionRange.getMaximum() == null ? maxVersion : versionRange.getMaximum(); if (maximum.compareTo(maxVersion) >= 0) return IMatchRules.GREATER_OR_EQUAL; else if (minimum.equals(maximum)) return IMatchRules.PERFECT; else if (!versionRange.isIncluded(minimum) || versionRange.isIncluded(maximum)) return IMatchRules.NONE; // no real match rule for this else if (minimum.getMajor() == maximum.getMajor() - 1) return IMatchRules.COMPATIBLE; else if (minimum.getMajor() != maximum.getMajor()) return IMatchRules.NONE; // no real match rule for this else if (minimum.getMinor() == maximum.getMinor() - 1) return IMatchRules.EQUIVALENT; else if (minimum.getMinor() != maximum.getMinor()) return IMatchRules.NONE; // no real match rule for this else if (minimum.getMicro() == maximum.getMicro() - 1) return IMatchRules.PERFECT; // this is as close as we got return IMatchRules.NONE; // no real match rule for this }
public static int getMatchRule(VersionRange versionRange) { if (versionRange == null || versionRange.getMinimum() == null) return IMatchRules.NONE; Version minimum = versionRange.getLeft(); Version maximum = versionRange.getRight() == null ? maxVersion : versionRange.getRight(); if (maximum.compareTo(maxVersion) >= 0) return IMatchRules.GREATER_OR_EQUAL; else if (minimum.equals(maximum)) return IMatchRules.PERFECT; else if (!versionRange.isIncluded(minimum) || versionRange.isIncluded(maximum)) return IMatchRules.NONE; // no real match rule for this else if (minimum.getMajor() == maximum.getMajor() - 1) return IMatchRules.COMPATIBLE; else if (minimum.getMajor() != maximum.getMajor()) return IMatchRules.NONE; // no real match rule for this else if (minimum.getMinor() == maximum.getMinor() - 1) return IMatchRules.EQUIVALENT; else if (minimum.getMinor() != maximum.getMinor()) return IMatchRules.NONE; // no real match rule for this else if (minimum.getMicro() == maximum.getMicro() - 1) return IMatchRules.PERFECT; // this is as close as we got return IMatchRules.NONE; // no real match rule for this }