KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > impl > EOperationImpl


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

17 package org.eclipse.emf.ecore.impl;
18
19
20 import java.util.Collection JavaDoc;
21
22 import org.eclipse.emf.common.notify.NotificationChain;
23 import org.eclipse.emf.common.util.EList;
24 import org.eclipse.emf.ecore.EClass;
25 import org.eclipse.emf.ecore.EClassifier;
26 import org.eclipse.emf.ecore.EOperation;
27 import org.eclipse.emf.ecore.EParameter;
28 import org.eclipse.emf.ecore.EStructuralFeature;
29 import org.eclipse.emf.ecore.EcorePackage;
30 import org.eclipse.emf.ecore.InternalEObject;
31 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
32 import org.eclipse.emf.ecore.util.EObjectResolvingEList;
33 import org.eclipse.emf.ecore.util.InternalEList;
34
35
36 /**
37  * <!-- begin-user-doc -->
38  * An implementation of the model object '<em><b>EOperation</b></em>'.
39  * <!-- end-user-doc -->
40  * <p>
41  * The following features are implemented:
42  * <ul>
43  * <li>{@link org.eclipse.emf.ecore.impl.EOperationImpl#getEContainingClass <em>EContaining Class</em>}</li>
44  * <li>{@link org.eclipse.emf.ecore.impl.EOperationImpl#getEParameters <em>EParameters</em>}</li>
45  * <li>{@link org.eclipse.emf.ecore.impl.EOperationImpl#getEExceptions <em>EExceptions</em>}</li>
46  * </ul>
47  * </p>
48  *
49  * @generated
50  */

51 public class EOperationImpl extends ETypedElementImpl implements EOperation
52 {
53   /**
54    * The cached value of the '{@link #getEParameters() <em>EParameters</em>}' containment reference list.
55    * <!-- begin-user-doc -->
56    * <!-- end-user-doc -->
57    * @see #getEParameters()
58    * @generated
59    * @ordered
60    */

61   protected EList eParameters = null;
62
63   /**
64    * The cached value of the '{@link #getEExceptions() <em>EExceptions</em>}' reference list.
65    * <!-- begin-user-doc -->
66    * <!-- end-user-doc -->
67    * @see #getEExceptions()
68    * @generated
69    * @ordered
70    */

71   protected EList eExceptions = null;
72
73   /**
74    * <!-- begin-user-doc -->
75    * <!-- end-user-doc -->
76    * @generated
77    */

78   protected EOperationImpl()
79   {
80     super();
81   }
82
83   /**
84    * <!-- begin-user-doc -->
85    * <!-- end-user-doc -->
86    * @generated
87    */

88   protected EClass eStaticClass()
89   {
90     return EcorePackage.eINSTANCE.getEOperation();
91   }
92
93   /**
94    * <!-- begin-user-doc -->
95    * <!-- end-user-doc -->
96    * @generated modifiable
97    */

98   public EClass getEContainingClass()
99   {
100     return (eContainerFeatureID == EcorePackage.EOPERATION__ECONTAINING_CLASS) ? (EClass)eContainer : null;
101   }
102
103   /**
104    * <!-- begin-user-doc -->
105    * <!-- end-user-doc -->
106    * @generated
107    */

108   public EList getEParameters()
109   {
110     if (eParameters == null)
111     {
112       eParameters = new EObjectContainmentWithInverseEList(EParameter.class, this, EcorePackage.EOPERATION__EPARAMETERS, EcorePackage.EPARAMETER__EOPERATION);
113     }
114     return eParameters;
115   }
116
117   /**
118    * <!-- begin-user-doc -->
119    * <!-- end-user-doc -->
120    * @generated
121    */

122   public EList getEExceptions()
123   {
124     if (eExceptions == null)
125     {
126       eExceptions = new EObjectResolvingEList(EClassifier.class, this, EcorePackage.EOPERATION__EEXCEPTIONS);
127     }
128     return eExceptions;
129   }
130
131   /**
132    * <!-- begin-user-doc -->
133    * <!-- end-user-doc -->
134    * @generated
135    */

136   public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
137   {
138     if (featureID >= 0)
139     {
140       switch (eDerivedStructuralFeatureID(featureID, baseClass))
141       {
142         case EcorePackage.EOPERATION__EANNOTATIONS:
143           return ((InternalEList)getEAnnotations()).basicAdd(otherEnd, msgs);
144         case EcorePackage.EOPERATION__ECONTAINING_CLASS:
145           if (eContainer != null)
146             msgs = eBasicRemoveFromContainer(msgs);
147           return eBasicSetContainer(otherEnd, EcorePackage.EOPERATION__ECONTAINING_CLASS, msgs);
148         case EcorePackage.EOPERATION__EPARAMETERS:
149           return ((InternalEList)getEParameters()).basicAdd(otherEnd, msgs);
150         default:
151           return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
152       }
153     }
154     if (eContainer != null)
155       msgs = eBasicRemoveFromContainer(msgs);
156     return eBasicSetContainer(otherEnd, featureID, msgs);
157   }
158
159   /**
160    * <!-- begin-user-doc -->
161    * <!-- end-user-doc -->
162    * @generated
163    */

164   public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
165   {
166     if (featureID >= 0)
167     {
168       switch (eDerivedStructuralFeatureID(featureID, baseClass))
169       {
170         case EcorePackage.EOPERATION__EANNOTATIONS:
171           return ((InternalEList)getEAnnotations()).basicRemove(otherEnd, msgs);
172         case EcorePackage.EOPERATION__ECONTAINING_CLASS:
173           return eBasicSetContainer(null, EcorePackage.EOPERATION__ECONTAINING_CLASS, msgs);
174         case EcorePackage.EOPERATION__EPARAMETERS:
175           return ((InternalEList)getEParameters()).basicRemove(otherEnd, msgs);
176         default:
177           return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
178       }
179     }
180     return eBasicSetContainer(null, featureID, msgs);
181   }
182
183   /**
184    * <!-- begin-user-doc -->
185    * <!-- end-user-doc -->
186    * @generated
187    */

188   public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs)
189   {
190     if (eContainerFeatureID >= 0)
191     {
192       switch (eContainerFeatureID)
193       {
194         case EcorePackage.EOPERATION__ECONTAINING_CLASS:
195           return eContainer.eInverseRemove(this, EcorePackage.ECLASS__EOPERATIONS, EClass.class, msgs);
196         default:
197           return eDynamicBasicRemoveFromContainer(msgs);
198       }
199     }
200     return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
201   }
202
203   /**
204    * <!-- begin-user-doc -->
205    * <!-- end-user-doc -->
206    * @generated
207    */

208   public Object JavaDoc eGet(EStructuralFeature eFeature, boolean resolve)
209   {
210     switch (eDerivedStructuralFeatureID(eFeature))
211     {
212       case EcorePackage.EOPERATION__EANNOTATIONS:
213         return getEAnnotations();
214       case EcorePackage.EOPERATION__NAME:
215         return getName();
216       case EcorePackage.EOPERATION__ORDERED:
217         return isOrdered() ? Boolean.TRUE : Boolean.FALSE;
218       case EcorePackage.EOPERATION__UNIQUE:
219         return isUnique() ? Boolean.TRUE : Boolean.FALSE;
220       case EcorePackage.EOPERATION__LOWER_BOUND:
221         return new Integer JavaDoc(getLowerBound());
222       case EcorePackage.EOPERATION__UPPER_BOUND:
223         return new Integer JavaDoc(getUpperBound());
224       case EcorePackage.EOPERATION__MANY:
225         return isMany() ? Boolean.TRUE : Boolean.FALSE;
226       case EcorePackage.EOPERATION__REQUIRED:
227         return isRequired() ? Boolean.TRUE : Boolean.FALSE;
228       case EcorePackage.EOPERATION__ETYPE:
229         if (resolve) return getEType();
230         return basicGetEType();
231       case EcorePackage.EOPERATION__ECONTAINING_CLASS:
232         return getEContainingClass();
233       case EcorePackage.EOPERATION__EPARAMETERS:
234         return getEParameters();
235       case EcorePackage.EOPERATION__EEXCEPTIONS:
236         return getEExceptions();
237     }
238     return eDynamicGet(eFeature, resolve);
239   }
240
241   /**
242    * <!-- begin-user-doc -->
243    * <!-- end-user-doc -->
244    * @generated
245    */

246   public boolean eIsSet(EStructuralFeature eFeature)
247   {
248     switch (eDerivedStructuralFeatureID(eFeature))
249     {
250       case EcorePackage.EOPERATION__EANNOTATIONS:
251         return eAnnotations != null && !eAnnotations.isEmpty();
252       case EcorePackage.EOPERATION__NAME:
253         return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
254       case EcorePackage.EOPERATION__ORDERED:
255         return ((eFlags & ORDERED_EFLAG) != 0) != ORDERED_EDEFAULT;
256       case EcorePackage.EOPERATION__UNIQUE:
257         return ((eFlags & UNIQUE_EFLAG) != 0) != UNIQUE_EDEFAULT;
258       case EcorePackage.EOPERATION__LOWER_BOUND:
259         return lowerBound != LOWER_BOUND_EDEFAULT;
260       case EcorePackage.EOPERATION__UPPER_BOUND:
261         return upperBound != UPPER_BOUND_EDEFAULT;
262       case EcorePackage.EOPERATION__MANY:
263         return isMany() != MANY_EDEFAULT;
264       case EcorePackage.EOPERATION__REQUIRED:
265         return isRequired() != REQUIRED_EDEFAULT;
266       case EcorePackage.EOPERATION__ETYPE:
267         return eType != null;
268       case EcorePackage.EOPERATION__ECONTAINING_CLASS:
269         return getEContainingClass() != null;
270       case EcorePackage.EOPERATION__EPARAMETERS:
271         return eParameters != null && !eParameters.isEmpty();
272       case EcorePackage.EOPERATION__EEXCEPTIONS:
273         return eExceptions != null && !eExceptions.isEmpty();
274     }
275     return eDynamicIsSet(eFeature);
276   }
277
278   /**
279    * <!-- begin-user-doc -->
280    * <!-- end-user-doc -->
281    * @generated
282    */

283   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
284   {
285     switch (eDerivedStructuralFeatureID(eFeature))
286     {
287       case EcorePackage.EOPERATION__EANNOTATIONS:
288         getEAnnotations().clear();
289         getEAnnotations().addAll((Collection JavaDoc)newValue);
290         return;
291       case EcorePackage.EOPERATION__NAME:
292         setName((String JavaDoc)newValue);
293         return;
294       case EcorePackage.EOPERATION__ORDERED:
295         setOrdered(((Boolean JavaDoc)newValue).booleanValue());
296         return;
297       case EcorePackage.EOPERATION__UNIQUE:
298         setUnique(((Boolean JavaDoc)newValue).booleanValue());
299         return;
300       case EcorePackage.EOPERATION__LOWER_BOUND:
301         setLowerBound(((Integer JavaDoc)newValue).intValue());
302         return;
303       case EcorePackage.EOPERATION__UPPER_BOUND:
304         setUpperBound(((Integer JavaDoc)newValue).intValue());
305         return;
306       case EcorePackage.EOPERATION__ETYPE:
307         setEType((EClassifier)newValue);
308         return;
309       case EcorePackage.EOPERATION__EPARAMETERS:
310         getEParameters().clear();
311         getEParameters().addAll((Collection JavaDoc)newValue);
312         return;
313       case EcorePackage.EOPERATION__EEXCEPTIONS:
314         getEExceptions().clear();
315         getEExceptions().addAll((Collection JavaDoc)newValue);
316         return;
317     }
318     eDynamicSet(eFeature, newValue);
319   }
320
321   /**
322    * <!-- begin-user-doc -->
323    * <!-- end-user-doc -->
324    * @generated
325    */

326   public void eUnset(EStructuralFeature eFeature)
327   {
328     switch (eDerivedStructuralFeatureID(eFeature))
329     {
330       case EcorePackage.EOPERATION__EANNOTATIONS:
331         getEAnnotations().clear();
332         return;
333       case EcorePackage.EOPERATION__NAME:
334         setName(NAME_EDEFAULT);
335         return;
336       case EcorePackage.EOPERATION__ORDERED:
337         setOrdered(ORDERED_EDEFAULT);
338         return;
339       case EcorePackage.EOPERATION__UNIQUE:
340         setUnique(UNIQUE_EDEFAULT);
341         return;
342       case EcorePackage.EOPERATION__LOWER_BOUND:
343         setLowerBound(LOWER_BOUND_EDEFAULT);
344         return;
345       case EcorePackage.EOPERATION__UPPER_BOUND:
346         setUpperBound(UPPER_BOUND_EDEFAULT);
347         return;
348       case EcorePackage.EOPERATION__ETYPE:
349         setEType((EClassifier)null);
350         return;
351       case EcorePackage.EOPERATION__EPARAMETERS:
352         getEParameters().clear();
353         return;
354       case EcorePackage.EOPERATION__EEXCEPTIONS:
355         getEExceptions().clear();
356         return;
357     }
358     eDynamicUnset(eFeature);
359   }
360
361 }
362
Popular Tags