private Map<String, ActionEntry> parseImportAttribute(String importAttribute) { if (importAttribute == null) return Collections.emptyMap(); Map<String, ActionEntry> result = new HashMap<>(); StringTokenizer tokenizer = new StringTokenizer(importAttribute, ","); //$NON-NLS-1$ while (tokenizer.hasMoreTokens()) { StringTokenizer actionTokenizer = new StringTokenizer(tokenizer.nextToken(), ";"); //$NON-NLS-1$ String actionId = actionTokenizer.nextToken().trim(); int lastDot = actionId.lastIndexOf('.'); String actionKey = (lastDot == -1) ? actionId : actionId.substring(lastDot + 1); VersionRange actionVersionRange = null; while (actionTokenizer.hasMoreTokens()) { String actionAttribute = actionTokenizer.nextToken().trim(); if (actionAttribute.startsWith(VERSION_EQUALS)) actionVersionRange = VersionRange.create(actionAttribute.substring(VERSION_EQUALS.length() + 1)); } result.put(actionKey, new ActionEntry(actionId, actionVersionRange)); result.put(actionId, new ActionEntry(actionId, actionVersionRange)); } return result; }
private void processImport(Attributes attributes) { String id = attributes.getValue("feature"); //$NON-NLS-1$ boolean isPlugin = false; if (id == null) { id = attributes.getValue("plugin"); //$NON-NLS-1$ if (id == null) throw new IllegalStateException(); isPlugin = true; } String versionStr = attributes.getValue("version"); //$NON-NLS-1$ FeatureEntry entry = null; if ("versionRange".equals(attributes.getValue("match"))) { //$NON-NLS-1$//$NON-NLS-2$ VersionRange versionRange = VersionRange.create(versionStr); entry = FeatureEntry.createRequires(id, versionRange, attributes.getValue("match"), attributes.getValue("filter"), isPlugin); //$NON-NLS-1$ //$NON-NLS-2$ } else { entry = FeatureEntry.createRequires(id, versionStr, attributes.getValue("match"), attributes.getValue("filter"), isPlugin); //$NON-NLS-1$ //$NON-NLS-2$ } if (!isPlugin && "true".equalsIgnoreCase(attributes.getValue("patch"))) { //$NON-NLS-1$ //$NON-NLS-2$ entry.setPatch(true); } hasImports = true; result.addEntry(entry); }
public Touchpoint getTouchpoint(String typeId, String versionRange) { if (typeId == null || typeId.length() == 0) throw new IllegalArgumentException(Messages.TouchpointManager_Null_Touchpoint_Type_Argument); TouchpointEntry entry = getTouchpointEntries().get(typeId); if (entry == null) return null; if (versionRange != null) { VersionRange range = VersionRange.create(versionRange); if (!range.isIncluded(entry.getVersion())) return null; } return entry.getTouchpoint(); }
/** * Returns whether the profile file for the given profile should be written in gzip format. */ private boolean shouldGzipFile(Profile profile) { //check system property controlling compression String format = EngineActivator.getContext().getProperty(EngineActivator.PROP_PROFILE_FORMAT); if (format != null && format.equals(EngineActivator.PROFILE_FORMAT_UNCOMPRESSED)) return false; //check whether the profile contains the p2 engine from 3.5.0 or earlier return profile.available(QueryUtil.createIUQuery("org.eclipse.equinox.p2.engine", VersionRange.create("[0.0.0, 1.0.101)")), null).isEmpty(); //$NON-NLS-1$//$NON-NLS-2$ }
String eeName = eeSegments[0].replace('%', '/'); String eeVersion = eeSegments[1]; res.add(MetadataFactory.createRequirement(JREAction.NAMESPACE_OSGI_EE, eeName, VersionRange.create('[' + eeVersion + ',' + eeVersion + ']'), filter, false, false)); } else { osWithUndefinedVM.add(os); res.add(MetadataFactory.createRequirement(JREAction.NAMESPACE_OSGI_EE, DEFAULT_EE_CAPABILITY_NAME, VersionRange.create("0.0.0"), null, false, false)); //$NON-NLS-1$ } else { osWithUndefinedVM.forEach(os -> { IMatchExpression<IInstallableUnit> filter = createFilterSpec(createConfigSpec(CONFIG_ANY, os, CONFIG_ANY)); res.add(MetadataFactory.createRequirement(JREAction.NAMESPACE_OSGI_EE, DEFAULT_EE_CAPABILITY_NAME, VersionRange.create("0.0.0"), filter, false, false)); //$NON-NLS-1$ });
namespace = currentValue(); } else if (token.equals(RANGE)) { range = VersionRange.create(substituteVersionAndQualifier(currentValue())); } else if (token.equals(MIN)) { min = Integer.valueOf(currentValue()).intValue();
VersionRange versionRange = VersionRange.create(range); return MetadataFactory.createUpdateDescriptor(name, versionRange, Integer.valueOf(severity), description);
next(); } else if (token.equals(UPDATE_RANGE)) { unitUpdateRange = VersionRange.create(substituteVersionAndQualifier(currentValue())); next(); } else if (token.equals(UPDATE_SEVERITY)) {
protected VersionRange getVersionRange(FeatureEntry entry) { String versionSpec = entry.getVersion(); if (versionSpec == null) return VersionRange.emptyRange; String match = entry.getMatch(); if ("versionRange".equals(match)) //$NON-NLS-1$ return VersionRange.create(versionSpec); Version version = Version.parseVersion(versionSpec); if (version.equals(Version.emptyVersion)) return VersionRange.emptyRange; if (!entry.isRequires()) return new VersionRange(version, true, version, true); if (match == null) // TODO should really be returning VersionRange.emptyRange here... return null; if (match.equals("perfect")) //$NON-NLS-1$ return new VersionRange(version, true, version, true); org.osgi.framework.Version osgiVersion = PublisherHelper.toOSGiVersion(version); if (match.equals("equivalent")) { //$NON-NLS-1$ Version upper = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor() + 1, 0); return new VersionRange(version, true, upper, false); } if (match.equals("compatible")) { //$NON-NLS-1$ Version upper = Version.createOSGi(osgiVersion.getMajor() + 1, 0, 0); return new VersionRange(version, true, upper, false); } if (match.equals("greaterOrEqual")) //$NON-NLS-1$ return new VersionRange(version, true, Version.MAX_VERSION, true); return null; }