1 17 package org.eclipse.emf.mapping.ecore2xml.util; 18 19 import java.util.List ; 20 import java.util.Map ; 21 22 import org.eclipse.emf.ecore.EClass; 23 import org.eclipse.emf.ecore.EObject; 24 import org.eclipse.emf.mapping.ecore2xml.*; 25 26 39 public class Ecore2XMLSwitch { 40 41 47 protected static Ecore2XMLPackage modelPackage; 48 49 55 public Ecore2XMLSwitch() 56 { 57 if (modelPackage == null) 58 { 59 modelPackage = Ecore2XMLPackage.eINSTANCE; 60 } 61 } 62 63 70 public Object doSwitch(EObject theEObject) 71 { 72 return doSwitch(theEObject.eClass(), theEObject); 73 } 74 75 82 protected Object doSwitch(EClass theEClass, EObject theEObject) 83 { 84 if (theEClass.eContainer() == modelPackage) 85 { 86 return doSwitch(theEClass.getClassifierID(), theEObject); 87 } 88 else 89 { 90 List eSuperTypes = theEClass.getESuperTypes(); 91 return 92 eSuperTypes.isEmpty() ? 93 defaultCase(theEObject) : 94 doSwitch((EClass)eSuperTypes.get(0), theEObject); 95 } 96 } 97 98 105 protected Object doSwitch(int classifierID, EObject theEObject) 106 { 107 switch (classifierID) 108 { 109 case Ecore2XMLPackage.XML_INFO: 110 { 111 XMLInfo xmlInfo = (XMLInfo)theEObject; 112 Object result = caseXMLInfo(xmlInfo); 113 if (result == null) result = defaultCase(theEObject); 114 return result; 115 } 116 case Ecore2XMLPackage.XML_MAP: 117 { 118 XMLMap xmlMap = (XMLMap)theEObject; 119 Object result = caseXMLMap(xmlMap); 120 if (result == null) result = defaultCase(theEObject); 121 return result; 122 } 123 case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY: 124 { 125 Map.Entry eNamedElementToXMLInfoMapEntry = (Map.Entry )theEObject; 126 Object result = caseENamedElementToXMLInfoMapEntry(eNamedElementToXMLInfoMapEntry); 127 if (result == null) result = defaultCase(theEObject); 128 return result; 129 } 130 default: return defaultCase(theEObject); 131 } 132 } 133 134 145 public Object caseXMLInfo(XMLInfo object) 146 { 147 return null; 148 } 149 150 161 public Object caseXMLMap(XMLMap object) 162 { 163 return null; 164 } 165 166 177 public Object caseENamedElementToXMLInfoMapEntry(Map.Entry object) 178 { 179 return null; 180 } 181 182 193 public Object defaultCase(EObject object) 194 { 195 return null; 196 } 197 198 } | Popular Tags |