1 11 package org.eclipse.pde.internal.core.bundle; 12 13 import java.util.Iterator ; 14 import java.util.Map ; 15 16 import org.eclipse.pde.internal.core.ibundle.IBundle; 17 import org.eclipse.pde.internal.core.ibundle.IManifestHeader; 18 import org.eclipse.pde.internal.core.text.bundle.ManifestHeader; 19 import org.eclipse.pde.internal.core.util.HeaderMap; 20 import org.osgi.framework.Constants; 21 22 public class Bundle extends BundleObject implements IBundle { 23 private static final long serialVersionUID = 1L; 24 private Map fProperties; 25 26 29 public void setHeader(String key, String value) { 30 if (fProperties == null) 31 fProperties = new HeaderMap(); Object oldValue = fProperties.get(key); 33 if (value == null || value.trim().length() == 0) 34 fProperties.remove(key); 35 else 36 fProperties.put(key, value); 37 getModel().fireModelObjectChanged(this, key, oldValue, value); 38 } 39 42 public String getHeader(String key) { 43 if (fProperties == null) { 44 return null; 45 } 46 return (String )fProperties.get(key); 47 } 48 49 public void load(Map properties) { 50 fProperties = new HeaderMap(); Iterator it = properties.keySet().iterator(); 53 while (it.hasNext()) { 54 Object o = it.next(); 55 fProperties.put(o, properties.get(o)); 56 } 57 } 58 59 public String getLocalization() { 60 return getHeader(Constants.BUNDLE_LOCALIZATION); 61 } 62 63 public void setLocalization(String localization) { 64 setHeader(Constants.BUNDLE_LOCALIZATION, localization); 65 } 66 67 public void renameHeader(String key, String newKey) { 68 if (fProperties == null) 69 fProperties = new HeaderMap(); if (fProperties.get(key) != null) { 71 fProperties.put(newKey, fProperties.remove(key)); 72 } 73 } 74 75 public IManifestHeader getManifestHeader(String key) { 76 return new ManifestHeader(key, getHeader(key), this, System.getProperty("line.separator")); } 78 79 protected Map getHeaders() { 80 return fProperties; 81 } 82 } 83 | Popular Tags |