.getSingleValue();
}
String vBundle = new ManifestHeaderValue(mainAttributes.getValue(BUNDLE_VERSION))
.getSingleValue();
Version version;
try {
version = versionOf(vBundle);
} catch (NumberFormatException e) {
throw new ParseException("The " + BUNDLE_VERSION + " has an incorrect version: "
+ vBundle + " (" + e.getMessage() + ")", 0);
}
BundleInfo bundleInfo = new BundleInfo(symbolicName, version);
bundleInfo.setDescription(description);
List<String> environments = new ManifestHeaderValue(
mainAttributes.getValue(BUNDLE_REQUIRED_EXECUTION_ENVIRONMENT)).getValues();
bundleInfo.setExecutionEnvironments(environments);
parseRequirement(bundleInfo, mainAttributes, REQUIRE_BUNDLE, BundleInfo.BUNDLE_TYPE,
ATTR_BUNDLE_VERSION);
parseRequirement(bundleInfo, mainAttributes, IMPORT_PACKAGE, BundleInfo.PACKAGE_TYPE,
ATTR_VERSION);
parseRequirement(bundleInfo, mainAttributes, IMPORT_SERVICE, BundleInfo.SERVICE_TYPE,
ATTR_VERSION);
ManifestHeaderValue exportElements = new ManifestHeaderValue(
mainAttributes.getValue(EXPORT_PACKAGE));
for (ManifestHeaderElement exportElement : exportElements.getElements()) {
String vExport = exportElement.getAttributes().get(ATTR_VERSION);
Version v = null;
try {
v = versionOf(vExport);
} catch (NumberFormatException e) {
throw new ParseException("The " + EXPORT_PACKAGE + " has an incorrect version: "
+ vExport + " (" + e.getMessage() + ")", 0);
}
for (String name : exportElement.getValues()) {
ExportPackage export = new ExportPackage(name, v);
String uses = exportElement.getDirectives().get(ATTR_USE);
if (uses != null) {
String[] split = uses.trim().split(",");
for (int i = 0; i < split.length; i++) {
export.addUse(split[i].trim());
}
}
bundleInfo.addCapability(export);
}
}
parseCapability(bundleInfo, mainAttributes, EXPORT_SERVICE, BundleInfo.SERVICE_TYPE);
// handle Eclipse specific source attachement
String eclipseSourceBundle = mainAttributes.getValue(ECLIPSE_SOURCE_BUNDLE);
if (eclipseSourceBundle != null) {
bundleInfo.setSource(true);
ManifestHeaderValue eclipseSourceBundleValue = new ManifestHeaderValue(
eclipseSourceBundle);
ManifestHeaderElement element = eclipseSourceBundleValue.getElements().iterator()
.next();
String symbolicNameTarget = element.getValues().iterator().next();
bundleInfo.setSymbolicNameTarget(symbolicNameTarget);
String v = element.getAttributes().get(ATTR_VERSION);
if (v != null) {
bundleInfo.setVersionTarget(new Version(v));
}
}
String bundleClasspath = mainAttributes.getValue(BUNDLE_CLASSPATH);
if (bundleClasspath != null) {