1 11 package org.eclipse.core.internal.registry; 12 13 public class RegistryIndexElement implements KeyedElement { 14 15 final protected String key; 17 18 private RegistryIndexChildren extensionPoints; 20 21 private RegistryIndexChildren extensions; 23 24 public RegistryIndexElement(String key) { 25 this.key = key; 26 } 27 28 public RegistryIndexElement(String key, int[] extensionPoints, int[] extensions) { 29 this.key = key; 30 this.extensionPoints = new RegistryIndexChildren(extensionPoints); 31 this.extensions = new RegistryIndexChildren(extensions); 32 } 33 34 protected int[] getExtensions() { 35 if (extensions == null) 36 return RegistryIndexChildren.EMPTY_ARRAY; 37 return extensions.getChildren(); 38 } 39 40 protected int[] getExtensionPoints() { 41 if (extensionPoints == null) 42 return RegistryIndexChildren.EMPTY_ARRAY; 43 return extensionPoints.getChildren(); 44 } 45 46 public boolean updateExtension(int id, boolean add) { 47 if (extensions == null) 48 extensions = new RegistryIndexChildren(); 49 50 if (add) 51 return extensions.linkChild(id); 52 else 53 return extensions.unlinkChild(id); 54 } 55 56 public boolean updateExtensions(int[] IDs, boolean add) { 57 if (extensions == null) 58 extensions = new RegistryIndexChildren(); 59 60 if (add) 61 return extensions.linkChildren(IDs); 62 else 63 return extensions.unlinkChildren(IDs); 64 } 65 66 public boolean updateExtensionPoint(int id, boolean add) { 67 if (extensionPoints == null) 68 extensionPoints = new RegistryIndexChildren(); 69 70 if (add) 71 return extensionPoints.linkChild(id); 72 else 73 return extensionPoints.unlinkChild(id); 74 } 75 76 public boolean updateExtensionPoints(int[] IDs, boolean add) { 77 if (extensionPoints == null) 78 extensionPoints = new RegistryIndexChildren(); 79 80 if (add) 81 return extensionPoints.linkChildren(IDs); 82 else 83 return extensionPoints.unlinkChildren(IDs); 84 } 85 86 public int getKeyHashCode() { 88 return getKey().hashCode(); 89 } 90 91 public Object getKey() { 92 return key; 93 } 94 95 public boolean compare(KeyedElement other) { 96 return key.equals(((RegistryIndexElement) other).key); 97 } 98 } 99 | Popular Tags |