1 11 package org.eclipse.core.internal.registry; 12 13 import java.io.File ; 14 import java.lang.ref.SoftReference ; 15 import org.eclipse.core.runtime.IContributor; 16 17 21 public class ExtensionPoint extends RegistryObject { 22 public static final ExtensionPoint[] EMPTY_ARRAY = new ExtensionPoint[0]; 23 24 private Object extraInformation; 27 private static final byte LABEL = 0; private static final byte SCHEMA = 1; private static final byte QUALIFIED_NAME = 2; private static final byte NAMESPACE = 3; private static final byte CONTRIBUTOR_ID = 4; private static final int EXTRA_SIZE = 5; 34 35 protected ExtensionPoint(ExtensionRegistry registry, boolean persist) { 36 super(registry, persist); 37 } 38 39 protected ExtensionPoint(int self, int[] children, int dataOffset, ExtensionRegistry registry, boolean persist) { 40 super(registry, persist); 41 42 setObjectId(self); 43 setRawChildren(children); 44 setExtraDataOffset(dataOffset); 45 } 46 47 protected String getSimpleIdentifier() { 48 return getUniqueIdentifier().substring(getUniqueIdentifier().lastIndexOf('.') + 1); 49 } 50 51 private String [] getExtraData() { 52 if (noExtraData()) { if (extraInformation != null) 55 return (String []) extraInformation; 56 return new String [EXTRA_SIZE]; 57 } 58 59 String [] result = null; 61 if (extraInformation == null || (result = ((extraInformation instanceof SoftReference ) ? (String []) ((SoftReference ) extraInformation).get() : (String []) extraInformation)) == null) { 62 result = registry.getTableReader().loadExtensionPointExtraData(getExtraDataOffset()); 63 extraInformation = new SoftReference (result); 64 } 65 return result; 66 } 67 68 71 private void ensureExtraInformationType() { 72 if (extraInformation instanceof SoftReference ) { 73 extraInformation = ((SoftReference ) extraInformation).get(); 74 } 75 if (extraInformation == null) { 76 extraInformation = new String [EXTRA_SIZE]; 77 } 78 } 79 80 protected String getSchemaReference() { 81 String [] result = getExtraData(); 82 return result[1] == null ? "" : result[SCHEMA].replace(File.separatorChar, '/'); } 84 85 protected String getLabel() { 86 String [] result = getExtraData(); 87 return result[0] == null ? "" : result[LABEL]; } 89 90 protected String getUniqueIdentifier() { 91 return getExtraData()[QUALIFIED_NAME]; 92 } 93 94 public String getNamespace() { 95 return getExtraData()[NAMESPACE]; 96 } 97 98 protected String getContributorId() { 99 return getExtraData()[CONTRIBUTOR_ID]; 100 } 101 102 public IContributor getContributor() { 103 return registry.getObjectManager().getContributor(getContributorId()); 104 } 105 106 void setSchema(String value) { 107 ensureExtraInformationType(); 108 ((String []) extraInformation)[SCHEMA] = value; 109 } 110 111 void setLabel(String value) { 112 ensureExtraInformationType(); 113 ((String []) extraInformation)[LABEL] = value; 114 } 115 116 void setUniqueIdentifier(String value) { 117 ensureExtraInformationType(); 118 ((String []) extraInformation)[QUALIFIED_NAME] = value; 119 } 120 121 void setNamespace(String value) { 122 ensureExtraInformationType(); 123 ((String []) extraInformation)[NAMESPACE] = value; 124 } 125 126 void setContributorId(String id) { 127 ensureExtraInformationType(); 128 ((String []) extraInformation)[CONTRIBUTOR_ID] = id; 129 } 130 131 public String toString() { 132 return getUniqueIdentifier(); 133 } 134 135 } 136 | Popular Tags |