1 11 package org.eclipse.pde.internal.ui.model.bundle; 12 13 import org.eclipse.osgi.service.resolver.*; 14 import org.eclipse.osgi.util.*; 15 import org.osgi.framework.*; 16 17 public class ImportPackageObject extends PackageObject { 18 19 private static final long serialVersionUID = 1L; 20 21 private boolean fOptional; 22 23 private static String getVersion(ExportPackageDescription desc) { 24 String version = desc.getVersion().toString(); 25 if (!version.equals(Version.emptyVersion.toString())) 26 return desc.getVersion().toString(); 27 return null; 28 } 29 30 public ImportPackageObject(ManifestHeader header, ManifestElement element, String versionAttribute) { 31 super(header, element, versionAttribute); 32 fOptional = Constants.RESOLUTION_OPTIONAL.equals(element.getDirective(Constants.RESOLUTION_DIRECTIVE)); 33 } 34 35 public ImportPackageObject(ManifestHeader header, ExportPackageDescription desc, String versionAttribute) { 36 super(header, desc.getName(), getVersion(desc), versionAttribute); 37 fOptional = Constants.RESOLUTION_OPTIONAL.equals(desc.getDirective(Constants.RESOLUTION_DIRECTIVE)); 38 } 39 40 protected void appendSupportedAttributes(StringBuffer buffer) { 41 super.appendSupportedAttributes(buffer); 42 if (fOptional) { 43 buffer.append(";"); buffer.append(Constants.RESOLUTION_DIRECTIVE); 45 buffer.append(":="); buffer.append(Constants.RESOLUTION_OPTIONAL); 47 } 48 } 49 public boolean isOptional() { 50 return fOptional; 51 } 52 53 public void setOptional(boolean optional) { 54 fOptional = optional; 55 } 56 57 } 58 | Popular Tags |