1 11 package org.eclipse.pde.internal.core.text.bundle; 12 13 import org.eclipse.osgi.util.ManifestElement; 14 import org.eclipse.pde.internal.core.ICoreConstants; 15 import org.eclipse.pde.internal.core.bundle.BundlePluginBase; 16 import org.eclipse.pde.internal.core.ibundle.IBundle; 17 import org.osgi.framework.BundleException; 18 import org.osgi.framework.Constants; 19 20 public abstract class BasePackageHeader extends CompositeManifestHeader { 21 22 private static final long serialVersionUID = 1L; 23 24 public BasePackageHeader(String name, String value, IBundle bundle, String lineDelimiter) { 25 super(name, value, bundle, lineDelimiter, true); 26 } 27 28 protected String getVersionAttribute() { 29 int manifestVersion = BundlePluginBase.getBundleManifestVersion(getBundle()); 30 return (manifestVersion < 2) ? ICoreConstants.PACKAGE_SPECIFICATION_VERSION : Constants.VERSION_ATTRIBUTE; 31 } 32 33 public void addPackage(PackageObject object) { 34 addManifestElement(object); 35 } 36 37 public Object removePackage(PackageObject object) { 38 return removeManifestElement(object); 39 } 40 41 public boolean hasPackage(String packageName) { 42 return hasElement(packageName); 43 } 44 45 public Object removePackage(String name) { 46 return removeManifestElement(name); 47 } 48 49 public boolean renamePackage(String oldName, String newName) { 50 if (hasPackage(oldName)) { 51 PackageObject object = (PackageObject)removeManifestElement(oldName); 52 object.setName(newName); 53 addManifestElement(object); 54 return true; 55 } 56 return false; 57 } 58 59 protected void processValue(String value) { 60 try { 61 ManifestElement[] elements = ManifestElement.parseHeader(fName, value); 62 for (int i = 0; i < elements.length; i++) { 63 if (elements[i].getValueComponents().length > 1) { 64 String [] values = elements[i].getValueComponents(); 66 for (int j = 0; j < values.length; j++) { 67 PDEManifestElement elem = createElement(elements[i]); 68 elem.setValueComponents(new String [] { values [j] }); 69 addManifestElement(elem, false); 70 } 71 } else { 72 addManifestElement(createElement(elements[i]), false); 73 } 74 } 75 } catch (BundleException e) { 76 } 77 } 78 79 } 80 | Popular Tags |