1 17 package org.eclipse.emf.mapping.ecore2xml.impl; 18 19 import java.util.Collection ; 20 21 import java.util.List ; 22 23 import org.eclipse.emf.common.notify.Notification; 24 import org.eclipse.emf.common.notify.NotificationChain; 25 26 import org.eclipse.emf.common.util.EMap; 27 28 import org.eclipse.emf.ecore.EClass; 29 import org.eclipse.emf.ecore.EClassifier; 30 import org.eclipse.emf.ecore.ENamedElement; 31 import org.eclipse.emf.ecore.EPackage; 32 import org.eclipse.emf.ecore.EStructuralFeature; 33 import org.eclipse.emf.ecore.InternalEObject; 34 35 import org.eclipse.emf.ecore.impl.ENotificationImpl; 36 import org.eclipse.emf.ecore.impl.EObjectImpl; 37 38 import org.eclipse.emf.ecore.util.EcoreEMap; 39 import org.eclipse.emf.ecore.util.InternalEList; 40 import org.eclipse.emf.ecore.xmi.XMLResource; 41 import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage; 42 import org.eclipse.emf.mapping.ecore2xml.XMLInfo; 43 import org.eclipse.emf.mapping.ecore2xml.XMLMap; 44 45 60 public class XMLMapImpl extends EObjectImpl implements XMLMap 61 { 62 63 71 protected static final String IDATTRIBUTE_NAME_EDEFAULT = null; 72 73 81 protected EMap ecoreToXMLInfo = null; 82 83 88 protected XMLMapImpl() 89 { 90 super(); 91 } 92 93 98 protected EClass eStaticClass() 99 { 100 return Ecore2XMLPackage.eINSTANCE.getXMLMap(); 101 } 102 103 108 public String getIDAttributeName() 109 { 110 return delegateXMLMap.getIDAttributeName(); 111 } 112 113 118 public void setIDAttributeName(String newIDAttributeName) 119 { 120 String oldIDAttributeName = delegateXMLMap.getIDAttributeName(); 121 delegateXMLMap.setIDAttributeName(newIDAttributeName); 122 if (eNotificationRequired()) 123 eNotify(new ENotificationImpl(this, Notification.SET, Ecore2XMLPackage.XML_MAP__IDATTRIBUTE_NAME, oldIDAttributeName, newIDAttributeName)); 124 } 125 126 131 public EMap getEcoreToXMLInfo() 132 { 133 if (ecoreToXMLInfo == null) 134 { 135 ecoreToXMLInfo = new EcoreEMap(Ecore2XMLPackage.eINSTANCE.getENamedElementToXMLInfoMapEntry(), ENamedElementToXMLInfoMapEntryImpl.class, this, Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO); 136 } 137 return ecoreToXMLInfo; 138 } 139 140 145 public EPackage getNoNamespacePackage() 146 { 147 EPackage noNamespacePackage = basicGetNoNamespacePackage(); 148 return noNamespacePackage == null ? null : (EPackage)eResolveProxy((InternalEObject)noNamespacePackage); 149 } 150 151 156 public EPackage basicGetNoNamespacePackage() 157 { 158 return delegateXMLMap.getNoNamespacePackage(); 159 } 160 161 166 public void setNoNamespacePackage(EPackage newNoNamespacePackage) 167 { 168 EPackage oldNoNamespacePackage = delegateXMLMap.getNoNamespacePackage(); 169 delegateXMLMap.setNoNamespacePackage(newNoNamespacePackage); 170 if (eNotificationRequired()) 171 eNotify(new ENotificationImpl(this, Notification.SET, Ecore2XMLPackage.XML_MAP__NO_NAMESPACE_PACKAGE, oldNoNamespacePackage, newNoNamespacePackage)); 172 } 173 174 179 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 180 { 181 if (featureID >= 0) 182 { 183 switch (eDerivedStructuralFeatureID(featureID, baseClass)) 184 { 185 case Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO: 186 return ((InternalEList)getEcoreToXMLInfo()).basicRemove(otherEnd, msgs); 187 default: 188 return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); 189 } 190 } 191 return eBasicSetContainer(null, featureID, msgs); 192 } 193 194 199 public Object eGet(EStructuralFeature eFeature, boolean resolve) 200 { 201 switch (eDerivedStructuralFeatureID(eFeature)) 202 { 203 case Ecore2XMLPackage.XML_MAP__IDATTRIBUTE_NAME: 204 return getIDAttributeName(); 205 case Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO: 206 return getEcoreToXMLInfo(); 207 case Ecore2XMLPackage.XML_MAP__NO_NAMESPACE_PACKAGE: 208 if (resolve) return getNoNamespacePackage(); 209 return basicGetNoNamespacePackage(); 210 } 211 return eDynamicGet(eFeature, resolve); 212 } 213 214 219 public void eSet(EStructuralFeature eFeature, Object newValue) 220 { 221 switch (eDerivedStructuralFeatureID(eFeature)) 222 { 223 case Ecore2XMLPackage.XML_MAP__IDATTRIBUTE_NAME: 224 setIDAttributeName((String )newValue); 225 return; 226 case Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO: 227 getEcoreToXMLInfo().clear(); 228 getEcoreToXMLInfo().addAll((Collection )newValue); 229 return; 230 case Ecore2XMLPackage.XML_MAP__NO_NAMESPACE_PACKAGE: 231 setNoNamespacePackage((EPackage)newValue); 232 return; 233 } 234 eDynamicSet(eFeature, newValue); 235 } 236 237 242 public void eUnset(EStructuralFeature eFeature) 243 { 244 switch (eDerivedStructuralFeatureID(eFeature)) 245 { 246 case Ecore2XMLPackage.XML_MAP__IDATTRIBUTE_NAME: 247 setIDAttributeName(IDATTRIBUTE_NAME_EDEFAULT); 248 return; 249 case Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO: 250 getEcoreToXMLInfo().clear(); 251 return; 252 case Ecore2XMLPackage.XML_MAP__NO_NAMESPACE_PACKAGE: 253 setNoNamespacePackage((EPackage)null); 254 return; 255 } 256 eDynamicUnset(eFeature); 257 } 258 259 264 public boolean eIsSet(EStructuralFeature eFeature) 265 { 266 switch (eDerivedStructuralFeatureID(eFeature)) 267 { 268 case Ecore2XMLPackage.XML_MAP__IDATTRIBUTE_NAME: 269 return IDATTRIBUTE_NAME_EDEFAULT == null ? getIDAttributeName() != null : !IDATTRIBUTE_NAME_EDEFAULT.equals(getIDAttributeName()); 270 case Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO: 271 return ecoreToXMLInfo != null && !ecoreToXMLInfo.isEmpty(); 272 case Ecore2XMLPackage.XML_MAP__NO_NAMESPACE_PACKAGE: 273 return basicGetNoNamespacePackage() != null; 274 } 275 return eDynamicIsSet(eFeature); 276 } 277 278 protected class DelegateXMLMapImpl extends org.eclipse.emf.ecore.xmi.impl.XMLMapImpl 279 { 280 protected DelegateXMLMapImpl() 281 { 282 super(); 283 this.ecoreToXMLInfo = XMLMapImpl.this.getEcoreToXMLInfo().map(); 284 } 285 } 286 287 protected XMLResource.XMLMap delegateXMLMap = new DelegateXMLMapImpl(); 288 289 292 public void add(ENamedElement element, XMLResource.XMLInfo info) 293 { 294 delegateXMLMap.add(element, XMLInfo.class.isInstance(info) ? info : new XMLInfoImpl(info)); 295 } 296 297 300 public EClassifier getClassifier(String namespaceURI, String name) 301 { 302 return delegateXMLMap.getClassifier(namespaceURI, name); 303 } 304 305 308 public EStructuralFeature getFeature(EClass eClass, String namespaceURI, String name) 309 { 310 return delegateXMLMap.getFeature(eClass, namespaceURI, name); 311 } 312 313 316 public List getFeatures(EClass eClass) 317 { 318 return delegateXMLMap.getFeatures(eClass); 319 } 320 321 324 public XMLResource.XMLInfo getInfo(ENamedElement element) 325 { 326 return delegateXMLMap.getInfo(element); 327 } 328 329 } | Popular Tags |