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