1 17 package org.eclipse.emf.edit.tree.util; 18 19 20 import java.util.List ; 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 40 public class TreeSwitch { 41 47 protected static TreePackage modelPackage; 48 49 55 public TreeSwitch() 56 { 57 if (modelPackage == null) 58 { 59 modelPackage = TreePackage.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 TreePackage.TREE_NODE: 110 { 111 TreeNode treeNode = (TreeNode)theEObject; 112 Object result = caseTreeNode(treeNode); 113 if (result == null) result = defaultCase(theEObject); 114 return result; 115 } 116 default: return defaultCase(theEObject); 117 } 118 } 119 120 131 public Object caseTreeNode(TreeNode object) 132 { 133 return null; 134 } 135 136 147 public Object defaultCase(EObject object) 148 { 149 return null; 150 } 151 152 } | Popular Tags |