imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/model/iContent/util/IContentSwitch.java
author dpodwall
Tue, 12 Jan 2010 13:17:53 -0600
changeset 0 61163b28edca
permissions -rw-r--r--
initial EPL conversion
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     1
/*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     3
* All rights reserved.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     4
* This component and the accompanying materials are made available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     6
* which accompanies this distribution, and is available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     8
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     9
* Initial Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    11
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    12
* Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    13
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    14
* Description:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    15
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    16
*/
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    17
package com.nokia.s60tools.imaker.internal.model.iContent.util;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    18
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    19
import com.nokia.s60tools.imaker.internal.model.iContent.*;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    20
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    21
import java.util.List;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    22
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    23
import org.eclipse.emf.ecore.EClass;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    24
import org.eclipse.emf.ecore.EObject;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    25
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    26
/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    27
 * <!-- begin-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    28
 * The <b>Switch</b> for the model's inheritance hierarchy.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    29
 * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    30
 * to invoke the <code>caseXXX</code> method for each class of the model,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    31
 * starting with the actual class of the object
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    32
 * and proceeding up the inheritance hierarchy
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    33
 * until a non-null result is returned,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    34
 * which is the result of the switch.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    35
 * <!-- end-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    36
 * @see com.nokia.s60tools.imaker.internal.model.iContent.IContentPackage
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    37
 * @generated
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    38
 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    39
public class IContentSwitch<T> {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    40
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    41
	 * The cached model package
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    42
	 * <!-- begin-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    43
	 * <!-- end-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    44
	 * @generated
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    45
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    46
	protected static IContentPackage modelPackage;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    47
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    48
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    49
	 * Creates an instance of the switch.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    50
	 * <!-- begin-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    51
	 * <!-- end-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    52
	 * @generated
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    53
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    54
	public IContentSwitch() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    55
		if (modelPackage == null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    56
			modelPackage = IContentPackage.eINSTANCE;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    57
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    58
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    59
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    60
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    61
	 * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    62
	 * <!-- begin-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    63
	 * <!-- end-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    64
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    65
	 * @generated
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    66
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    67
	public T doSwitch(EObject theEObject) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    68
		return doSwitch(theEObject.eClass(), theEObject);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    69
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    70
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    71
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    72
	 * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    73
	 * <!-- begin-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    74
	 * <!-- end-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    75
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    76
	 * @generated
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    77
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    78
	protected T doSwitch(EClass theEClass, EObject theEObject) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    79
		if (theEClass.eContainer() == modelPackage) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    80
			return doSwitch(theEClass.getClassifierID(), theEObject);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    81
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    82
		else {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    83
			List<EClass> eSuperTypes = theEClass.getESuperTypes();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    84
			return
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    85
				eSuperTypes.isEmpty() ?
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    86
					defaultCase(theEObject) :
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    87
					doSwitch(eSuperTypes.get(0), theEObject);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    88
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    89
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    90
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    91
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    92
	 * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    93
	 * <!-- begin-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    94
	 * <!-- end-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    95
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    96
	 * @generated
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    97
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    98
	protected T doSwitch(int classifierID, EObject theEObject) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    99
		switch (classifierID) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   100
			case IContentPackage.IMAGE_CONTENT: {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   101
				ImageContent imageContent = (ImageContent)theEObject;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   102
				T result = caseImageContent(imageContent);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   103
				if (result == null) result = defaultCase(theEObject);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   104
				return result;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   105
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   106
			case IContentPackage.IBY_ENTRY: {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   107
				IbyEntry ibyEntry = (IbyEntry)theEObject;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   108
				T result = caseIbyEntry(ibyEntry);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   109
				if (result == null) result = defaultCase(theEObject);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   110
				return result;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   111
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   112
			default: return defaultCase(theEObject);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   113
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   114
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   115
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   116
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   117
	 * Returns the result of interpreting the object as an instance of '<em>Image Content</em>'.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   118
	 * <!-- begin-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   119
	 * This implementation returns null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   120
	 * returning a non-null result will terminate the switch.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   121
	 * <!-- end-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   122
	 * @param object the target of the switch.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   123
	 * @return the result of interpreting the object as an instance of '<em>Image Content</em>'.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   124
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   125
	 * @generated
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   126
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   127
	public T caseImageContent(ImageContent object) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   128
		return null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   129
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   130
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   131
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   132
	 * Returns the result of interpreting the object as an instance of '<em>Iby Entry</em>'.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   133
	 * <!-- begin-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   134
	 * This implementation returns null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   135
	 * returning a non-null result will terminate the switch.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   136
	 * <!-- end-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   137
	 * @param object the target of the switch.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   138
	 * @return the result of interpreting the object as an instance of '<em>Iby Entry</em>'.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   139
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   140
	 * @generated
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   141
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   142
	public T caseIbyEntry(IbyEntry object) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   143
		return null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   144
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   145
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   146
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   147
	 * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   148
	 * <!-- begin-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   149
	 * This implementation returns null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   150
	 * returning a non-null result will terminate the switch, but this is the last case anyway.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   151
	 * <!-- end-user-doc -->
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   152
	 * @param object the target of the switch.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   153
	 * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   154
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   155
	 * @generated
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   156
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   157
	public T defaultCase(EObject object) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   158
		return null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   159
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   160
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   161
} //IContentSwitch