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.ibundle.IBundle; 15 import org.osgi.framework.BundleException; 16 17 public class SingleManifestHeader extends ManifestHeader { 18 19 private static final long serialVersionUID = 1L; 20 21 private PDEManifestElement fElement; 22 23 public SingleManifestHeader(String name, String value, IBundle bundle, String lineDelimiter) { 24 super(name, value, bundle, lineDelimiter); 25 } 26 27 protected void processValue(String value) { 28 try { 29 ManifestElement[] elements = ManifestElement.parseHeader(getName(), value); 30 if (elements.length > 0) 31 fElement = new PDEManifestElement(this, elements[0]); 32 } catch (BundleException e) { 33 } 34 if (fElement == null) 35 fElement = new PDEManifestElement(this, ""); fValue = value; 37 } 38 39 public void setAttribute(String key, String value) { 40 fElement.setAttribute(key, value); 41 update(); 42 } 43 44 public void setDirective(String key, String value) { 45 fElement.setDirective(key, value); 46 update(); 47 } 48 49 public void setMainComponent(String value) { 50 if (value == null) 51 fElement.setValueComponents((String [])null); 52 else 53 fElement.setValueComponents(new String [] {value}); 54 update(); 55 } 56 57 public String getAttribute(String key) { 58 return fElement.getAttribute(key); 59 } 60 61 public String getDirective(String key) { 62 return fElement.getDirective(key); 63 } 64 65 public String getMainComponent() { 66 return fElement.getValue(); 67 } 68 69 public void update() { 70 update(true); 72 } 73 74 public void update(boolean notify) { 75 String old = fValue; 76 fValue = fElement.write(); 77 if (notify) 78 fBundle.getModel().fireModelObjectChanged(this, fName, old, fValue); 79 } 80 81 } 82 | Popular Tags |