001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id: ModelSwitch.java 18807 2006-03-25 01:16:09Z chorner $
006: */package net.refractions.udig.printing.model.util;
007:
008: import java.util.List;
009:
010: import net.refractions.udig.printing.model.Box;
011: import net.refractions.udig.printing.model.Connection;
012: import net.refractions.udig.printing.model.DecoratorBox;
013: import net.refractions.udig.printing.model.Element;
014: import net.refractions.udig.printing.model.ModelPackage;
015: import net.refractions.udig.printing.model.Page;
016: import net.refractions.udig.project.IProjectElement;
017: import net.refractions.udig.project.internal.ProjectElement;
018:
019: import org.eclipse.core.runtime.IAdaptable;
020: import org.eclipse.emf.ecore.EClass;
021: import org.eclipse.emf.ecore.EObject;
022:
023: /**
024: * <!-- begin-user-doc -->
025: * The <b>Switch</b> for the model's inheritance hierarchy.
026: * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
027: * to invoke the <code>caseXXX</code> method for each class of the model,
028: * starting with the actual class of the object
029: * and proceeding up the inheritance hierarchy
030: * until a non-null result is returned,
031: * which is the result of the switch.
032: * <!-- end-user-doc -->
033: * @see net.refractions.udig.printing.model.ModelPackage
034: * @generated
035: */
036: public class ModelSwitch {
037: /**
038: * The cached model package
039: * <!-- begin-user-doc -->
040: * <!-- end-user-doc -->
041: * @generated
042: */
043: protected static ModelPackage modelPackage;
044:
045: /**
046: * Creates an instance of the switch.
047: * <!-- begin-user-doc -->
048: * <!-- end-user-doc -->
049: * @generated
050: */
051: public ModelSwitch() {
052: if (modelPackage == null) {
053: modelPackage = ModelPackage.eINSTANCE;
054: }
055: }
056:
057: /**
058: * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
059: * <!-- begin-user-doc -->
060: * <!-- end-user-doc -->
061: * @return the first non-null result returned by a <code>caseXXX</code> call.
062: * @generated
063: */
064: public Object doSwitch(EObject theEObject) {
065: return doSwitch(theEObject.eClass(), theEObject);
066: }
067:
068: /**
069: * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
070: * <!-- begin-user-doc -->
071: * <!-- end-user-doc -->
072: * @return the first non-null result returned by a <code>caseXXX</code> call.
073: * @generated
074: */
075: protected Object doSwitch(EClass theEClass, EObject theEObject) {
076: if (theEClass.eContainer() == modelPackage) {
077: return doSwitch(theEClass.getClassifierID(), theEObject);
078: } else {
079: List eSuperTypes = theEClass.getESuperTypes();
080: return eSuperTypes.isEmpty() ? defaultCase(theEObject)
081: : doSwitch((EClass) eSuperTypes.get(0), theEObject);
082: }
083: }
084:
085: /**
086: * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
087: * <!-- begin-user-doc -->
088: * <!-- end-user-doc -->
089: * @return the first non-null result returned by a <code>caseXXX</code> call.
090: * @generated
091: */
092: protected Object doSwitch(int classifierID, EObject theEObject) {
093: switch (classifierID) {
094: case ModelPackage.BOX: {
095: Box box = (Box) theEObject;
096: Object result = caseBox(box);
097: if (result == null)
098: result = caseElement(box);
099: if (result == null)
100: result = defaultCase(theEObject);
101: return result;
102: }
103: case ModelPackage.CONNECTION: {
104: Connection connection = (Connection) theEObject;
105: Object result = caseConnection(connection);
106: if (result == null)
107: result = caseElement(connection);
108: if (result == null)
109: result = defaultCase(theEObject);
110: return result;
111: }
112: case ModelPackage.DECORATOR_BOX: {
113: DecoratorBox decoratorBox = (DecoratorBox) theEObject;
114: Object result = caseDecoratorBox(decoratorBox);
115: if (result == null)
116: result = caseBox(decoratorBox);
117: if (result == null)
118: result = caseElement(decoratorBox);
119: if (result == null)
120: result = defaultCase(theEObject);
121: return result;
122: }
123: case ModelPackage.ELEMENT: {
124: Element element = (Element) theEObject;
125: Object result = caseElement(element);
126: if (result == null)
127: result = defaultCase(theEObject);
128: return result;
129: }
130: case ModelPackage.PAGE: {
131: Page page = (Page) theEObject;
132: Object result = casePage(page);
133: if (result == null)
134: result = caseElement(page);
135: if (result == null)
136: result = caseProjectElement(page);
137: if (result == null)
138: result = caseIProjectElement(page);
139: if (result == null)
140: result = caseIAdaptable(page);
141: if (result == null)
142: result = defaultCase(theEObject);
143: return result;
144: }
145: default:
146: return defaultCase(theEObject);
147: }
148: }
149:
150: /**
151: * Returns the result of interpretting the object as an instance of '<em>Box</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>Box</em>'.
158: * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
159: * @generated
160: */
161: public Object caseBox(Box object) {
162: return null;
163: }
164:
165: /**
166: * Returns the result of interpretting the object as an instance of '<em>Connection</em>'.
167: * <!-- begin-user-doc -->
168: * This implementation returns null;
169: * returning a non-null result will terminate the switch.
170: * <!-- end-user-doc -->
171: * @param object the target of the switch.
172: * @return the result of interpretting the object as an instance of '<em>Connection</em>'.
173: * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
174: * @generated
175: */
176: public Object caseConnection(Connection object) {
177: return null;
178: }
179:
180: /**
181: * Returns the result of interpretting the object as an instance of '<em>Decorator Box</em>'.
182: * <!-- begin-user-doc -->
183: * This implementation returns null;
184: * returning a non-null result will terminate the switch.
185: * <!-- end-user-doc -->
186: * @param object the target of the switch.
187: * @return the result of interpretting the object as an instance of '<em>Decorator Box</em>'.
188: * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
189: * @generated
190: */
191: public Object caseDecoratorBox(DecoratorBox object) {
192: return null;
193: }
194:
195: /**
196: * Returns the result of interpretting the object as an instance of '<em>Element</em>'.
197: * <!-- begin-user-doc -->
198: * This implementation returns null;
199: * returning a non-null result will terminate the switch.
200: * <!-- end-user-doc -->
201: * @param object the target of the switch.
202: * @return the result of interpretting the object as an instance of '<em>Element</em>'.
203: * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
204: * @generated
205: */
206: public Object caseElement(Element object) {
207: return null;
208: }
209:
210: /**
211: * Returns the result of interpretting the object as an instance of '<em>Page</em>'.
212: * <!-- begin-user-doc -->
213: * This implementation returns null;
214: * returning a non-null result will terminate the switch.
215: * <!-- end-user-doc -->
216: * @param object the target of the switch.
217: * @return the result of interpretting the object as an instance of '<em>Page</em>'.
218: * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
219: * @generated
220: */
221: public Object casePage(Page object) {
222: return null;
223: }
224:
225: /**
226: * Returns the result of interpretting the object as an instance of '<em>IProject Element</em>'.
227: * <!-- begin-user-doc -->
228: * This implementation returns null;
229: * returning a non-null result will terminate the switch.
230: * <!-- end-user-doc -->
231: * @param object the target of the switch.
232: * @return the result of interpretting the object as an instance of '<em>IProject Element</em>'.
233: * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
234: * @generated
235: */
236: public Object caseIProjectElement(IProjectElement object) {
237: return null;
238: }
239:
240: /**
241: * Returns the result of interpretting the object as an instance of '<em>IAdaptable</em>'.
242: * <!-- begin-user-doc -->
243: * This implementation returns null;
244: * returning a non-null result will terminate the switch.
245: * <!-- end-user-doc -->
246: * @param object the target of the switch.
247: * @return the result of interpretting the object as an instance of '<em>IAdaptable</em>'.
248: * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
249: * @generated
250: */
251: public Object caseIAdaptable(IAdaptable object) {
252: return null;
253: }
254:
255: /**
256: * Returns the result of interpretting the object as an instance of '<em>Element</em>'.
257: * <!-- begin-user-doc -->
258: * This implementation returns null;
259: * returning a non-null result will terminate the switch.
260: * <!-- end-user-doc -->
261: * @param object the target of the switch.
262: * @return the result of interpretting the object as an instance of '<em>Element</em>'.
263: * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
264: * @generated
265: */
266: public Object caseProjectElement(ProjectElement object) {
267: return null;
268: }
269:
270: /**
271: * Returns the result of interpretting the object as an instance of '<em>EObject</em>'.
272: * <!-- begin-user-doc -->
273: * This implementation returns null;
274: * returning a non-null result will terminate the switch, but this is the last case anyway.
275: * <!-- end-user-doc -->
276: * @param object the target of the switch.
277: * @return the result of interpretting the object as an instance of '<em>EObject</em>'.
278: * @see #doSwitch(org.eclipse.emf.ecore.EObject)
279: * @generated
280: */
281: public Object defaultCase(EObject object) {
282: return null;
283: }
284:
285: } //ModelSwitch
|