1 11 12 package org.eclipse.osgi.internal.resolver; 13 14 import java.util.*; 15 import org.eclipse.osgi.framework.internal.core.Constants; 16 import org.eclipse.osgi.service.resolver.BundleDescription; 17 import org.eclipse.osgi.service.resolver.ExportPackageDescription; 18 19 public class ExportPackageDescriptionImpl extends BaseDescriptionImpl implements ExportPackageDescription { 20 public static final String EQUINOX_EE = "x-equinox-ee"; private static final Integer EQUINOX_EE_DEFAULT = new Integer (-1); 22 private String [] uses; 23 private Map attributes; 24 private BundleDescription exporter; 25 private String exclude; 26 private String include; 27 private String [] friends; 28 private String [] mandatory; 29 private Boolean internal = Boolean.FALSE; 30 private int equinox_ee = -1; 31 private boolean root; 32 private int tableIndex; 33 34 public Map getDirectives() { 35 Map result = new HashMap(5); 36 if (uses != null) 37 result.put(Constants.USES_DIRECTIVE, uses); 38 if (exclude != null) 39 result.put(Constants.EXCLUDE_DIRECTIVE, exclude); 40 if (include != null) 41 result.put(Constants.INCLUDE_DIRECTIVE, include); 42 if (mandatory != null) 43 result.put(Constants.MANDATORY_DIRECTIVE, mandatory); 44 if (friends != null) 45 result.put(Constants.FRIENDS_DIRECTIVE, friends); 46 result.put(Constants.INTERNAL_DIRECTIVE, internal); 47 result.put(EQUINOX_EE, equinox_ee == -1 ? EQUINOX_EE_DEFAULT : new Integer (equinox_ee)); 48 return result; 49 } 50 51 public Object getDirective(String key) { 52 if (key.equals(Constants.USES_DIRECTIVE)) 53 return uses; 54 if (key.equals(Constants.EXCLUDE_DIRECTIVE)) 55 return exclude; 56 if (key.equals(Constants.INCLUDE_DIRECTIVE)) 57 return include; 58 if (key.equals(Constants.MANDATORY_DIRECTIVE)) 59 return mandatory; 60 if (key.equals(Constants.FRIENDS_DIRECTIVE)) 61 return friends; 62 if (key.equals(Constants.INTERNAL_DIRECTIVE)) 63 return internal; 64 if (key.equals(EQUINOX_EE)) 65 return equinox_ee == -1 ? EQUINOX_EE_DEFAULT : new Integer (equinox_ee); 66 return null; 67 } 68 69 public Object setDirective(String key, Object value) { 70 if (key.equals(Constants.USES_DIRECTIVE)) 71 return uses = (String []) value; 72 if (key.equals(Constants.EXCLUDE_DIRECTIVE)) 73 return exclude = (String ) value; 74 if (key.equals(Constants.INCLUDE_DIRECTIVE)) 75 return include = (String ) value; 76 if (key.equals(Constants.MANDATORY_DIRECTIVE)) 77 return mandatory = (String []) value; 78 if (key.equals(Constants.FRIENDS_DIRECTIVE)) 79 return friends = (String []) value; 80 if (key.equals(Constants.INTERNAL_DIRECTIVE)) 81 return internal = (Boolean ) value; 82 if (key.equals(EQUINOX_EE)) { 83 equinox_ee = ((Integer ) value).intValue(); 84 return value; 85 } 86 return null; 87 } 88 89 public void setDirectives(Map directives) { 90 if (directives == null) 91 return; 92 uses = (String []) directives.get(Constants.USES_DIRECTIVE); 93 exclude = (String ) directives.get(Constants.EXCLUDE_DIRECTIVE); 94 include = (String ) directives.get(Constants.INCLUDE_DIRECTIVE); 95 mandatory = (String []) directives.get(Constants.MANDATORY_DIRECTIVE); 96 friends = (String []) directives.get(Constants.FRIENDS_DIRECTIVE); 97 internal = (Boolean ) directives.get(Constants.INTERNAL_DIRECTIVE); 98 equinox_ee = ((Integer ) directives.get(EQUINOX_EE)).intValue(); 99 } 100 101 public Map getAttributes() { 102 return attributes; 103 } 104 105 public BundleDescription getSupplier() { 106 return getExporter(); 107 } 108 109 public BundleDescription getExporter() { 110 return exporter; 111 } 112 113 public boolean isRoot() { 114 return root; 115 } 116 117 protected void setAttributes(Map attributes) { 118 this.attributes = attributes; 119 } 120 121 protected void setExporter(BundleDescription exporter) { 122 this.exporter = exporter; 123 } 124 125 protected void setRoot(boolean root) { 126 this.root = root; 127 } 128 129 public String toString() { 130 return "Export-Package: " + getName() + "; version=\"" + getVersion() + "\""; } 132 133 int getTableIndex() { 134 return tableIndex; 135 } 136 137 void setTableIndex(int tableIndex) { 138 this.tableIndex = tableIndex; 139 } 140 } 141 | Popular Tags |