KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > util > EcoreSwitch


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 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: EcoreSwitch.java,v 1.8 2005/06/08 06:20:10 nickb Exp $
16  */

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

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

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

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

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

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

107   protected Object JavaDoc doSwitch(int classifierID, EObject theEObject)
108   {
109     switch (classifierID)
110     {
111       case EcorePackage.EATTRIBUTE:
112       {
113         EAttribute eAttribute = (EAttribute)theEObject;
114         Object JavaDoc result = caseEAttribute(eAttribute);
115         if (result == null) result = caseEStructuralFeature(eAttribute);
116         if (result == null) result = caseETypedElement(eAttribute);
117         if (result == null) result = caseENamedElement(eAttribute);
118         if (result == null) result = caseEModelElement(eAttribute);
119         if (result == null) result = defaultCase(theEObject);
120         return result;
121       }
122       case EcorePackage.EANNOTATION:
123       {
124         EAnnotation eAnnotation = (EAnnotation)theEObject;
125         Object JavaDoc result = caseEAnnotation(eAnnotation);
126         if (result == null) result = caseEModelElement(eAnnotation);
127         if (result == null) result = defaultCase(theEObject);
128         return result;
129       }
130       case EcorePackage.ECLASS:
131       {
132         EClass eClass = (EClass)theEObject;
133         Object JavaDoc result = caseEClass(eClass);
134         if (result == null) result = caseEClassifier(eClass);
135         if (result == null) result = caseENamedElement(eClass);
136         if (result == null) result = caseEModelElement(eClass);
137         if (result == null) result = defaultCase(theEObject);
138         return result;
139       }
140       case EcorePackage.ECLASSIFIER:
141       {
142         EClassifier eClassifier = (EClassifier)theEObject;
143         Object JavaDoc result = caseEClassifier(eClassifier);
144         if (result == null) result = caseENamedElement(eClassifier);
145         if (result == null) result = caseEModelElement(eClassifier);
146         if (result == null) result = defaultCase(theEObject);
147         return result;
148       }
149       case EcorePackage.EDATA_TYPE:
150       {
151         EDataType eDataType = (EDataType)theEObject;
152         Object JavaDoc result = caseEDataType(eDataType);
153         if (result == null) result = caseEClassifier(eDataType);
154         if (result == null) result = caseENamedElement(eDataType);
155         if (result == null) result = caseEModelElement(eDataType);
156         if (result == null) result = defaultCase(theEObject);
157         return result;
158       }
159       case EcorePackage.EENUM:
160       {
161         EEnum eEnum = (EEnum)theEObject;
162         Object JavaDoc result = caseEEnum(eEnum);
163         if (result == null) result = caseEDataType(eEnum);
164         if (result == null) result = caseEClassifier(eEnum);
165         if (result == null) result = caseENamedElement(eEnum);
166         if (result == null) result = caseEModelElement(eEnum);
167         if (result == null) result = defaultCase(theEObject);
168         return result;
169       }
170       case EcorePackage.EENUM_LITERAL:
171       {
172         EEnumLiteral eEnumLiteral = (EEnumLiteral)theEObject;
173         Object JavaDoc result = caseEEnumLiteral(eEnumLiteral);
174         if (result == null) result = caseENamedElement(eEnumLiteral);
175         if (result == null) result = caseEModelElement(eEnumLiteral);
176         if (result == null) result = defaultCase(theEObject);
177         return result;
178       }
179       case EcorePackage.EFACTORY:
180       {
181         EFactory eFactory = (EFactory)theEObject;
182         Object JavaDoc result = caseEFactory(eFactory);
183         if (result == null) result = caseEModelElement(eFactory);
184         if (result == null) result = defaultCase(theEObject);
185         return result;
186       }
187       case EcorePackage.EMODEL_ELEMENT:
188       {
189         EModelElement eModelElement = (EModelElement)theEObject;
190         Object JavaDoc result = caseEModelElement(eModelElement);
191         if (result == null) result = defaultCase(theEObject);
192         return result;
193       }
194       case EcorePackage.ENAMED_ELEMENT:
195       {
196         ENamedElement eNamedElement = (ENamedElement)theEObject;
197         Object JavaDoc result = caseENamedElement(eNamedElement);
198         if (result == null) result = caseEModelElement(eNamedElement);
199         if (result == null) result = defaultCase(theEObject);
200         return result;
201       }
202       case EcorePackage.EOPERATION:
203       {
204         EOperation eOperation = (EOperation)theEObject;
205         Object JavaDoc result = caseEOperation(eOperation);
206         if (result == null) result = caseETypedElement(eOperation);
207         if (result == null) result = caseENamedElement(eOperation);
208         if (result == null) result = caseEModelElement(eOperation);
209         if (result == null) result = defaultCase(theEObject);
210         return result;
211       }
212       case EcorePackage.EPACKAGE:
213       {
214         EPackage ePackage = (EPackage)theEObject;
215         Object JavaDoc result = caseEPackage(ePackage);
216         if (result == null) result = caseENamedElement(ePackage);
217         if (result == null) result = caseEModelElement(ePackage);
218         if (result == null) result = defaultCase(theEObject);
219         return result;
220       }
221       case EcorePackage.EPARAMETER:
222       {
223         EParameter eParameter = (EParameter)theEObject;
224         Object JavaDoc result = caseEParameter(eParameter);
225         if (result == null) result = caseETypedElement(eParameter);
226         if (result == null) result = caseENamedElement(eParameter);
227         if (result == null) result = caseEModelElement(eParameter);
228         if (result == null) result = defaultCase(theEObject);
229         return result;
230       }
231       case EcorePackage.EREFERENCE:
232       {
233         EReference eReference = (EReference)theEObject;
234         Object JavaDoc result = caseEReference(eReference);
235         if (result == null) result = caseEStructuralFeature(eReference);
236         if (result == null) result = caseETypedElement(eReference);
237         if (result == null) result = caseENamedElement(eReference);
238         if (result == null) result = caseEModelElement(eReference);
239         if (result == null) result = defaultCase(theEObject);
240         return result;
241       }
242       case EcorePackage.ESTRUCTURAL_FEATURE:
243       {
244         EStructuralFeature eStructuralFeature = (EStructuralFeature)theEObject;
245         Object JavaDoc result = caseEStructuralFeature(eStructuralFeature);
246         if (result == null) result = caseETypedElement(eStructuralFeature);
247         if (result == null) result = caseENamedElement(eStructuralFeature);
248         if (result == null) result = caseEModelElement(eStructuralFeature);
249         if (result == null) result = defaultCase(theEObject);
250         return result;
251       }
252       case EcorePackage.ETYPED_ELEMENT:
253       {
254         ETypedElement eTypedElement = (ETypedElement)theEObject;
255         Object JavaDoc result = caseETypedElement(eTypedElement);
256         if (result == null) result = caseENamedElement(eTypedElement);
257         if (result == null) result = caseEModelElement(eTypedElement);
258         if (result == null) result = defaultCase(theEObject);
259         return result;
260       }
261       case EcorePackage.ESTRING_TO_STRING_MAP_ENTRY:
262       {
263         Map.Entry JavaDoc eStringToStringMapEntry = (Map.Entry JavaDoc)theEObject;
264         Object JavaDoc result = caseEStringToStringMapEntry(eStringToStringMapEntry);
265         if (result == null) result = defaultCase(theEObject);
266         return result;
267       }
268       default: return defaultCase(theEObject);
269     }
270   }
271
272   /**
273    * Returns the result of interpretting the object as an instance of '<em>EModel Element</em>'.
274    * <!-- begin-user-doc -->
275    * This implementation returns null;
276    * returning a non-null result will terminate the switch.
277    * <!-- end-user-doc -->
278    * @param object the target of the switch.
279    * @return the result of interpretting the object as an instance of '<em>EModel Element</em>'.
280    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
281    * @generated
282    */

283   public Object JavaDoc caseEModelElement(EModelElement object)
284   {
285     return null;
286   }
287
288   /**
289    * Returns the result of interpretting the object as an instance of '<em>EStructural Feature</em>'.
290    * <!-- begin-user-doc -->
291    * This implementation returns null;
292    * returning a non-null result will terminate the switch.
293    * <!-- end-user-doc -->
294    * @param object the target of the switch.
295    * @return the result of interpretting the object as an instance of '<em>EStructural Feature</em>'.
296    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
297    * @generated
298    */

299   public Object JavaDoc caseEStructuralFeature(EStructuralFeature object)
300   {
301     return null;
302   }
303
304   /**
305    * Returns the result of interpretting the object as an instance of '<em>EAnnotation</em>'.
306    * <!-- begin-user-doc -->
307    * This implementation returns null;
308    * returning a non-null result will terminate the switch.
309    * <!-- end-user-doc -->
310    * @param object the target of the switch.
311    * @return the result of interpretting the object as an instance of '<em>EAnnotation</em>'.
312    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
313    * @generated
314    */

315   public Object JavaDoc caseEAnnotation(EAnnotation object)
316   {
317     return null;
318   }
319
320   /**
321    * Returns the result of interpretting the object as an instance of '<em>EAttribute</em>'.
322    * <!-- begin-user-doc -->
323    * This implementation returns null;
324    * returning a non-null result will terminate the switch.
325    * <!-- end-user-doc -->
326    * @param object the target of the switch.
327    * @return the result of interpretting the object as an instance of '<em>EAttribute</em>'.
328    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
329    * @generated
330    */

331   public Object JavaDoc caseEAttribute(EAttribute object)
332   {
333     return null;
334   }
335
336   /**
337    * Returns the result of interpretting the object as an instance of '<em>EClass</em>'.
338    * <!-- begin-user-doc -->
339    * This implementation returns null;
340    * returning a non-null result will terminate the switch.
341    * <!-- end-user-doc -->
342    * @param object the target of the switch.
343    * @return the result of interpretting the object as an instance of '<em>EClass</em>'.
344    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
345    * @generated
346    */

347   public Object JavaDoc caseEClass(EClass object)
348   {
349     return null;
350   }
351
352   /**
353    * Returns the result of interpretting the object as an instance of '<em>EData Type</em>'.
354    * <!-- begin-user-doc -->
355    * This implementation returns null;
356    * returning a non-null result will terminate the switch.
357    * <!-- end-user-doc -->
358    * @param object the target of the switch.
359    * @return the result of interpretting the object as an instance of '<em>EData Type</em>'.
360    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
361    * @generated
362    */

363   public Object JavaDoc caseEDataType(EDataType object)
364   {
365     return null;
366   }
367
368   /**
369    * Returns the result of interpretting the object as an instance of '<em>EClassifier</em>'.
370    * <!-- begin-user-doc -->
371    * This implementation returns null;
372    * returning a non-null result will terminate the switch.
373    * <!-- end-user-doc -->
374    * @param object the target of the switch.
375    * @return the result of interpretting the object as an instance of '<em>EClassifier</em>'.
376    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
377    * @generated
378    */

379   public Object JavaDoc caseEClassifier(EClassifier object)
380   {
381     return null;
382   }
383
384   /**
385    * Returns the result of interpretting the object as an instance of '<em>ENamed Element</em>'.
386    * <!-- begin-user-doc -->
387    * This implementation returns null;
388    * returning a non-null result will terminate the switch.
389    * <!-- end-user-doc -->
390    * @param object the target of the switch.
391    * @return the result of interpretting the object as an instance of '<em>ENamed Element</em>'.
392    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
393    * @generated
394    */

395   public Object JavaDoc caseENamedElement(ENamedElement object)
396   {
397     return null;
398   }
399
400   /**
401    * Returns the result of interpretting the object as an instance of '<em>EObject</em>'.
402    * <!-- begin-user-doc -->
403    * This implementation returns null;
404    * returning a non-null result will terminate the switch, but this is the last case anyway.
405    * <!-- end-user-doc -->
406    * @param object the target of the switch.
407    * @return the result of interpretting the object as an instance of '<em>EObject</em>'.
408    * @see #doSwitch(org.eclipse.emf.ecore.EObject)
409    * @generated
410    */

411   public Object JavaDoc defaultCase(EObject object)
412   {
413     return null;
414   }
415
416   /**
417    * Returns the result of interpretting the object as an instance of '<em>ETyped Element</em>'.
418    * <!-- begin-user-doc -->
419    * This implementation returns null;
420    * returning a non-null result will terminate the switch.
421    * <!-- end-user-doc -->
422    * @param object the target of the switch.
423    * @return the result of interpretting the object as an instance of '<em>ETyped Element</em>'.
424    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
425    * @generated
426    */

427   public Object JavaDoc caseETypedElement(ETypedElement object)
428   {
429     return null;
430   }
431
432   /**
433    * Returns the result of interpretting the object as an instance of '<em>EParameter</em>'.
434    * <!-- begin-user-doc -->
435    * This implementation returns null;
436    * returning a non-null result will terminate the switch.
437    * <!-- end-user-doc -->
438    * @param object the target of the switch.
439    * @return the result of interpretting the object as an instance of '<em>EParameter</em>'.
440    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
441    * @generated
442    */

443   public Object JavaDoc caseEParameter(EParameter object)
444   {
445     return null;
446   }
447
448   /**
449    * Returns the result of interpretting the object as an instance of '<em>EOperation</em>'.
450    * <!-- begin-user-doc -->
451    * This implementation returns null;
452    * returning a non-null result will terminate the switch.
453    * <!-- end-user-doc -->
454    * @param object the target of the switch.
455    * @return the result of interpretting the object as an instance of '<em>EOperation</em>'.
456    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
457    * @generated
458    */

459   public Object JavaDoc caseEOperation(EOperation object)
460   {
461     return null;
462   }
463
464   /**
465    * Returns the result of interpretting the object as an instance of '<em>EPackage</em>'.
466    * <!-- begin-user-doc -->
467    * This implementation returns null;
468    * returning a non-null result will terminate the switch.
469    * <!-- end-user-doc -->
470    * @param object the target of the switch.
471    * @return the result of interpretting the object as an instance of '<em>EPackage</em>'.
472    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
473    * @generated
474    */

475   public Object JavaDoc caseEPackage(EPackage object)
476   {
477     return null;
478   }
479
480   /**
481    * Returns the result of interpretting the object as an instance of '<em>EFactory</em>'.
482    * <!-- begin-user-doc -->
483    * This implementation returns null;
484    * returning a non-null result will terminate the switch.
485    * <!-- end-user-doc -->
486    * @param object the target of the switch.
487    * @return the result of interpretting the object as an instance of '<em>EFactory</em>'.
488    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
489    * @generated
490    */

491   public Object JavaDoc caseEFactory(EFactory object)
492   {
493     return null;
494   }
495
496   /**
497    * Returns the result of interpretting the object as an instance of '<em>EEnum Literal</em>'.
498    * <!-- begin-user-doc -->
499    * This implementation returns null;
500    * returning a non-null result will terminate the switch.
501    * <!-- end-user-doc -->
502    * @param object the target of the switch.
503    * @return the result of interpretting the object as an instance of '<em>EEnum Literal</em>'.
504    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
505    * @generated
506    */

507   public Object JavaDoc caseEEnumLiteral(EEnumLiteral object)
508   {
509     return null;
510   }
511
512   /**
513    * Returns the result of interpretting the object as an instance of '<em>EEnum</em>'.
514    * <!-- begin-user-doc -->
515    * This implementation returns null;
516    * returning a non-null result will terminate the switch.
517    * <!-- end-user-doc -->
518    * @param object the target of the switch.
519    * @return the result of interpretting the object as an instance of '<em>EEnum</em>'.
520    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
521    * @generated
522    */

523   public Object JavaDoc caseEEnum(EEnum object)
524   {
525     return null;
526   }
527
528   /**
529    * Returns the result of interpretting the object as an instance of '<em>EReference</em>'.
530    * <!-- begin-user-doc -->
531    * This implementation returns null;
532    * returning a non-null result will terminate the switch.
533    * <!-- end-user-doc -->
534    * @param object the target of the switch.
535    * @return the result of interpretting the object as an instance of '<em>EReference</em>'.
536    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
537    * @generated
538    */

539   public Object JavaDoc caseEReference(EReference object)
540   {
541     return null;
542   }
543
544   /**
545    * Returns the result of interpretting the object as an instance of '<em>EString To String Map Entry</em>'.
546    * <!-- begin-user-doc -->
547    * This implementation returns null;
548    * returning a non-null result will terminate the switch.
549    * <!-- end-user-doc -->
550    * @param object the target of the switch.
551    * @return the result of interpretting the object as an instance of '<em>EString To String Map Entry</em>'.
552    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
553    * @generated
554    */

555   public Object JavaDoc caseEStringToStringMapEntry(Map.Entry JavaDoc object)
556   {
557     return null;
558   }
559
560 } //EcoreSwitch
561
Popular Tags