use of org.eclipse.osgi.util.ManifestElement in project tycho by eclipse.
the class StandardExecutionEnvironment method parseEEVersion.
private EEVersion parseEEVersion(String systemCaps) {
List<EEVersion> eeVersions = new ArrayList<>();
try {
ManifestElement[] systemCapValues = ManifestElement.parseHeader("org.osgi.framework.system.capabilities", systemCaps);
for (int i = 0; i < systemCapValues.length; i++) {
Version version;
String singleVersion = systemCapValues[i].getAttribute("version:Version");
if (singleVersion != null) {
version = Version.parseVersion(singleVersion);
} else {
String[] versions = systemCapValues[i].getAttribute("version:List<Version>").split(",");
List<Version> osgiVersions = new ArrayList<>(versions.length);
for (String currentVersion : versions) {
osgiVersions.add(Version.parseVersion(currentVersion));
}
version = Collections.max(osgiVersions);
}
String execEnv = systemCapValues[i].getAttribute("osgi.ee");
EEType eeType = EEType.fromName(execEnv);
if (eeType != null) {
eeVersions.add(new EEVersion(version, eeType));
}
}
return Collections.max(eeVersions);
} catch (BundleException e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.osgi.util.ManifestElement in project tycho by eclipse.
the class MutableBundleManifest method getRequiredBundleVersions.
/**
* Read the RequiredBundle with optional versions
*
* @return
*/
public Map<String, String> getRequiredBundleVersions() {
ManifestElement[] requireBundleElements = parseHeader(Constants.REQUIRE_BUNDLE);
if (requireBundleElements == null || requireBundleElements.length == 0) {
return Collections.emptyMap();
}
Map<String, String> result = new HashMap<>();
for (ManifestElement manifestElement : requireBundleElements) {
String symbolicName = manifestElement.getValue();
String versionRangeString = manifestElement.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
result.put(symbolicName, versionRangeString);
}
return result;
}
use of org.eclipse.osgi.util.ManifestElement in project tycho by eclipse.
the class MutableBundleManifest method getImportPackagesVersions.
/**
* Get a map containing the name of packages in Import-Package manifest attribute as a map.
* <p>
* The map keys are the package names and the values are the version range if present or null
* when absent.
*
* @return
*/
public Map<String, String> getImportPackagesVersions() {
ManifestElement[] importPackageElements = parseHeader(Constants.IMPORT_PACKAGE);
if (importPackageElements == null || importPackageElements.length == 0) {
return Collections.emptyMap();
}
Map<String, String> result = new HashMap<>();
for (ManifestElement manifestElement : importPackageElements) {
String packageName = manifestElement.getValue();
String versionRangeString = manifestElement.getAttribute(Constants.VERSION_ATTRIBUTE);
result.put(packageName, versionRangeString);
}
return result;
}
use of org.eclipse.osgi.util.ManifestElement in project tycho by eclipse.
the class MutableBundleManifest method getExportedPackagesVersion.
/**
* Get a map containing the name of packages in Export-Package manifest attribute as a map.
*
* @return the package/version map. Keys are the package names and the values are the version if
* present or null when absent.
*/
public Map<String, String> getExportedPackagesVersion() {
ManifestElement[] exportPackageElements = parseHeader(Constants.EXPORT_PACKAGE);
if (exportPackageElements == null || exportPackageElements.length == 0) {
return Collections.emptyMap();
}
Map<String, String> result = new HashMap<>();
for (ManifestElement manifestElement : exportPackageElements) {
String packageName = manifestElement.getValue();
String versionRangeString = manifestElement.getAttribute(Constants.VERSION_ATTRIBUTE);
result.put(packageName, versionRangeString);
}
return result;
}
use of org.eclipse.osgi.util.ManifestElement in project tycho by eclipse.
the class MutableManifestElement method parseHeader.
public static List<MutableManifestElement> parseHeader(String name, String value) throws BundleException {
ManifestElement[] manifestElements = ManifestElement.parseHeader(name, value);
if (manifestElements == null) {
return null;
}
List<MutableManifestElement> mutableManifestElements = new ArrayList<>();
for (ManifestElement manifestElement : manifestElements) {
mutableManifestElements.add(new MutableManifestElement(manifestElement));
}
return mutableManifestElements;
}
Aggregations