KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > edit > tree > util > TreeSwitch


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: TreeSwitch.java,v 1.5 2005/06/08 06:17:06 nickb Exp $
16  */

17 package org.eclipse.emf.edit.tree.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 import org.eclipse.emf.edit.tree.*;
25
26
27 /**
28  * <!-- begin-user-doc -->
29  * The <b>Switch</b> for the model's inheritance hierarchy.
30  * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
31  * to invoke the <code>caseXXX</code> method for each class of the model,
32  * starting with the actual class of the object
33  * and proceeding up the inheritance hierarchy
34  * until a non-null result is returned,
35  * which is the result of the switch.
36  * <!-- end-user-doc -->
37  * @see org.eclipse.emf.edit.tree.TreePackage
38  * @generated
39  */

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

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

55   public TreeSwitch()
56   {
57     if (modelPackage == null)
58     {
59       modelPackage = TreePackage.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 TreePackage.TREE_NODE:
110       {
111         TreeNode treeNode = (TreeNode)theEObject;
112         Object JavaDoc result = caseTreeNode(treeNode);
113         if (result == null) result = defaultCase(theEObject);
114         return result;
115       }
116       default: return defaultCase(theEObject);
117     }
118   }
119
120   /**
121    * Returns the result of interpretting the object as an instance of '<em>Node</em>'.
122    * <!-- begin-user-doc -->
123    * This implementation returns null;
124    * returning a non-null result will terminate the switch.
125    * <!-- end-user-doc -->
126    * @param object the target of the switch.
127    * @return the result of interpretting the object as an instance of '<em>Node</em>'.
128    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
129    * @generated
130    */

131   public Object JavaDoc caseTreeNode(TreeNode object)
132   {
133     return null;
134   }
135
136   /**
137    * Returns the result of interpretting the object as an instance of '<em>EObject</em>'.
138    * <!-- begin-user-doc -->
139    * This implementation returns null;
140    * returning a non-null result will terminate the switch, but this is the last case anyway.
141    * <!-- end-user-doc -->
142    * @param object the target of the switch.
143    * @return the result of interpretting the object as an instance of '<em>EObject</em>'.
144    * @see #doSwitch(org.eclipse.emf.ecore.EObject)
145    * @generated
146    */

147   public Object JavaDoc defaultCase(EObject object)
148   {
149     return null;
150   }
151
152 } //TreeSwitch
153
Popular Tags