1 17 package org.eclipse.emf.ecore.impl; 18 19 20 import org.eclipse.emf.common.util.EList; 21 import org.eclipse.emf.common.util.URI; 22 import org.eclipse.emf.ecore.EClass; 23 import org.eclipse.emf.ecore.EStructuralFeature; 24 import org.eclipse.emf.ecore.resource.Resource; 25 26 27 30 public class DynamicEObjectImpl extends EObjectImpl implements EStructuralFeature.Internal.DynamicValueHolder 31 { 32 35 protected static class DynamicEPropertiesHolderImpl implements BasicEObjectImpl.EPropertiesHolder 36 { 37 protected URI eProxyURI; 38 protected Resource.Internal eResource; 39 protected EList eContents; 40 protected EList eCrossReferences; 41 42 public EClass getEClass() 43 { 44 throw new UnsupportedOperationException (); 45 } 46 47 public void setEClass(EClass eClass) 48 { 49 throw new UnsupportedOperationException (); 50 } 51 52 public URI getEProxyURI() 53 { 54 return eProxyURI; 55 } 56 57 public void setEProxyURI(URI eProxyURI) 58 { 59 this.eProxyURI = eProxyURI; 60 } 61 62 public Resource.Internal getEResource() 63 { 64 return eResource; 65 } 66 67 public void setEResource(Resource.Internal eResource) 68 { 69 this.eResource = eResource; 70 } 71 72 public EList getEContents() 73 { 74 return eContents; 75 } 76 77 public void setEContents(EList eContents) 78 { 79 this.eContents = eContents; 80 } 81 82 public EList getECrossReferences() 83 { 84 return eCrossReferences; 85 } 86 87 public void setECrossReferences(EList eCrossReferences) 88 { 89 this.eCrossReferences = eCrossReferences; 90 } 91 92 public boolean hasSettings() 93 { 94 throw new UnsupportedOperationException (); 95 } 96 97 public void allocateSettings(int maximumDynamicFeatureID) 98 { 99 throw new UnsupportedOperationException (); 100 } 101 102 public Object dynamicGet(int dynamicFeatureID) 103 { 104 throw new UnsupportedOperationException (); 105 } 106 107 public void dynamicSet(int dynamicFeatureID, Object value) 108 { 109 throw new UnsupportedOperationException (); 110 } 111 112 public void dynamicUnset(int dynamicFeatureID) 113 { 114 throw new UnsupportedOperationException (); 115 } 116 } 117 118 protected EClass eClass; 119 protected Object [] eSettings; 120 121 protected static final Object [] ENO_SETTINGS = new Object [0]; 122 123 126 public DynamicEObjectImpl() 127 { 128 super(); 129 } 130 131 134 public DynamicEObjectImpl(EClass eClass) 135 { 136 super(); 137 eSetClass(eClass); 138 } 139 140 protected int eStaticFeatureCount() 141 { 142 return 0; 143 } 144 145 public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) 146 { 147 return eClass().getFeatureID(eStructuralFeature); 148 } 149 150 protected BasicEObjectImpl.EPropertiesHolder eProperties() 151 { 152 if (eProperties == null) 153 { 154 eProperties = new DynamicEPropertiesHolderImpl(); 155 } 156 return eProperties; 157 } 158 159 protected boolean eHasSettings() 160 { 161 return eSettings != null; 162 } 163 164 protected EStructuralFeature.Internal.DynamicValueHolder eSettings() 165 { 166 if (eSettings == null) 167 { 168 int size = eClass().getFeatureCount() - eStaticFeatureCount(); 169 eSettings = size == 0 ? ENO_SETTINGS : new Object [size]; 170 } 171 172 return this; 173 } 174 175 protected EClass eDynamicClass() 176 { 177 return eClass; 178 } 179 180 public EClass eClass() 181 { 182 return eClass; 183 } 184 185 public void eSetClass(EClass eClass) 186 { 187 this.eClass = eClass; 188 } 189 190 public Object dynamicGet(int dynamicFeatureID) 191 { 192 return eSettings[dynamicFeatureID]; 193 } 194 195 public void dynamicSet(int dynamicFeatureID, Object value) 196 { 197 eSettings[dynamicFeatureID] = value; 198 } 199 200 public void dynamicUnset(int dynamicFeatureID) 201 { 202 eSettings[dynamicFeatureID] = null; 203 } 204 205 213 } 214 | Popular Tags |