KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > mapping > ecore2ecore > util > Ecore2EcoreSwitch


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2004-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: Ecore2EcoreSwitch.java,v 1.5 2005/06/08 06:21:24 nickb Exp $
16  */

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

44 public class Ecore2EcoreSwitch {
45   /**
46    * The cached model package
47    * <!-- begin-user-doc -->
48    * <!-- end-user-doc -->
49    * @generated
50    */

51   protected static Ecore2EcorePackage modelPackage;
52
53   /**
54    * Creates an instance of the switch.
55    * <!-- begin-user-doc -->
56    * <!-- end-user-doc -->
57    * @generated
58    */

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

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

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

109   protected Object JavaDoc doSwitch(int classifierID, EObject theEObject)
110   {
111     switch (classifierID)
112     {
113       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT:
114       {
115         Ecore2EcoreMappingRoot ecore2EcoreMappingRoot = (Ecore2EcoreMappingRoot)theEObject;
116         Object JavaDoc result = caseEcore2EcoreMappingRoot(ecore2EcoreMappingRoot);
117         if (result == null) result = caseMappingRoot(ecore2EcoreMappingRoot);
118         if (result == null) result = caseMapping(ecore2EcoreMappingRoot);
119         if (result == null) result = defaultCase(theEObject);
120         return result;
121       }
122       default: return defaultCase(theEObject);
123     }
124   }
125
126   /**
127    * Returns the result of interpretting the object as an instance of '<em>Mapping Root</em>'.
128    * <!-- begin-user-doc -->
129    * This implementation returns null;
130    * returning a non-null result will terminate the switch.
131    * <!-- end-user-doc -->
132    * @param object the target of the switch.
133    * @return the result of interpretting the object as an instance of '<em>Mapping Root</em>'.
134    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
135    * @generated
136    */

137   public Object JavaDoc caseEcore2EcoreMappingRoot(Ecore2EcoreMappingRoot object)
138   {
139     return null;
140   }
141
142   /**
143    * Returns the result of interpretting the object as an instance of '<em>Mapping</em>'.
144    * <!-- begin-user-doc -->
145    * This implementation returns null;
146    * returning a non-null result will terminate the switch.
147    * <!-- end-user-doc -->
148    * @param object the target of the switch.
149    * @return the result of interpretting the object as an instance of '<em>Mapping</em>'.
150    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
151    * @generated
152    */

153   public Object JavaDoc caseMapping(Mapping object)
154   {
155     return null;
156   }
157
158   /**
159    * Returns the result of interpretting the object as an instance of '<em>Root</em>'.
160    * <!-- begin-user-doc -->
161    * This implementation returns null;
162    * returning a non-null result will terminate the switch.
163    * <!-- end-user-doc -->
164    * @param object the target of the switch.
165    * @return the result of interpretting the object as an instance of '<em>Root</em>'.
166    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
167    * @generated
168    */

169   public Object JavaDoc caseMappingRoot(MappingRoot object)
170   {
171     return null;
172   }
173
174   /**
175    * Returns the result of interpretting the object as an instance of '<em>EObject</em>'.
176    * <!-- begin-user-doc -->
177    * This implementation returns null;
178    * returning a non-null result will terminate the switch, but this is the last case anyway.
179    * <!-- end-user-doc -->
180    * @param object the target of the switch.
181    * @return the result of interpretting the object as an instance of '<em>EObject</em>'.
182    * @see #doSwitch(org.eclipse.emf.ecore.EObject)
183    * @generated
184    */

185   public Object JavaDoc defaultCase(EObject object)
186   {
187     return null;
188   }
189
190 } //Ecore2EcoreSwitch
191
Popular Tags