1 17 package org.eclipse.emf.mapping.ecore2xml.impl; 18 19 import org.eclipse.emf.common.notify.Notification; 20 import org.eclipse.emf.common.notify.NotificationChain; 21 22 import org.eclipse.emf.common.util.BasicEMap; 23 import org.eclipse.emf.common.util.EMap; 24 25 import org.eclipse.emf.ecore.EClass; 26 import org.eclipse.emf.ecore.ENamedElement; 27 import org.eclipse.emf.ecore.EObject; 28 import org.eclipse.emf.ecore.EStructuralFeature; 29 import org.eclipse.emf.ecore.InternalEObject; 30 31 import org.eclipse.emf.ecore.impl.ENotificationImpl; 32 import org.eclipse.emf.ecore.impl.EObjectImpl; 33 import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage; 34 import org.eclipse.emf.mapping.ecore2xml.XMLInfo; 35 36 50 public class ENamedElementToXMLInfoMapEntryImpl extends EObjectImpl implements BasicEMap.Entry 51 { 52 53 61 protected ENamedElement key = null; 62 63 71 protected XMLInfo value = null; 72 73 78 protected ENamedElementToXMLInfoMapEntryImpl() 79 { 80 super(); 81 } 82 83 88 protected EClass eStaticClass() 89 { 90 return Ecore2XMLPackage.eINSTANCE.getENamedElementToXMLInfoMapEntry(); 91 } 92 93 98 public ENamedElement getTypedKey() 99 { 100 if (key != null && key.eIsProxy()) 101 { 102 ENamedElement oldKey = key; 103 key = (ENamedElement)eResolveProxy((InternalEObject)key); 104 if (key != oldKey) 105 { 106 if (eNotificationRequired()) 107 eNotify(new ENotificationImpl(this, Notification.RESOLVE, Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY, oldKey, key)); 108 } 109 } 110 return key; 111 } 112 113 118 public ENamedElement basicGetTypedKey() 119 { 120 return key; 121 } 122 123 128 public void setTypedKey(ENamedElement newKey) 129 { 130 ENamedElement oldKey = key; 131 key = newKey; 132 if (eNotificationRequired()) 133 eNotify(new ENotificationImpl(this, Notification.SET, Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY, oldKey, key)); 134 } 135 136 141 public XMLInfo getTypedValue() 142 { 143 return value; 144 } 145 146 151 public NotificationChain basicSetTypedValue(XMLInfo newValue, NotificationChain msgs) 152 { 153 XMLInfo oldValue = value; 154 value = newValue; 155 if (eNotificationRequired()) 156 { 157 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE, oldValue, newValue); 158 if (msgs == null) msgs = notification; else msgs.add(notification); 159 } 160 return msgs; 161 } 162 163 168 public void setTypedValue(XMLInfo newValue) 169 { 170 if (newValue != value) 171 { 172 NotificationChain msgs = null; 173 if (value != null) 174 msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE, null, msgs); 175 if (newValue != null) 176 msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE, null, msgs); 177 msgs = basicSetTypedValue(newValue, msgs); 178 if (msgs != null) msgs.dispatch(); 179 } 180 else if (eNotificationRequired()) 181 eNotify(new ENotificationImpl(this, Notification.SET, Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE, newValue, newValue)); 182 } 183 184 189 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 190 { 191 if (featureID >= 0) 192 { 193 switch (eDerivedStructuralFeatureID(featureID, baseClass)) 194 { 195 case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE: 196 return basicSetTypedValue(null, msgs); 197 default: 198 return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); 199 } 200 } 201 return eBasicSetContainer(null, featureID, msgs); 202 } 203 204 209 public Object eGet(EStructuralFeature eFeature, boolean resolve) 210 { 211 switch (eDerivedStructuralFeatureID(eFeature)) 212 { 213 case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY: 214 if (resolve) return getTypedKey(); 215 return basicGetTypedKey(); 216 case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE: 217 return getTypedValue(); 218 } 219 return eDynamicGet(eFeature, resolve); 220 } 221 222 227 public void eSet(EStructuralFeature eFeature, Object newValue) 228 { 229 switch (eDerivedStructuralFeatureID(eFeature)) 230 { 231 case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY: 232 setTypedKey((ENamedElement)newValue); 233 return; 234 case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE: 235 setTypedValue((XMLInfo)newValue); 236 return; 237 } 238 eDynamicSet(eFeature, newValue); 239 } 240 241 246 public void eUnset(EStructuralFeature eFeature) 247 { 248 switch (eDerivedStructuralFeatureID(eFeature)) 249 { 250 case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY: 251 setTypedKey((ENamedElement)null); 252 return; 253 case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE: 254 setTypedValue((XMLInfo)null); 255 return; 256 } 257 eDynamicUnset(eFeature); 258 } 259 260 265 public boolean eIsSet(EStructuralFeature eFeature) 266 { 267 switch (eDerivedStructuralFeatureID(eFeature)) 268 { 269 case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY: 270 return key != null; 271 case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE: 272 return value != null; 273 } 274 return eDynamicIsSet(eFeature); 275 } 276 277 282 protected int hash = -1; 283 284 289 public int getHash() 290 { 291 if (hash == -1) 292 { 293 Object theKey = getKey(); 294 hash = (theKey == null ? 0 : theKey.hashCode()); 295 } 296 return hash; 297 } 298 299 304 public void setHash(int hash) 305 { 306 this.hash = hash; 307 } 308 309 314 public Object getKey() 315 { 316 return getTypedKey(); 317 } 318 319 324 public void setKey(Object key) 325 { 326 setTypedKey((ENamedElement)key); 327 } 328 329 334 public Object getValue() 335 { 336 return getTypedValue(); 337 } 338 339 344 public Object setValue(Object value) 345 { 346 Object oldValue = getValue(); 347 setTypedValue((XMLInfo)value); 348 return oldValue; 349 } 350 351 356 public EMap getEMap() 357 { 358 EObject container = eContainer(); 359 return container == null ? null : (EMap)container.eGet(eContainmentFeature()); 360 } 361 362 } | Popular Tags |