1 11 package org.eclipse.core.internal.registry; 12 13 import java.util.MissingResourceException ; 14 import java.util.ResourceBundle ; 15 import org.eclipse.core.internal.runtime.ResourceTranslator; 16 import org.eclipse.core.runtime.IExtension; 17 import org.eclipse.core.runtime.IExtensionPoint; 18 import org.osgi.framework.Bundle; 19 20 24 public class Namespace extends NestedRegistryModelObject { 25 private String hostId; 27 private IExtensionPoint[] extensionPoints; 28 private IExtension[] extensions; 29 private transient ResourceBundle resourceBundle; 30 private boolean missingResourceBundle = false; 31 private Bundle bundle; 33 public String getUniqueIdentifier() { 34 return getName(); 35 } 36 37 public void setUniqueIdentifier(String value) { 38 setName(value); 39 } 40 41 public void setExtensions(IExtension[] value) { 42 extensions = value; 43 } 44 45 public IExtension getExtension(String id) { 46 if (id == null) 47 return null; 48 IExtension[] list = getExtensions(); 49 if (list == null) 50 return null; 51 for (int i = 0; i < list.length; i++) { 52 if (id.equals(list[i].getSimpleIdentifier())) 53 return list[i]; 54 } 55 return null; 56 } 57 58 public IExtension[] getExtensions() { 59 return extensions == null ? new IExtension[0] : extensions; 60 } 61 62 public void setExtensionPoints(IExtensionPoint[] value) { 63 extensionPoints = value; 64 } 65 66 public IExtensionPoint getExtensionPoint(String xpt) { 67 if (xpt == null) 68 return null; 69 IExtensionPoint[] list = getExtensionPoints(); 70 if (list == null) 71 return null; 72 for (int i = 0; i < list.length; i++) { 73 if (xpt.equals(list[i].getSimpleIdentifier())) 74 return list[i]; 75 } 76 return null; 77 } 78 79 public IExtensionPoint[] getExtensionPoints() { 80 return extensionPoints == null ? new IExtensionPoint[0] : extensionPoints; 81 } 82 83 public void setHostIdentifier(String value) { 84 hostId = value; 85 } 86 87 public String getHostIdentifier() { 88 return hostId; 89 } 90 91 public boolean isFragment() { 92 return hostId != null; 93 } 94 95 public String toString() { 96 return "Namespace: " + getName(); } 98 99 public long getId() { 100 return bundle == null ? -1 : bundle.getBundleId(); 102 } 103 104 public Bundle getBundle() { 105 return bundle; 106 } 107 108 public void setBundle(Bundle value) { 109 bundle = value; 110 } 111 112 public String getResourceString(String value) { 113 if (resourceBundle != null) 114 return ResourceTranslator.getResourceString(null, value, resourceBundle); 115 116 if (missingResourceBundle) 117 return value; 118 119 if (resourceBundle == null) { 120 try { 121 resourceBundle = ResourceTranslator.getResourceBundle(bundle); 122 } catch (MissingResourceException e) { 123 resourceBundle = null; 124 } 125 } 126 127 if (resourceBundle == null) { 128 missingResourceBundle = true; 129 return value; 130 } 131 132 return ResourceTranslator.getResourceString(null, value, resourceBundle); 133 } 134 } | Popular Tags |