KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > mapping > ecore2xml > util > Ecore2XMLSwitch


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2005 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: Ecore2XMLSwitch.java,v 1.2 2005/06/21 16:17:03 khussey Exp $
16  */

17 package org.eclipse.emf.mapping.ecore2xml.util;
18
19 import java.util.List JavaDoc;
20 import java.util.Map JavaDoc;
21
22 import org.eclipse.emf.ecore.EClass;
23 import org.eclipse.emf.ecore.EObject;
24 import org.eclipse.emf.mapping.ecore2xml.*;
25
26 /**
27  * <!-- begin-user-doc -->
28  * The <b>Switch</b> for the model's inheritance hierarchy.
29  * It supports the call {@link #doSwitch doSwitch(object)}
30  * to invoke the <code>caseXXX</code> method for each class of the model,
31  * starting with the actual class of the object
32  * and proceeding up the inheritance hierarchy
33  * until a non-null result is returned,
34  * which is the result of the switch.
35  * <!-- end-user-doc -->
36  * @see org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage
37  * @generated
38  */

39 public class Ecore2XMLSwitch {
40   
41   /**
42    * The cached model package
43    * <!-- begin-user-doc -->
44    * <!-- end-user-doc -->
45    * @generated
46    */

47   protected static Ecore2XMLPackage modelPackage;
48   
49   /**
50    * Creates an instance of the switch.
51    * <!-- begin-user-doc -->
52    * <!-- end-user-doc -->
53    * @generated
54    */

55   public Ecore2XMLSwitch()
56   {
57     if (modelPackage == null)
58     {
59       modelPackage = Ecore2XMLPackage.eINSTANCE;
60     }
61   }
62
63   /**
64    * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
65    * <!-- begin-user-doc -->
66    * <!-- end-user-doc -->
67    * @return the first non-null result returned by a <code>caseXXX</code> call.
68    * @generated
69    */

70   public Object JavaDoc doSwitch(EObject theEObject)
71   {
72     return doSwitch(theEObject.eClass(), theEObject);
73   }
74
75   /**
76    * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
77    * <!-- begin-user-doc -->
78    * <!-- end-user-doc -->
79    * @return the first non-null result returned by a <code>caseXXX</code> call.
80    * @generated
81    */

82   protected Object JavaDoc doSwitch(EClass theEClass, EObject theEObject)
83   {
84     if (theEClass.eContainer() == modelPackage)
85     {
86       return doSwitch(theEClass.getClassifierID(), theEObject);
87     }
88     else
89     {
90       List JavaDoc eSuperTypes = theEClass.getESuperTypes();
91       return
92         eSuperTypes.isEmpty() ?
93           defaultCase(theEObject) :
94           doSwitch((EClass)eSuperTypes.get(0), theEObject);
95     }
96   }
97
98   /**
99    * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
100    * <!-- begin-user-doc -->
101    * <!-- end-user-doc -->
102    * @return the first non-null result returned by a <code>caseXXX</code> call.
103    * @generated
104    */

105   protected Object JavaDoc doSwitch(int classifierID, EObject theEObject)
106   {
107     switch (classifierID)
108     {
109       case Ecore2XMLPackage.XML_INFO:
110       {
111         XMLInfo xmlInfo = (XMLInfo)theEObject;
112         Object JavaDoc 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 JavaDoc 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 JavaDoc eNamedElementToXMLInfoMapEntry = (Map.Entry JavaDoc)theEObject;
126         Object JavaDoc result = caseENamedElementToXMLInfoMapEntry(eNamedElementToXMLInfoMapEntry);
127         if (result == null) result = defaultCase(theEObject);
128         return result;
129       }
130       default: return defaultCase(theEObject);
131     }
132   }
133
134   /**
135    * Returns the result of interpretting the object as an instance of '<em>XML Info</em>'.
136    * <!-- begin-user-doc -->
137    * This implementation returns null;
138    * returning a non-null result will terminate the switch.
139    * <!-- end-user-doc -->
140    * @param object the target of the switch.
141    * @return the result of interpretting the object as an instance of '<em>XML Info</em>'.
142    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
143    * @generated
144    */

145   public Object JavaDoc caseXMLInfo(XMLInfo object)
146   {
147     return null;
148   }
149
150   /**
151    * Returns the result of interpretting the object as an instance of '<em>XML Map</em>'.
152    * <!-- begin-user-doc -->
153    * This implementation returns null;
154    * returning a non-null result will terminate the switch.
155    * <!-- end-user-doc -->
156    * @param object the target of the switch.
157    * @return the result of interpretting the object as an instance of '<em>XML Map</em>'.
158    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
159    * @generated
160    */

161   public Object JavaDoc caseXMLMap(XMLMap object)
162   {
163     return null;
164   }
165
166   /**
167    * Returns the result of interpretting the object as an instance of '<em>ENamed Element To XML Info Map Entry</em>'.
168    * <!-- begin-user-doc -->
169    * This implementation returns null;
170    * returning a non-null result will terminate the switch.
171    * <!-- end-user-doc -->
172    * @param object the target of the switch.
173    * @return the result of interpretting the object as an instance of '<em>ENamed Element To XML Info Map Entry</em>'.
174    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
175    * @generated
176    */

177   public Object JavaDoc caseENamedElementToXMLInfoMapEntry(Map.Entry JavaDoc object)
178   {
179     return null;
180   }
181
182   /**
183    * Returns the result of interpretting the object as an instance of '<em>EObject</em>'.
184    * <!-- begin-user-doc -->
185    * This implementation returns null;
186    * returning a non-null result will terminate the switch, but this is the last case anyway.
187    * <!-- end-user-doc -->
188    * @param object the target of the switch.
189    * @return the result of interpretting the object as an instance of '<em>EObject</em>'.
190    * @see #doSwitch(org.eclipse.emf.ecore.EObject)
191    * @generated
192    */

193   public Object JavaDoc defaultCase(EObject object)
194   {
195     return null;
196   }
197
198 } //Ecore2XMLSwitch
199
Popular Tags