KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2005 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: EStructuralFeatureImpl.java,v 1.12 2005/06/12 13:29:22 emerks Exp $
16  */

17 package org.eclipse.emf.ecore.impl;
18
19
20 import java.util.Collection JavaDoc;
21 import java.util.List JavaDoc;
22 import java.util.Map JavaDoc;
23
24 import org.eclipse.emf.common.notify.Notification;
25 import org.eclipse.emf.common.notify.NotificationChain;
26 import org.eclipse.emf.common.notify.impl.NotificationChainImpl;
27 import org.eclipse.emf.common.util.BasicEMap;
28 import org.eclipse.emf.ecore.EClass;
29 import org.eclipse.emf.ecore.EClassifier;
30 import org.eclipse.emf.ecore.EDataType;
31 import org.eclipse.emf.ecore.EFactory;
32 import org.eclipse.emf.ecore.EObject;
33 import org.eclipse.emf.ecore.EReference;
34 import org.eclipse.emf.ecore.EStructuralFeature;
35 import org.eclipse.emf.ecore.EcorePackage;
36 import org.eclipse.emf.ecore.InternalEObject;
37 import org.eclipse.emf.ecore.util.BasicExtendedMetaData;
38 import org.eclipse.emf.ecore.util.BasicFeatureMap;
39 import org.eclipse.emf.ecore.util.EDataTypeEList;
40 import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
41 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
42 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
43 import org.eclipse.emf.ecore.util.EObjectEList;
44 import org.eclipse.emf.ecore.util.EObjectResolvingEList;
45 import org.eclipse.emf.ecore.util.EObjectWithInverseEList;
46 import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
47 import org.eclipse.emf.ecore.util.EcoreEList;
48 import org.eclipse.emf.ecore.util.EcoreEMap;
49 import org.eclipse.emf.ecore.util.EcoreUtil;
50 import org.eclipse.emf.ecore.util.ExtendedMetaData;
51 import org.eclipse.emf.ecore.util.FeatureMap;
52 import org.eclipse.emf.ecore.util.InternalEList;
53
54
55 /**
56  * <!-- begin-user-doc -->
57  * An implementation of the model object '<em><b>EStructural Feature</b></em>'.
58  * @extends EStructuralFeature.Internal, BasicExtendedMetaData.EStructuralFeatureExtendedMetaData.Holder
59  * <!-- end-user-doc -->
60  * <p>
61  * The following features are implemented:
62  * <ul>
63  * <li>{@link org.eclipse.emf.ecore.impl.EStructuralFeatureImpl#isChangeable <em>Changeable</em>}</li>
64  * <li>{@link org.eclipse.emf.ecore.impl.EStructuralFeatureImpl#isVolatile <em>Volatile</em>}</li>
65  * <li>{@link org.eclipse.emf.ecore.impl.EStructuralFeatureImpl#isTransient <em>Transient</em>}</li>
66  * <li>{@link org.eclipse.emf.ecore.impl.EStructuralFeatureImpl#getDefaultValueLiteral <em>Default Value Literal</em>}</li>
67  * <li>{@link org.eclipse.emf.ecore.impl.EStructuralFeatureImpl#getDefaultValue <em>Default Value</em>}</li>
68  * <li>{@link org.eclipse.emf.ecore.impl.EStructuralFeatureImpl#isUnsettable <em>Unsettable</em>}</li>
69  * <li>{@link org.eclipse.emf.ecore.impl.EStructuralFeatureImpl#isDerived <em>Derived</em>}</li>
70  * <li>{@link org.eclipse.emf.ecore.impl.EStructuralFeatureImpl#getEContainingClass <em>EContaining Class</em>}</li>
71  * </ul>
72  * </p>
73  *
74  * @generated
75  */

76 public abstract class EStructuralFeatureImpl extends ETypedElementImpl implements EStructuralFeature, EStructuralFeature.Internal, BasicExtendedMetaData.EStructuralFeatureExtendedMetaData.Holder
77 {
78   protected int featureID = -1;
79   protected Class JavaDoc containerClass;
80
81   /**
82    * <!-- begin-user-doc -->
83    * <!-- end-user-doc -->
84    * @generated
85    */

86   protected EStructuralFeatureImpl()
87   {
88     super();
89     eFlags |= CHANGEABLE_EFLAG;
90   }
91
92   /**
93    * <!-- begin-user-doc -->
94    * <!-- end-user-doc -->
95    * @generated
96    */

97   protected EClass eStaticClass()
98   {
99     return EcorePackage.eINSTANCE.getEStructuralFeature();
100   }
101
102   protected Object JavaDoc defaultValue = null;
103   protected EFactory defaultValueFactory = null;
104
105   /**
106    * <!-- begin-user-doc -->
107    * <!-- end-user-doc -->
108    * @generated modifiable
109    */

110   public Object JavaDoc getDefaultValue()
111   {
112     EClassifier eType = getEType();
113     String JavaDoc literal = getDefaultValueLiteral();
114
115     if (literal == null && eType != null)
116     {
117       return eType.getDefaultValue();
118     }
119     else if (eType instanceof EDataType)
120     {
121       EFactory factory = eType.getEPackage().getEFactoryInstance();
122       if (factory != defaultValueFactory)
123       {
124         defaultValueFactory = factory;
125         EDataType eDataType = (EDataType)eType;
126         if (eDataType.isSerializable())
127         {
128           defaultValue = factory.createFromString((EDataType)eType, literal);
129         }
130       }
131       return defaultValue;
132     }
133     return null;
134   }
135
136   public void setDefaultValue(Object JavaDoc newDefaultValue)
137   {
138     EClassifier eType = getEType();
139     if (eType instanceof EDataType)
140     {
141       EFactory factory = eType.getEPackage().getEFactoryInstance();
142       String JavaDoc literal = factory.convertToString((EDataType)eType, newDefaultValue);
143       defaultValueFactory = null;
144       setDefaultValueLiteralGen(literal);
145       return;
146     }
147     throw new IllegalStateException JavaDoc("Cannot serialize value to object without an EDataType eType");
148   }
149
150   public void setDefaultValueLiteral(String JavaDoc newDefaultValueLiteral)
151   {
152     defaultValueFactory = null;
153     setDefaultValueLiteralGen(newDefaultValueLiteral);
154   }
155
156   /**
157    * <!-- begin-user-doc -->
158    * <!-- end-user-doc -->
159    * @generated
160    */

161   public void setDefaultValueLiteralGen(String JavaDoc newDefaultValueLiteral)
162   {
163     String JavaDoc oldDefaultValueLiteral = defaultValueLiteral;
164     defaultValueLiteral = newDefaultValueLiteral;
165     if (eNotificationRequired())
166       eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ESTRUCTURAL_FEATURE__DEFAULT_VALUE_LITERAL, oldDefaultValueLiteral, defaultValueLiteral));
167   }
168
169   /**
170    * <!-- begin-user-doc -->
171    * <!-- end-user-doc -->
172    * @generated
173    */

174   public boolean isUnsettable()
175   {
176     return (eFlags & UNSETTABLE_EFLAG) != 0;
177   }
178
179   /**
180    * <!-- begin-user-doc -->
181    * <!-- end-user-doc -->
182    * @generated
183    */

184   public void setUnsettable(boolean newUnsettable)
185   {
186     boolean oldUnsettable = (eFlags & UNSETTABLE_EFLAG) != 0;
187     if (newUnsettable) eFlags |= UNSETTABLE_EFLAG; else eFlags &= ~UNSETTABLE_EFLAG;
188     if (eNotificationRequired())
189       eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ESTRUCTURAL_FEATURE__UNSETTABLE, oldUnsettable, newUnsettable));
190   }
191
192   /**
193    * <!-- begin-user-doc -->
194    * <!-- end-user-doc -->
195    * @generated
196    */

197   public boolean isDerived()
198   {
199     return (eFlags & DERIVED_EFLAG) != 0;
200   }
201
202   /**
203    * <!-- begin-user-doc -->
204    * <!-- end-user-doc -->
205    * @generated
206    */

207   public void setDerived(boolean newDerived)
208   {
209     boolean oldDerived = (eFlags & DERIVED_EFLAG) != 0;
210     if (newDerived) eFlags |= DERIVED_EFLAG; else eFlags &= ~DERIVED_EFLAG;
211     if (eNotificationRequired())
212       eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ESTRUCTURAL_FEATURE__DERIVED, oldDerived, newDerived));
213   }
214
215   /**
216    * <!-- begin-user-doc -->
217    * <!-- end-user-doc -->
218    * @generated
219    */

220   public EClass getEContainingClass()
221   {
222     if (eContainerFeatureID != EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS) return null;
223     return (EClass)eContainer;
224   }
225
226   /**
227    * The default value of the '{@link #isChangeable() <em>Changeable</em>}' attribute.
228    * <!-- begin-user-doc -->
229    * <!-- end-user-doc -->
230    * @see #isChangeable()
231    * @generated
232    * @ordered
233    */

234   protected static final boolean CHANGEABLE_EDEFAULT = true;
235
236   /**
237    * The flag representing the value of the '{@link #isChangeable() <em>Changeable</em>}' attribute.
238    * <!-- begin-user-doc -->
239    * <!-- end-user-doc -->
240    * @see #isChangeable()
241    * @generated
242    * @ordered
243    */

244   protected static final int CHANGEABLE_EFLAG = 1 << 10;
245
246   /**
247    * The default value of the '{@link #isVolatile() <em>Volatile</em>}' attribute.
248    * <!-- begin-user-doc -->
249    * <!-- end-user-doc -->
250    * @see #isVolatile()
251    * @generated
252    * @ordered
253    */

254   protected static final boolean VOLATILE_EDEFAULT = false;
255
256   /**
257    * The flag representing the value of the '{@link #isVolatile() <em>Volatile</em>}' attribute.
258    * <!-- begin-user-doc -->
259    * <!-- end-user-doc -->
260    * @see #isVolatile()
261    * @generated
262    * @ordered
263    */

264   protected static final int VOLATILE_EFLAG = 1 << 11;
265
266   /**
267    * The default value of the '{@link #isTransient() <em>Transient</em>}' attribute.
268    * <!-- begin-user-doc -->
269    * <!-- end-user-doc -->
270    * @see #isTransient()
271    * @generated
272    * @ordered
273    */

274   protected static final boolean TRANSIENT_EDEFAULT = false;
275
276   /**
277    * The flag representing the value of the '{@link #isTransient() <em>Transient</em>}' attribute.
278    * <!-- begin-user-doc -->
279    * <!-- end-user-doc -->
280    * @see #isTransient()
281    * @generated
282    * @ordered
283    */

284   protected static final int TRANSIENT_EFLAG = 1 << 12;
285
286   /**
287    * The default value of the '{@link #getDefaultValueLiteral() <em>Default Value Literal</em>}' attribute.
288    * <!-- begin-user-doc -->
289    * <!-- end-user-doc -->
290    * @see #getDefaultValueLiteral()
291    * @generated
292    * @ordered
293    */

294   protected static final String JavaDoc DEFAULT_VALUE_LITERAL_EDEFAULT = null;
295
296   /**
297    * The cached value of the '{@link #getDefaultValueLiteral() <em>Default Value Literal</em>}' attribute.
298    * <!-- begin-user-doc -->
299    * <!-- end-user-doc -->
300    * @see #getDefaultValueLiteral()
301    * @generated
302    * @ordered
303    */

304   protected String JavaDoc defaultValueLiteral = DEFAULT_VALUE_LITERAL_EDEFAULT;
305
306   /**
307    * The default value of the '{@link #getDefaultValue() <em>Default Value</em>}' attribute.
308    * <!-- begin-user-doc -->
309    * <!-- end-user-doc -->
310    * @see #getDefaultValue()
311    * @generated
312    * @ordered
313    */

314   protected static final Object JavaDoc DEFAULT_VALUE_EDEFAULT = null;
315
316   /**
317    * The default value of the '{@link #isUnsettable() <em>Unsettable</em>}' attribute.
318    * <!-- begin-user-doc -->
319    * <!-- end-user-doc -->
320    * @see #isUnsettable()
321    * @generated
322    * @ordered
323    */

324   protected static final boolean UNSETTABLE_EDEFAULT = false;
325
326   /**
327    * The flag representing the value of the '{@link #isUnsettable() <em>Unsettable</em>}' attribute.
328    * <!-- begin-user-doc -->
329    * <!-- end-user-doc -->
330    * @see #isUnsettable()
331    * @generated
332    * @ordered
333    */

334   protected static final int UNSETTABLE_EFLAG = 1 << 13;
335
336   /**
337    * The default value of the '{@link #isDerived() <em>Derived</em>}' attribute.
338    * <!-- begin-user-doc -->
339    * <!-- end-user-doc -->
340    * @see #isDerived()
341    * @generated
342    * @ordered
343    */

344   protected static final boolean DERIVED_EDEFAULT = false;
345
346   /**
347    * The flag representing the value of the '{@link #isDerived() <em>Derived</em>}' attribute.
348    * <!-- begin-user-doc -->
349    * <!-- end-user-doc -->
350    * @see #isDerived()
351    * @generated
352    * @ordered
353    */

354   protected static final int DERIVED_EFLAG = 1 << 14;
355
356   /**
357    * <!-- begin-user-doc -->
358    * <!-- end-user-doc -->
359    * @generated
360    */

361   public Object JavaDoc eGet(EStructuralFeature eFeature, boolean resolve)
362   {
363     switch (eDerivedStructuralFeatureID(eFeature))
364     {
365       case EcorePackage.ESTRUCTURAL_FEATURE__EANNOTATIONS:
366         return getEAnnotations();
367       case EcorePackage.ESTRUCTURAL_FEATURE__NAME:
368         return getName();
369       case EcorePackage.ESTRUCTURAL_FEATURE__ORDERED:
370         return isOrdered() ? Boolean.TRUE : Boolean.FALSE;
371       case EcorePackage.ESTRUCTURAL_FEATURE__UNIQUE:
372         return isUnique() ? Boolean.TRUE : Boolean.FALSE;
373       case EcorePackage.ESTRUCTURAL_FEATURE__LOWER_BOUND:
374         return new Integer JavaDoc(getLowerBound());
375       case EcorePackage.ESTRUCTURAL_FEATURE__UPPER_BOUND:
376         return new Integer JavaDoc(getUpperBound());
377       case EcorePackage.ESTRUCTURAL_FEATURE__MANY:
378         return isMany() ? Boolean.TRUE : Boolean.FALSE;
379       case EcorePackage.ESTRUCTURAL_FEATURE__REQUIRED:
380         return isRequired() ? Boolean.TRUE : Boolean.FALSE;
381       case EcorePackage.ESTRUCTURAL_FEATURE__ETYPE:
382         if (resolve) return getEType();
383         return basicGetEType();
384       case EcorePackage.ESTRUCTURAL_FEATURE__CHANGEABLE:
385         return isChangeable() ? Boolean.TRUE : Boolean.FALSE;
386       case EcorePackage.ESTRUCTURAL_FEATURE__VOLATILE:
387         return isVolatile() ? Boolean.TRUE : Boolean.FALSE;
388       case EcorePackage.ESTRUCTURAL_FEATURE__TRANSIENT:
389         return isTransient() ? Boolean.TRUE : Boolean.FALSE;
390       case EcorePackage.ESTRUCTURAL_FEATURE__DEFAULT_VALUE_LITERAL:
391         return getDefaultValueLiteral();
392       case EcorePackage.ESTRUCTURAL_FEATURE__DEFAULT_VALUE:
393         return getDefaultValue();
394       case EcorePackage.ESTRUCTURAL_FEATURE__UNSETTABLE:
395         return isUnsettable() ? Boolean.TRUE : Boolean.FALSE;
396       case EcorePackage.ESTRUCTURAL_FEATURE__DERIVED:
397         return isDerived() ? Boolean.TRUE : Boolean.FALSE;
398       case EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS:
399         return getEContainingClass();
400     }
401     return eDynamicGet(eFeature, resolve);
402   }
403
404   /**
405    * <!-- begin-user-doc -->
406    * <!-- end-user-doc -->
407    * @generated
408    */

409   public boolean eIsSet(EStructuralFeature eFeature)
410   {
411     switch (eDerivedStructuralFeatureID(eFeature))
412     {
413       case EcorePackage.ESTRUCTURAL_FEATURE__EANNOTATIONS:
414         return eAnnotations != null && !eAnnotations.isEmpty();
415       case EcorePackage.ESTRUCTURAL_FEATURE__NAME:
416         return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
417       case EcorePackage.ESTRUCTURAL_FEATURE__ORDERED:
418         return ((eFlags & ORDERED_EFLAG) != 0) != ORDERED_EDEFAULT;
419       case EcorePackage.ESTRUCTURAL_FEATURE__UNIQUE:
420         return ((eFlags & UNIQUE_EFLAG) != 0) != UNIQUE_EDEFAULT;
421       case EcorePackage.ESTRUCTURAL_FEATURE__LOWER_BOUND:
422         return lowerBound != LOWER_BOUND_EDEFAULT;
423       case EcorePackage.ESTRUCTURAL_FEATURE__UPPER_BOUND:
424         return upperBound != UPPER_BOUND_EDEFAULT;
425       case EcorePackage.ESTRUCTURAL_FEATURE__MANY:
426         return isMany() != MANY_EDEFAULT;
427       case EcorePackage.ESTRUCTURAL_FEATURE__REQUIRED:
428         return isRequired() != REQUIRED_EDEFAULT;
429       case EcorePackage.ESTRUCTURAL_FEATURE__ETYPE:
430         return eType != null;
431       case EcorePackage.ESTRUCTURAL_FEATURE__CHANGEABLE:
432         return ((eFlags & CHANGEABLE_EFLAG) != 0) != CHANGEABLE_EDEFAULT;
433       case EcorePackage.ESTRUCTURAL_FEATURE__VOLATILE:
434         return ((eFlags & VOLATILE_EFLAG) != 0) != VOLATILE_EDEFAULT;
435       case EcorePackage.ESTRUCTURAL_FEATURE__TRANSIENT:
436         return ((eFlags & TRANSIENT_EFLAG) != 0) != TRANSIENT_EDEFAULT;
437       case EcorePackage.ESTRUCTURAL_FEATURE__DEFAULT_VALUE_LITERAL:
438         return DEFAULT_VALUE_LITERAL_EDEFAULT == null ? defaultValueLiteral != null : !DEFAULT_VALUE_LITERAL_EDEFAULT.equals(defaultValueLiteral);
439       case EcorePackage.ESTRUCTURAL_FEATURE__DEFAULT_VALUE:
440         return DEFAULT_VALUE_EDEFAULT == null ? getDefaultValue() != null : !DEFAULT_VALUE_EDEFAULT.equals(getDefaultValue());
441       case EcorePackage.ESTRUCTURAL_FEATURE__UNSETTABLE:
442         return ((eFlags & UNSETTABLE_EFLAG) != 0) != UNSETTABLE_EDEFAULT;
443       case EcorePackage.ESTRUCTURAL_FEATURE__DERIVED:
444         return ((eFlags & DERIVED_EFLAG) != 0) != DERIVED_EDEFAULT;
445       case EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS:
446         return getEContainingClass() != null;
447     }
448     return eDynamicIsSet(eFeature);
449   }
450
451   /**
452    * <!-- begin-user-doc -->
453    * <!-- end-user-doc -->
454    * @generated
455    */

456   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
457   {
458     switch (eDerivedStructuralFeatureID(eFeature))
459     {
460       case EcorePackage.ESTRUCTURAL_FEATURE__EANNOTATIONS:
461         getEAnnotations().clear();
462         getEAnnotations().addAll((Collection JavaDoc)newValue);
463         return;
464       case EcorePackage.ESTRUCTURAL_FEATURE__NAME:
465         setName((String JavaDoc)newValue);
466         return;
467       case EcorePackage.ESTRUCTURAL_FEATURE__ORDERED:
468         setOrdered(((Boolean JavaDoc)newValue).booleanValue());
469         return;
470       case EcorePackage.ESTRUCTURAL_FEATURE__UNIQUE:
471         setUnique(((Boolean JavaDoc)newValue).booleanValue());
472         return;
473       case EcorePackage.ESTRUCTURAL_FEATURE__LOWER_BOUND:
474         setLowerBound(((Integer JavaDoc)newValue).intValue());
475         return;
476       case EcorePackage.ESTRUCTURAL_FEATURE__UPPER_BOUND:
477         setUpperBound(((Integer JavaDoc)newValue).intValue());
478         return;
479       case EcorePackage.ESTRUCTURAL_FEATURE__ETYPE:
480         setEType((EClassifier)newValue);
481         return;
482       case EcorePackage.ESTRUCTURAL_FEATURE__CHANGEABLE:
483         setChangeable(((Boolean JavaDoc)newValue).booleanValue());
484         return;
485       case EcorePackage.ESTRUCTURAL_FEATURE__VOLATILE:
486         setVolatile(((Boolean JavaDoc)newValue).booleanValue());
487         return;
488       case EcorePackage.ESTRUCTURAL_FEATURE__TRANSIENT:
489         setTransient(((Boolean JavaDoc)newValue).booleanValue());
490         return;
491       case EcorePackage.ESTRUCTURAL_FEATURE__DEFAULT_VALUE_LITERAL:
492         setDefaultValueLiteral((String JavaDoc)newValue);
493         return;
494       case EcorePackage.ESTRUCTURAL_FEATURE__UNSETTABLE:
495         setUnsettable(((Boolean JavaDoc)newValue).booleanValue());
496         return;
497       case EcorePackage.ESTRUCTURAL_FEATURE__DERIVED:
498         setDerived(((Boolean JavaDoc)newValue).booleanValue());
499         return;
500     }
501     eDynamicSet(eFeature, newValue);
502   }
503
504   /**
505    * <!-- begin-user-doc -->
506    * <!-- end-user-doc -->
507    * @generated
508    */

509   public void eUnset(EStructuralFeature eFeature)
510   {
511     switch (eDerivedStructuralFeatureID(eFeature))
512     {
513       case EcorePackage.ESTRUCTURAL_FEATURE__EANNOTATIONS:
514         getEAnnotations().clear();
515         return;
516       case EcorePackage.ESTRUCTURAL_FEATURE__NAME:
517         setName(NAME_EDEFAULT);
518         return;
519       case EcorePackage.ESTRUCTURAL_FEATURE__ORDERED:
520         setOrdered(ORDERED_EDEFAULT);
521         return;
522       case EcorePackage.ESTRUCTURAL_FEATURE__UNIQUE:
523         setUnique(UNIQUE_EDEFAULT);
524         return;
525       case EcorePackage.ESTRUCTURAL_FEATURE__LOWER_BOUND:
526         setLowerBound(LOWER_BOUND_EDEFAULT);
527         return;
528       case EcorePackage.ESTRUCTURAL_FEATURE__UPPER_BOUND:
529         setUpperBound(UPPER_BOUND_EDEFAULT);
530         return;
531       case EcorePackage.ESTRUCTURAL_FEATURE__ETYPE:
532         setEType((EClassifier)null);
533         return;
534       case EcorePackage.ESTRUCTURAL_FEATURE__CHANGEABLE:
535         setChangeable(CHANGEABLE_EDEFAULT);
536         return;
537       case EcorePackage.ESTRUCTURAL_FEATURE__VOLATILE:
538         setVolatile(VOLATILE_EDEFAULT);
539         return;
540       case EcorePackage.ESTRUCTURAL_FEATURE__TRANSIENT:
541         setTransient(TRANSIENT_EDEFAULT);
542         return;
543       case EcorePackage.ESTRUCTURAL_FEATURE__DEFAULT_VALUE_LITERAL:
544         setDefaultValueLiteral(DEFAULT_VALUE_LITERAL_EDEFAULT);
545         return;
546       case EcorePackage.ESTRUCTURAL_FEATURE__UNSETTABLE:
547         setUnsettable(UNSETTABLE_EDEFAULT);
548         return;
549       case EcorePackage.ESTRUCTURAL_FEATURE__DERIVED:
550         setDerived(DERIVED_EDEFAULT);
551         return;
552     }
553     eDynamicUnset(eFeature);
554   }
555
556   /**
557    * <!-- begin-user-doc -->
558    * <!-- end-user-doc -->
559    * @generated
560    */

561   public boolean isTransient()
562   {
563     return (eFlags & TRANSIENT_EFLAG) != 0;
564   }
565
566   /**
567    * <!-- begin-user-doc -->
568    * <!-- end-user-doc -->
569    * @generated
570    */

571   public void setTransient(boolean newTransient)
572   {
573     boolean oldTransient = (eFlags & TRANSIENT_EFLAG) != 0;
574     if (newTransient) eFlags |= TRANSIENT_EFLAG; else eFlags &= ~TRANSIENT_EFLAG;
575     if (eNotificationRequired())
576       eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ESTRUCTURAL_FEATURE__TRANSIENT, oldTransient, newTransient));
577   }
578
579   /**
580    * <!-- begin-user-doc -->
581    * <!-- end-user-doc -->
582    * @generated
583    */

584   public boolean isVolatile()
585   {
586     return (eFlags & VOLATILE_EFLAG) != 0;
587   }
588
589   /**
590    * <!-- begin-user-doc -->
591    * <!-- end-user-doc -->
592    * @generated
593    */

594   public void setVolatile(boolean newVolatile)
595   {
596     boolean oldVolatile = (eFlags & VOLATILE_EFLAG) != 0;
597     if (newVolatile) eFlags |= VOLATILE_EFLAG; else eFlags &= ~VOLATILE_EFLAG;
598     if (eNotificationRequired())
599       eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ESTRUCTURAL_FEATURE__VOLATILE, oldVolatile, newVolatile));
600   }
601
602   /**
603    * <!-- begin-user-doc -->
604    * <!-- end-user-doc -->
605    * @generated
606    */

607   public boolean isChangeable()
608   {
609     return (eFlags & CHANGEABLE_EFLAG) != 0;
610   }
611
612   /**
613    * <!-- begin-user-doc -->
614    * <!-- end-user-doc -->
615    * @generated
616    */

617   public void setChangeable(boolean newChangeable)
618   {
619     boolean oldChangeable = (eFlags & CHANGEABLE_EFLAG) != 0;
620     if (newChangeable) eFlags |= CHANGEABLE_EFLAG; else eFlags &= ~CHANGEABLE_EFLAG;
621     if (eNotificationRequired())
622       eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ESTRUCTURAL_FEATURE__CHANGEABLE, oldChangeable, newChangeable));
623   }
624
625   /**
626    * <!-- begin-user-doc -->
627    * <!-- end-user-doc -->
628    * @generated
629    */

630   public String JavaDoc getDefaultValueLiteral()
631   {
632     return defaultValueLiteral;
633   }
634
635   /**
636    * <!-- begin-user-doc -->
637    * <!-- end-user-doc -->
638    * @generated
639    */

640   public String JavaDoc toString()
641   {
642     if (eIsProxy()) return super.toString();
643
644     StringBuffer JavaDoc result = new StringBuffer JavaDoc(super.toString());
645     result.append(" (changeable: ");
646     result.append((eFlags & CHANGEABLE_EFLAG) != 0);
647     result.append(", volatile: ");
648     result.append((eFlags & VOLATILE_EFLAG) != 0);
649     result.append(", transient: ");
650     result.append((eFlags & TRANSIENT_EFLAG) != 0);
651     result.append(", defaultValueLiteral: ");
652     result.append(defaultValueLiteral);
653     result.append(", unsettable: ");
654     result.append((eFlags & UNSETTABLE_EFLAG) != 0);
655     result.append(", derived: ");
656     result.append((eFlags & DERIVED_EFLAG) != 0);
657     result.append(')');
658     return result.toString();
659   }
660
661   /**
662    * @generated modifiable
663    */

664   public int getFeatureID()
665   {
666     return featureID;
667   }
668
669   public void setFeatureID(int featureID)
670   {
671     this.featureID = featureID;
672   }
673
674   /**
675    * @generated modifiable
676    */

677   public Class JavaDoc getContainerClass()
678   {
679     return containerClass;
680   }
681
682   /**
683    * <!-- begin-user-doc -->
684    * <!-- end-user-doc -->
685    * @generated
686    */

687   public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
688   {
689     if (featureID >= 0)
690     {
691       switch (eDerivedStructuralFeatureID(featureID, baseClass))
692       {
693         case EcorePackage.ESTRUCTURAL_FEATURE__EANNOTATIONS:
694           return ((InternalEList)getEAnnotations()).basicAdd(otherEnd, msgs);
695         case EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS:
696           if (eContainer != null)
697             msgs = eBasicRemoveFromContainer(msgs);
698           return eBasicSetContainer(otherEnd, EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS, msgs);
699         default:
700           return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
701       }
702     }
703     if (eContainer != null)
704       msgs = eBasicRemoveFromContainer(msgs);
705     return eBasicSetContainer(otherEnd, featureID, msgs);
706   }
707
708   /**
709    * <!-- begin-user-doc -->
710    * <!-- end-user-doc -->
711    * @generated
712    */

713   public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
714   {
715     if (featureID >= 0)
716     {
717       switch (eDerivedStructuralFeatureID(featureID, baseClass))
718       {
719         case EcorePackage.ESTRUCTURAL_FEATURE__EANNOTATIONS:
720           return ((InternalEList)getEAnnotations()).basicRemove(otherEnd, msgs);
721         case EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS:
722           return eBasicSetContainer(null, EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS, msgs);
723         default:
724           return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
725       }
726     }
727     return eBasicSetContainer(null, featureID, msgs);
728   }
729
730   /**
731    * <!-- begin-user-doc -->
732    * <!-- end-user-doc -->
733    * @generated
734    */

735   public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs)
736   {
737     if (eContainerFeatureID >= 0)
738     {
739       switch (eContainerFeatureID)
740       {
741         case EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS:
742           return eContainer.eInverseRemove(this, EcorePackage.ECLASS__ESTRUCTURAL_FEATURES, EClass.class, msgs);
743         default:
744           return eDynamicBasicRemoveFromContainer(msgs);
745       }
746     }
747     return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
748   }
749
750   public void setContainerClass(Class JavaDoc containerClass)
751   {
752     this.containerClass = containerClass;
753   }
754
755   protected boolean isResolveProxies()
756   {
757     return false;
758   }
759
760   protected boolean isContainer()
761   {
762     return false;
763   }
764
765   protected boolean isContainment()
766   {
767     return false;
768   }
769
770   protected EReference getEOpposite()
771   {
772     return null;
773   }
774
775   protected EStructuralFeature.Internal.SettingDelegate settingDelegate;
776
777   public EStructuralFeature.Internal.SettingDelegate getSettingDelegate()
778   {
779     if (settingDelegate == null)
780     {
781       EClass eClass = getEContainingClass();
782       eClass.getFeatureCount();
783       EReference eOpposite = getEOpposite();
784       if (eOpposite != null)
785       {
786         eOpposite.getEContainingClass().getFeatureCount();
787       }
788
789       EClassifier eType = getEType();
790       Class JavaDoc dataClass = EcoreUtil.wrapperClassFor(eType.getInstanceClass());
791       Object JavaDoc defaultValue = getDefaultValue();
792       Object JavaDoc intrinsicDefaultValue = eType.getDefaultValue();
793
794       EStructuralFeature featureMapFeature;
795       if (isDerived() &&
796             (((featureMapFeature = ExtendedMetaData.INSTANCE.getMixedFeature(eClass)) != null &&
797                featureMapFeature != this) ||
798               ((featureMapFeature = ExtendedMetaData.INSTANCE.getGroup(this)) != null)))
799       {
800         settingDelegate = new InternalSettingDelegateFeatureMapDelegator(this, featureMapFeature);
801       }
802       else if (isMany())
803       {
804         if (isContainment())
805         {
806           if (eOpposite == null)
807           {
808             if (isUnsettable())
809             {
810               if (dataClass == null)
811               {
812                 settingDelegate =
813                   new InternalSettingDelegateMany
814                     (InternalSettingDelegateMany.CONTAINMENT_UNSETTABLE_DYNAMIC, this);
815               }
816               else
817               {
818                 settingDelegate =
819                   new InternalSettingDelegateMany
820                     (InternalSettingDelegateMany.CONTAINMENT_UNSETTABLE, dataClass, this);
821               }
822             }
823             else
824             {
825               if (dataClass == null)
826               {
827                 settingDelegate =
828                   new InternalSettingDelegateMany
829                     (InternalSettingDelegateMany.CONTAINMENT_DYNAMIC, this);
830               }
831               else if (dataClass == Map.Entry JavaDoc.class)
832               {
833                 settingDelegate =
834                   new InternalSettingDelegateMany
835                     (InternalSettingDelegateMany.EMAP, BasicEMap.Entry.class, this);
836               }
837               else
838               {
839                 settingDelegate =
840                   new InternalSettingDelegateMany
841                     (InternalSettingDelegateMany.CONTAINMENT, dataClass, this);
842               }
843             }
844           }
845           else
846           {
847             if (isUnsettable())
848             {
849               if (dataClass == null)
850               {
851                 settingDelegate =
852                   new InternalSettingDelegateMany
853                     (InternalSettingDelegateMany.CONTAINMENT_INVERSE_UNSETTABLE_DYNAMIC, this, eOpposite);
854               }
855               else
856               {
857                 settingDelegate =
858                   new InternalSettingDelegateMany
859                     (InternalSettingDelegateMany.CONTAINMENT_INVERSE_UNSETTABLE, dataClass, this, eOpposite);
860               }
861             }
862             else
863             {
864               if (dataClass == null)
865               {
866                 settingDelegate =
867                   new InternalSettingDelegateMany
868                     (InternalSettingDelegateMany.CONTAINMENT_INVERSE_DYNAMIC, this, eOpposite);
869               }
870               else
871               {
872                 settingDelegate =
873                   new InternalSettingDelegateMany
874                     (InternalSettingDelegateMany.CONTAINMENT_INVERSE, dataClass, this, eOpposite);
875               }
876             }
877           }
878         }
879         else if (eType instanceof EDataType)
880         {
881           if (dataClass == FeatureMap.Entry.class)
882           {
883             settingDelegate =
884               new InternalSettingDelegateMany
885                 (InternalSettingDelegateMany.FEATURE_MAP, this);
886           }
887           else if (isUnique())
888           {
889             if (isUnsettable())
890             {
891               if (dataClass == null)
892               {
893                 settingDelegate =
894                   new InternalSettingDelegateMany
895                     (InternalSettingDelegateMany.DATA_UNIQUE_UNSETTABLE_DYNAMIC, this);
896               }
897               else
898               {
899                 settingDelegate =
900                   new InternalSettingDelegateMany
901                     (InternalSettingDelegateMany.DATA_UNIQUE_UNSETTABLE, dataClass, this);
902               }
903             }
904             else
905             {
906               if (dataClass == null)
907               {
908                 settingDelegate =
909                   new InternalSettingDelegateMany
910                     (InternalSettingDelegateMany.DATA_UNIQUE_DYNAMIC, this);
911               }
912               else
913               {
914                 settingDelegate =
915                   new InternalSettingDelegateMany
916                     (InternalSettingDelegateMany.DATA_UNIQUE, dataClass, this);
917               }
918             }
919           }
920           else
921           {
922             if (isUnsettable())
923             {
924               if (dataClass == null)
925               {
926                 settingDelegate =
927                   new InternalSettingDelegateMany
928                     (InternalSettingDelegateMany.DATA_UNSETTABLE_DYNAMIC, this);
929               }
930               else
931               {
932                 settingDelegate =
933                   new InternalSettingDelegateMany
934                     (InternalSettingDelegateMany.DATA_UNSETTABLE, dataClass, this);
935               }
936             }
937             else
938             {
939               if (dataClass == null)
940               {
941                 settingDelegate =
942                   new InternalSettingDelegateMany
943                     (InternalSettingDelegateMany.DATA_DYNAMIC, this);
944               }
945               else
946               {
947                 settingDelegate =
948                   new InternalSettingDelegateMany
949                     (InternalSettingDelegateMany.DATA, dataClass, this);
950               }
951             }
952           }
953         }
954         else if (eOpposite == null)
955         {
956           if (isResolveProxies())
957           {
958             if (isUnsettable())
959             {
960               if (dataClass == null)
961               {
962                 settingDelegate =
963                   new InternalSettingDelegateMany
964                     (InternalSettingDelegateMany.EOBJECT_RESOLVE_UNSETTABLE_DYNAMIC, this);
965               }
966               else
967               {
968                 settingDelegate =
969                   new InternalSettingDelegateMany
970                     (InternalSettingDelegateMany.EOBJECT_RESOLVE_UNSETTABLE, dataClass, this);
971               }
972             }
973             else
974             {
975               if (dataClass == null)
976               {
977                 settingDelegate =
978                   new InternalSettingDelegateMany
979                     (InternalSettingDelegateMany.EOBJECT_RESOLVE_DYNAMIC, this);
980               }
981               else
982               {
983                 settingDelegate =
984                   new InternalSettingDelegateMany
985                     (InternalSettingDelegateMany.EOBJECT_RESOLVE, dataClass, this);
986               }
987             }
988           }
989           else
990           {
991             if (isUnsettable())
992             {
993               if (dataClass == null)
994               {
995                 settingDelegate =
996                   new InternalSettingDelegateMany
997                     (InternalSettingDelegateMany.EOBJECT_UNSETTABLE_DYNAMIC, this);
998               }
999               else
1000              {
1001                settingDelegate =
1002                  new InternalSettingDelegateMany
1003                    (InternalSettingDelegateMany.EOBJECT_UNSETTABLE, dataClass, this);
1004              }
1005            }
1006            else
1007            {
1008              if (dataClass == null)
1009              {
1010                settingDelegate =
1011                  new InternalSettingDelegateMany
1012                    (InternalSettingDelegateMany.EOBJECT_DYNAMIC, this);
1013              }
1014              else
1015              {
1016                settingDelegate =
1017                  new InternalSettingDelegateMany
1018                    (InternalSettingDelegateMany.EOBJECT, dataClass, this);
1019              }
1020            }
1021          }
1022        }
1023        else if (eOpposite.isMany())
1024        {
1025          if (isResolveProxies())
1026          {
1027            if (isUnsettable())
1028            {
1029              if (dataClass == null)
1030              {
1031                settingDelegate =
1032                  new InternalSettingDelegateMany
1033                    (InternalSettingDelegateMany.MANY_INVERSE_RESOLVE_UNSETTABLE_DYNAMIC, this, eOpposite);
1034              }
1035              else
1036              {
1037                settingDelegate =
1038                  new InternalSettingDelegateMany
1039                    (InternalSettingDelegateMany.MANY_INVERSE_RESOLVE_UNSETTABLE, dataClass, this, eOpposite);
1040              }
1041            }
1042            else
1043            {
1044              if (dataClass == null)
1045              {
1046                settingDelegate =
1047                  new InternalSettingDelegateMany
1048                    (InternalSettingDelegateMany.MANY_INVERSE_RESOLVE_DYNAMIC, this, eOpposite);
1049              }
1050              else
1051              {
1052                settingDelegate =
1053                  new InternalSettingDelegateMany
1054                    (InternalSettingDelegateMany.MANY_INVERSE_RESOLVE, dataClass, this, eOpposite);
1055              }
1056            }
1057          }
1058          else
1059          {
1060            if (isUnsettable())
1061            {
1062              if (dataClass == null)
1063              {
1064                settingDelegate =
1065                  new InternalSettingDelegateMany
1066                    (InternalSettingDelegateMany.MANY_INVERSE_UNSETTABLE_DYNAMIC, this, eOpposite);
1067              }
1068              else
1069              {
1070                settingDelegate =
1071                  new InternalSettingDelegateMany
1072                    (InternalSettingDelegateMany.MANY_INVERSE_UNSETTABLE, dataClass, this, eOpposite);
1073              }
1074            }
1075            else
1076            {
1077              if (dataClass == null)
1078              {
1079                settingDelegate =
1080                  new InternalSettingDelegateMany
1081                    (InternalSettingDelegateMany.MANY_INVERSE_DYNAMIC, this, eOpposite);
1082              }
1083              else
1084              {
1085                settingDelegate =
1086                  new InternalSettingDelegateMany
1087                    (InternalSettingDelegateMany.MANY_INVERSE, dataClass, this, eOpposite);
1088              }
1089            }
1090          }
1091        }
1092        else
1093        {
1094          if (isResolveProxies())
1095          {
1096            if (isUnsettable())
1097            {
1098              if (dataClass == null)
1099              {
1100                settingDelegate =
1101                  new InternalSettingDelegateMany
1102                    (InternalSettingDelegateMany.INVERSE_RESOLVE_UNSETTABLE_DYNAMIC, this, eOpposite);
1103              }
1104              else
1105              {
1106                settingDelegate =
1107                  new InternalSettingDelegateMany
1108                    (InternalSettingDelegateMany.INVERSE_RESOLVE_UNSETTABLE, dataClass, this, eOpposite);
1109              }
1110            }
1111            else
1112            {
1113              if (dataClass == null)
1114              {
1115                settingDelegate =
1116                  new InternalSettingDelegateMany
1117                    (InternalSettingDelegateMany.INVERSE_RESOLVE_DYNAMIC, this, eOpposite);
1118              }
1119              else
1120              {
1121                settingDelegate =
1122                  new InternalSettingDelegateMany
1123                    (InternalSettingDelegateMany.INVERSE_RESOLVE, dataClass, this, eOpposite);
1124              }
1125            }
1126          }
1127          else
1128          {
1129            if (isUnsettable())
1130            {
1131              if (dataClass == null)
1132              {
1133                settingDelegate =
1134                  new InternalSettingDelegateMany
1135                    (InternalSettingDelegateMany.INVERSE_UNSETTABLE_DYNAMIC, this, eOpposite);
1136              }
1137              else
1138              {
1139                settingDelegate =
1140                  new InternalSettingDelegateMany
1141                    (InternalSettingDelegateMany.INVERSE_UNSETTABLE, dataClass, this, eOpposite);
1142              }
1143            }
1144            else
1145            {
1146              if (dataClass == null)
1147              {
1148                settingDelegate =
1149                  new InternalSettingDelegateMany
1150                    (InternalSettingDelegateMany.INVERSE_DYNAMIC, this, eOpposite);
1151              }
1152              else
1153              {
1154                settingDelegate =
1155                  new InternalSettingDelegateMany
1156                    (InternalSettingDelegateMany.INVERSE, dataClass, this, eOpposite);
1157              }
1158            }
1159          }
1160        }
1161      }
1162      else if (isContainer())
1163      {
1164        settingDelegate = new InternalSettingDelegateSingleContainer((EClass)eType, this, eOpposite);
1165      }
1166      else if (eType instanceof EDataType)
1167      {
1168        if (dataClass == FeatureMap.Entry.class)
1169        {
1170          settingDelegate =
1171            new InternalSettingDelegateMany
1172              (InternalSettingDelegateMany.FEATURE_MAP, this);
1173        }
1174        else if (isUnsettable())
1175        {
1176          if (dataClass == null)
1177          {
1178            settingDelegate = new InternalSettingDelegateSingleDataUnsettableDynamic((EDataType)eType, defaultValue, intrinsicDefaultValue, this);
1179          }
1180          else
1181          {
1182            settingDelegate = new InternalSettingDelegateSingleDataUnsettableStatic(dataClass, defaultValue, intrinsicDefaultValue, this);
1183          }
1184        }
1185        else
1186        {
1187          if (dataClass == null)
1188          {
1189            settingDelegate = new InternalSettingDelegateSingleDataDynamic((EDataType)eType, defaultValue, intrinsicDefaultValue, this);
1190          }
1191          else
1192          {
1193            settingDelegate = new InternalSettingDelegateSingleDataStatic(dataClass, defaultValue, intrinsicDefaultValue, this);
1194          }
1195        }
1196      }
1197      else if (isContainment())
1198      {
1199        if (eOpposite == null)
1200        {
1201          if (isUnsettable())
1202          {
1203            settingDelegate = new InternalSettingDelegateSingleEObjectContainmentUnsettable((EClass)eType, this);
1204          }
1205          else
1206          {
1207            settingDelegate = new InternalSettingDelegateSingleEObjectContainment((EClass)eType, this);
1208          }
1209        }
1210        else
1211        {
1212          if (isUnsettable())
1213          {
1214            settingDelegate = new InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettable((EClass)eType, this, eOpposite);
1215          }
1216          else
1217          {
1218            settingDelegate = new InternalSettingDelegateSingleEObjectContainmentWithInverse((EClass)eType, this, eOpposite);
1219          }
1220        }
1221      }
1222      else if (isResolveProxies())
1223      {
1224        if (eOpposite == null)
1225        {
1226          if (isUnsettable())
1227          {
1228            settingDelegate = new InternalSettingDelegateSingleEObjectResolvingUnsettable((EClass)eType, this);
1229          }
1230          else
1231          {
1232            settingDelegate = new InternalSettingDelegateSingleEObjectResolving((EClass)eType, this);
1233          }
1234        }
1235        else
1236        {
1237          if (isUnsettable())
1238          {
1239            settingDelegate = new InternalSettingDelegateSingleEObjectResolvingWithInverseUnsettable((EClass)eType, this, eOpposite);
1240          }
1241          else
1242          {
1243            settingDelegate = new InternalSettingDelegateSingleEObjectResolvingWithInverse((EClass)eType, this, eOpposite);
1244          }
1245        }
1246      }
1247      else
1248      {
1249        if (eOpposite == null)
1250        {
1251          if (isUnsettable())
1252          {
1253            settingDelegate = new InternalSettingDelegateSingleEObjectUnsettable((EClass)eType, this);
1254          }
1255          else
1256          {
1257            settingDelegate = new InternalSettingDelegateSingleEObject((EClass)eType, this);
1258          }
1259        }
1260        else
1261        {
1262          if (isUnsettable())
1263          {
1264            settingDelegate = new InternalSettingDelegateSingleEObjectWithInverseUnsettable((EClass)eType, this, eOpposite);
1265          }
1266          else
1267          {
1268            settingDelegate = new InternalSettingDelegateSingleEObjectWithInverse((EClass)eType, this, eOpposite);
1269          }
1270        }
1271      }
1272    }
1273
1274    return settingDelegate;
1275  }
1276
1277  public void setSettingDelegate(EStructuralFeature.Internal.SettingDelegate settingDelegate)
1278  {
1279    this.settingDelegate = settingDelegate;
1280  }
1281
1282  public static class InternalSettingDelegateFeatureMapDelegator implements EStructuralFeature.Internal.SettingDelegate
1283  {
1284    protected EStructuralFeature feature;
1285    protected EStructuralFeature featureMapFeature;
1286
1287    public InternalSettingDelegateFeatureMapDelegator(EStructuralFeature feature, EStructuralFeature featureMapFeature)
1288    {
1289      this.feature = feature;
1290      this.featureMapFeature = featureMapFeature;
1291    }
1292
1293    protected EStructuralFeature.Setting createDynamicSetting(InternalEObject owner)
1294    {
1295      return ((FeatureMap.Internal)owner.eGet(featureMapFeature)).setting(feature);
1296    }
1297
1298    public EStructuralFeature.Setting dynamicSetting(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
1299    {
1300      return createDynamicSetting(owner);
1301    }
1302
1303    public Object JavaDoc dynamicGet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, boolean resolve)
1304    {
1305      FeatureMap.Internal featureMap = (FeatureMap.Internal)owner.eGet(featureMapFeature);
1306      return featureMap.setting(feature).get(resolve);
1307    }
1308
1309    public void dynamicSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, Object JavaDoc newValue)
1310    {
1311      FeatureMap.Internal featureMap = (FeatureMap.Internal)owner.eGet(featureMapFeature);
1312      featureMap.setting(feature).set(newValue);
1313    }
1314
1315    public void dynamicUnset(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
1316    {
1317      FeatureMap.Internal featureMap = (FeatureMap.Internal)owner.eGet(featureMapFeature);
1318      featureMap.setting(feature).unset();
1319    }
1320
1321    public boolean dynamicIsSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
1322    {
1323      FeatureMap.Internal featureMap = (FeatureMap.Internal)owner.eGet(featureMapFeature);
1324      return featureMap.setting(feature).isSet();
1325    }
1326
1327    public NotificationChain dynamicInverseAdd
1328      (InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, InternalEObject otherEnd, NotificationChain notifications)
1329    {
1330      FeatureMap.Internal featureMap = (FeatureMap.Internal)owner.eGet(featureMapFeature);
1331      return featureMap.basicAdd(feature, otherEnd, notifications);
1332    }
1333
1334    public NotificationChain dynamicInverseRemove
1335      (InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, InternalEObject otherEnd, NotificationChain notifications)
1336    {
1337      FeatureMap.Internal featureMap = (FeatureMap.Internal)owner.eGet(featureMapFeature);
1338      return featureMap.basicRemove(feature, otherEnd, notifications);
1339    }
1340  }
1341
1342  public static class InternalSettingDelegateMany implements EStructuralFeature.Internal.SettingDelegate
1343  {
1344    public static final int CONTAINMENT_UNSETTABLE_DYNAMIC = 0;
1345    public static final int CONTAINMENT_UNSETTABLE = 1;
1346    public static final int CONTAINMENT_DYNAMIC = 2;
1347    public static final int CONTAINMENT = 3;
1348    public static final int CONTAINMENT_INVERSE_UNSETTABLE_DYNAMIC = 4;
1349    public static final int CONTAINMENT_INVERSE_UNSETTABLE = 5;
1350    public static final int CONTAINMENT_INVERSE_DYNAMIC = 6;
1351    public static final int CONTAINMENT_INVERSE = 7;
1352    public static final int DATA_UNIQUE_UNSETTABLE_DYNAMIC = 8;
1353    public static final int DATA_UNIQUE_UNSETTABLE = 9;
1354    public static final int DATA_UNIQUE_DYNAMIC = 10;
1355    public static final int DATA_UNIQUE = 11;
1356    public static final int DATA_UNSETTABLE_DYNAMIC = 12;
1357    public static final int DATA_UNSETTABLE = 13;
1358    public static final int DATA_DYNAMIC = 14;
1359    public static final int DATA = 15;
1360    public static final int EOBJECT_RESOLVE_UNSETTABLE_DYNAMIC = 16;
1361    public static final int EOBJECT_RESOLVE_UNSETTABLE = 17;
1362    public static final int EOBJECT_RESOLVE_DYNAMIC = 18;
1363    public static final int EOBJECT_RESOLVE = 19;
1364    public static final int EOBJECT_UNSETTABLE_DYNAMIC = 20;
1365    public static final int EOBJECT_UNSETTABLE = 21;
1366    public static final int EOBJECT_DYNAMIC = 22;
1367    public static final int EOBJECT = 23;
1368    public static final int MANY_INVERSE_RESOLVE_UNSETTABLE_DYNAMIC = 24;
1369    public static final int MANY_INVERSE_RESOLVE_UNSETTABLE = 25;
1370    public static final int MANY_INVERSE_RESOLVE_DYNAMIC = 26;
1371    public static final int MANY_INVERSE_RESOLVE = 27;
1372    public static final int MANY_INVERSE_UNSETTABLE_DYNAMIC = 28;
1373    public static final int MANY_INVERSE_UNSETTABLE = 29;
1374    public static final int MANY_INVERSE_DYNAMIC = 30;
1375    public static final int MANY_INVERSE = 31;
1376    public static final int INVERSE_RESOLVE_UNSETTABLE_DYNAMIC = 32;
1377    public static final int INVERSE_RESOLVE_UNSETTABLE = 33;
1378    public static final int INVERSE_RESOLVE_DYNAMIC = 34;
1379    public static final int INVERSE_RESOLVE = 35;
1380    public static final int INVERSE_UNSETTABLE_DYNAMIC = 36;
1381    public static final int INVERSE_UNSETTABLE = 37;
1382    public static final int INVERSE_DYNAMIC = 38;
1383    public static final int INVERSE = 39;
1384    public static final int FEATURE_MAP = 40;
1385    public static final int EMAP = 41;
1386
1387    protected int style;
1388    protected int dynamicKind;
1389    protected Class JavaDoc dataClass;
1390    protected EStructuralFeature feature;
1391    protected EReference inverseFeature;
1392
1393    public InternalSettingDelegateMany(int style, Class JavaDoc dataClass, EStructuralFeature feature)
1394    {
1395      this.style = style;
1396      this.dataClass = dataClass;
1397      this.feature = feature;
1398    }
1399
1400    public InternalSettingDelegateMany(int style, EStructuralFeature feature)
1401    {
1402      this.style = style;
1403      this.dataClass = Object JavaDoc.class;
1404      this.dynamicKind = EcoreEList.Generic.kind(feature);
1405      this.feature = feature;
1406    }
1407
1408    public InternalSettingDelegateMany(int style, Class JavaDoc dataClass, EStructuralFeature feature, EReference inverseFeature)
1409    {
1410      this.style = style;
1411      this.dataClass = dataClass;
1412      this.feature = feature;
1413      this.inverseFeature = inverseFeature;
1414    }
1415
1416    public InternalSettingDelegateMany(int style, EStructuralFeature feature, EReference inverseFeature)
1417    {
1418      this.style = style;
1419      this.dataClass = Object JavaDoc.class;
1420      this.dynamicKind = EcoreEList.Generic.kind(feature);
1421      this.feature = feature;
1422      this.inverseFeature = inverseFeature;
1423    }
1424
1425    protected EStructuralFeature.Setting createDynamicSetting(InternalEObject owner)
1426    {
1427      switch (style)
1428      {
1429        case CONTAINMENT_UNSETTABLE_DYNAMIC:
1430        case CONTAINMENT_DYNAMIC:
1431        case CONTAINMENT_INVERSE_UNSETTABLE_DYNAMIC:
1432        case CONTAINMENT_INVERSE_DYNAMIC:
1433        case DATA_UNIQUE_UNSETTABLE_DYNAMIC:
1434        case DATA_UNIQUE_DYNAMIC:
1435        case DATA_UNSETTABLE_DYNAMIC:
1436        case DATA_DYNAMIC:
1437        case EOBJECT_RESOLVE_UNSETTABLE_DYNAMIC:
1438        case EOBJECT_RESOLVE_DYNAMIC:
1439        case EOBJECT_UNSETTABLE_DYNAMIC:
1440        case EOBJECT_DYNAMIC:
1441        case MANY_INVERSE_RESOLVE_UNSETTABLE_DYNAMIC:
1442        case MANY_INVERSE_RESOLVE_DYNAMIC:
1443        case MANY_INVERSE_UNSETTABLE_DYNAMIC:
1444        case MANY_INVERSE_DYNAMIC:
1445        case INVERSE_RESOLVE_UNSETTABLE_DYNAMIC:
1446        case INVERSE_RESOLVE_DYNAMIC:
1447        case INVERSE_UNSETTABLE_DYNAMIC:
1448        case INVERSE_DYNAMIC:
1449          return new EcoreEList.Dynamic(dynamicKind, dataClass, owner, feature);
1450        case CONTAINMENT_UNSETTABLE:
1451          return new EObjectContainmentEList.Unsettable(dataClass, owner, feature.getFeatureID());
1452        case CONTAINMENT:
1453          return new EObjectContainmentEList(dataClass, owner, feature.getFeatureID());
1454        case EMAP:
1455          return new EcoreEMap((EClass)feature.getEType(), dataClass, owner, feature.getFeatureID());
1456        case CONTAINMENT_INVERSE_UNSETTABLE:
1457          return new EObjectContainmentWithInverseEList.Unsettable(dataClass, owner, feature.getFeatureID(), inverseFeature.getFeatureID());
1458        case CONTAINMENT_INVERSE:
1459          return new EObjectContainmentWithInverseEList(dataClass, owner, feature.getFeatureID(), inverseFeature.getFeatureID());
1460        case DATA_UNIQUE_UNSETTABLE:
1461          return new EDataTypeUniqueEList.Unsettable(dataClass, owner, feature.getFeatureID());
1462        case DATA_UNIQUE:
1463          return new EDataTypeUniqueEList(dataClass, owner, feature.getFeatureID());
1464        case DATA_UNSETTABLE:
1465          return new EDataTypeEList.Unsettable(dataClass, owner, feature.getFeatureID());
1466        case DATA:
1467          return new EDataTypeEList(dataClass, owner, feature.getFeatureID());
1468        case EOBJECT_RESOLVE_UNSETTABLE:
1469          return new EObjectResolvingEList.Unsettable(dataClass, owner, feature.getFeatureID());
1470        case EOBJECT_RESOLVE:
1471          return new EObjectResolvingEList(dataClass, owner, feature.getFeatureID());
1472        case EOBJECT_UNSETTABLE:
1473          return new EObjectEList.Unsettable(dataClass, owner, feature.getFeatureID());
1474        case EOBJECT:
1475          return new EObjectEList(dataClass, owner, feature.getFeatureID());
1476        case MANY_INVERSE_RESOLVE_UNSETTABLE:
1477          return new EObjectWithInverseResolvingEList.Unsettable.ManyInverse(dataClass, owner, feature.getFeatureID(), inverseFeature.getFeatureID());
1478        case MANY_INVERSE_RESOLVE:
1479          return new EObjectWithInverseResolvingEList.ManyInverse(dataClass, owner, feature.getFeatureID(), inverseFeature.getFeatureID());
1480        case MANY_INVERSE_UNSETTABLE:
1481          return new EObjectWithInverseEList.Unsettable.ManyInverse(dataClass, owner, feature.getFeatureID(), inverseFeature.getFeatureID());
1482        case MANY_INVERSE:
1483          return new EObjectWithInverseEList.ManyInverse(dataClass, owner, feature.getFeatureID(), inverseFeature.getFeatureID());
1484        case INVERSE_RESOLVE_UNSETTABLE:
1485          return new EObjectWithInverseResolvingEList.Unsettable(dataClass, owner, feature.getFeatureID(), inverseFeature.getFeatureID());
1486        case INVERSE_RESOLVE:
1487          return new EObjectWithInverseResolvingEList(dataClass, owner, feature.getFeatureID(), inverseFeature.getFeatureID());
1488        case INVERSE_UNSETTABLE:
1489          return new EObjectWithInverseEList.Unsettable(dataClass, owner, feature.getFeatureID(), inverseFeature.getFeatureID());
1490        case INVERSE:
1491          return new EObjectWithInverseEList(dataClass, owner, feature.getFeatureID(), inverseFeature.getFeatureID());
1492        case FEATURE_MAP:
1493          return new BasicFeatureMap(owner, feature.getFeatureID());
1494        default:
1495          throw new RuntimeException JavaDoc("Unknown feature style: " + style);
1496      }
1497    }
1498
1499    public EStructuralFeature.Setting dynamicSetting(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
1500    {
1501      Object JavaDoc setting = settings.dynamicGet(index);
1502      if (setting == null)
1503      {
1504        settings.dynamicSet(index, setting = createDynamicSetting(owner));
1505      }
1506
1507      return
1508        setting instanceof EStructuralFeature.Setting ?
1509          (EStructuralFeature.Setting)setting :
1510          new SettingMany(owner, feature, (List JavaDoc)settings.dynamicGet(index));
1511    }
1512
1513    public Object JavaDoc dynamicGet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, boolean resolve)
1514    {
1515      Object JavaDoc result = settings.dynamicGet(index);
1516      if (result == null)
1517      {
1518        settings.dynamicSet(index, result = createDynamicSetting(owner));
1519      }
1520      return result;
1521    }
1522
1523    public void dynamicSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, Object JavaDoc newValue)
1524    {
1525      EStructuralFeature.Setting setting = (EStructuralFeature.Setting)settings.dynamicGet(index);
1526      if (setting == null)
1527      {
1528        settings.dynamicSet(index, setting = createDynamicSetting(owner));
1529      }
1530      setting.set(newValue);
1531    }
1532
1533    public void dynamicUnset(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
1534    {
1535      EStructuralFeature.Setting setting = (EStructuralFeature.Setting)settings.dynamicGet(index);
1536      if (setting == null)
1537      {
1538        settings.dynamicSet(index, setting = createDynamicSetting(owner));
1539      }
1540      setting.unset();
1541    }
1542
1543    public boolean dynamicIsSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
1544    {
1545      Object JavaDoc setting = settings.dynamicGet(index);
1546      if (setting == null)
1547      {
1548        return false;
1549      }
1550      else
1551      {
1552        return ((EStructuralFeature.Setting)setting).isSet();
1553      }
1554    }
1555
1556    public NotificationChain dynamicInverseAdd
1557      (InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, InternalEObject otherEnd, NotificationChain notifications)
1558    {
1559      Object JavaDoc setting = settings.dynamicGet(index);
1560      if (setting == null)
1561      {
1562        settings.dynamicSet(index, setting = createDynamicSetting(owner));
1563      }
1564      return ((InternalEList)setting).basicAdd(otherEnd, notifications);
1565    }
1566
1567    public NotificationChain dynamicInverseRemove
1568      (InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, InternalEObject otherEnd, NotificationChain notifications)
1569    {
1570      Object JavaDoc setting = settings.dynamicGet(index);
1571      if (setting != null)
1572      {
1573        notifications = ((InternalEList)setting).basicRemove(otherEnd, notifications);
1574      }
1575      return notifications;
1576    }
1577  }
1578
1579  public static abstract class InternalSettingDelegateSingle implements EStructuralFeature.Internal.SettingDelegate
1580  {
1581    public static final Object JavaDoc NIL = EStructuralFeature.Internal.DynamicValueHolder.NIL;
1582
1583    protected EStructuralFeature feature;
1584
1585    public InternalSettingDelegateSingle(EStructuralFeature feature)
1586    {
1587      this.feature = feature;
1588    }
1589
1590    public EStructuralFeature.Setting dynamicSetting(final InternalEObject owner, final EStructuralFeature.Internal.DynamicValueHolder settings, final int index)
1591    {
1592      return
1593        new EStructuralFeature.Setting()
1594        {
1595          public EObject getEObject()
1596          {
1597            return owner;
1598          }
1599
1600          public EStructuralFeature getEStructuralFeature()
1601          {
1602            return feature;
1603          }
1604
1605          public Object JavaDoc get(boolean resolve)
1606          {
1607            return dynamicGet(owner, settings, index, resolve);
1608          }
1609
1610          public void set(Object JavaDoc newValue)
1611          {
1612            dynamicSet(owner, settings, index, newValue);
1613          }
1614
1615          public boolean isSet()
1616          {
1617            return dynamicIsSet(owner, settings, index);
1618          }
1619
1620          public void unset()
1621          {
1622            dynamicUnset(owner, settings, index);
1623          }
1624        };
1625    }
1626
1627    public NotificationChain dynamicInverseAdd
1628      (InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, InternalEObject otherEnd, NotificationChain notifications)
1629    {
1630      throw new UnsupportedOperationException JavaDoc();
1631    }
1632
1633    public NotificationChain dynamicInverseRemove
1634      (InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, InternalEObject otherEnd, NotificationChain notifications)
1635    {
1636      throw new UnsupportedOperationException JavaDoc();
1637    }
1638  }
1639
1640  public static class InternalSettingDelegateSingleContainer extends InternalSettingDelegateSingle
1641  {
1642    protected EClass eClass;
1643    protected EReference inverseFeature;
1644
1645    public InternalSettingDelegateSingleContainer(EClass eClass, EStructuralFeature feature, EReference inverseFeature)
1646    {
1647      super(feature);
1648      this.eClass = eClass;
1649      this.inverseFeature = inverseFeature;
1650    }
1651
1652    public Object JavaDoc dynamicGet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, boolean resolve)
1653    {
1654      return owner.eContainmentFeature() == inverseFeature ? owner.eContainer() : null;
1655    }
1656
1657    public void dynamicSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, Object JavaDoc newValue)
1658    {
1659      if (newValue != null && !eClass.isInstance(newValue))
1660      {
1661        throw
1662          new ClassCastException JavaDoc
1663            ("The value of type '" +
1664               (newValue instanceof EObject ? ((EObject)newValue).eClass().toString() : newValue.getClass().toString()) +
1665               "' must be of type '" + eClass + "'");
1666      }
1667
1668      EObject eContainer = owner.eContainer();
1669      int featureID = owner.eClass().getFeatureID(feature);
1670      if (newValue != eContainer || (owner.eContainerFeatureID() != featureID && newValue != null))
1671      {
1672        if (EcoreUtil.isAncestor(owner, (EObject)newValue))
1673          throw new IllegalArgumentException JavaDoc("Recursive containment not allowed for " + owner.toString());
1674
1675        NotificationChain notifications = null;
1676        if (eContainer != null)
1677        {
1678          notifications = owner.eBasicRemoveFromContainer(notifications);
1679        }
1680
1681        InternalEObject internalEObject = (InternalEObject)newValue;
1682        if (newValue != null)
1683        {
1684          notifications =
1685            internalEObject.eInverseAdd
1686              (owner, internalEObject.eClass().getFeatureID(inverseFeature), null, notifications);
1687        }
1688
1689        notifications = owner.eBasicSetContainer(internalEObject, featureID, notifications);
1690        if (notifications != null) notifications.dispatch();
1691      }
1692      else
1693      {
1694        if (owner.eNotificationRequired())
1695          owner.eNotify(new ENotificationImpl(owner, Notification.SET, featureID, newValue, newValue));
1696      }
1697    }
1698
1699    public void dynamicUnset(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
1700    {
1701      EObject eContainer = owner.eContainer();
1702      if (eContainer != null)
1703      {
1704        NotificationChain notifications = null;
1705        if (eContainer != null)
1706        {
1707          notifications = owner.eBasicRemoveFromContainer(notifications);
1708        }
1709        int featureID = owner.eClass().getFeatureID(feature);
1710        notifications = owner.eBasicSetContainer(null, featureID, notifications);
1711        if (notifications != null) notifications.dispatch();
1712      }
1713      else
1714      {
1715        if (owner.eNotificationRequired())
1716          owner.eNotify(new ENotificationImpl(owner, Notification.SET, feature, null, null));
1717      }
1718    }
1719
1720    public boolean dynamicIsSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
1721    {
1722      int featureID = owner.eClass().getFeatureID(feature);
1723      return owner.eContainer() != null && owner.eContainerFeatureID() == featureID;
1724    }
1725
1726    public NotificationChain dynamicInverseAdd
1727      (InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, InternalEObject otherEnd, NotificationChain notifications)
1728    {
1729      if (owner.eContainer() != null)
1730      {
1731        notifications = owner.eBasicRemoveFromContainer(notifications);
1732      }
1733      int featureID = owner.eClass().getFeatureID(feature);
1734      return owner.eBasicSetContainer(otherEnd, featureID, notifications);
1735    }
1736
1737    public NotificationChain dynamicInverseRemove
1738      (InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, InternalEObject otherEnd, NotificationChain notifications)
1739    {
1740      if (owner.eContainer() != null)
1741      {
1742        notifications = owner.eBasicRemoveFromContainer(notifications);
1743      }
1744      int featureID = owner.eClass().getFeatureID(feature);
1745      return owner.eBasicSetContainer(null, featureID, notifications);
1746    }
1747  }
1748
1749  public static class InternalSettingDelegateSingleData extends InternalSettingDelegateSingle
1750  {
1751    protected Object JavaDoc defaultValue;
1752    protected Object JavaDoc intrinsicDefaultValue;
1753
1754    public InternalSettingDelegateSingleData(Object JavaDoc defaultValue, Object JavaDoc intrinsicDefaultValue, EStructuralFeature feature)
1755    {
1756      super(feature);
1757      this.defaultValue = defaultValue;
1758      this.intrinsicDefaultValue = intrinsicDefaultValue;
1759    }
1760
1761    protected void validate(Object JavaDoc object)
1762    {
1763      throw new ClassCastException JavaDoc();
1764    }
1765
1766    public Object JavaDoc dynamicGet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, boolean resolve)
1767    {
1768      Object JavaDoc result = settings.dynamicGet(index);
1769      if (result == null)
1770      {
1771        return this.defaultValue;
1772      }
1773      else if (result == NIL)
1774      {
1775        return null;
1776      }
1777      else
1778      {
1779        return result;
1780      }
1781    }
1782
1783    public void dynamicSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, Object JavaDoc newValue)
1784    {
1785      if (owner.eNotificationRequired())
1786      {
1787        Object JavaDoc oldValue = dynamicGet(owner, settings, index, false);
1788
1789        if (newValue == null)
1790        {
1791          if (intrinsicDefaultValue != null)
1792          {
1793            settings.dynamicSet(index, null);
1794            newValue = defaultValue;
1795          }
1796          else if (defaultValue != null)
1797          {
1798            settings.dynamicSet(index, NIL);
1799          }
1800          else
1801          {
1802            settings.dynamicSet(index, null);
1803          }
1804        }
1805        else
1806        {
1807          validate(newValue);
1808          settings.dynamicSet(index, newValue);
1809        }
1810
1811        owner.eNotify
1812          (new ENotificationImpl
1813             (owner,
1814              Notification.SET,
1815              feature,
1816              oldValue,
1817              newValue));
1818      }
1819      else
1820      {
1821        if (newValue == null)
1822        {
1823          if (intrinsicDefaultValue != null)
1824          {
1825            settings.dynamicSet(index, null);
1826          }
1827          else if (defaultValue != null)
1828          {
1829            settings.dynamicSet(index, NIL);
1830          }
1831          else
1832          {
1833            settings.dynamicSet(index, null);
1834          }
1835        }
1836        else
1837        {
1838          validate(newValue);
1839          settings.dynamicSet(index, newValue);
1840        }
1841      }
1842    }
1843
1844    public void dynamicUnset(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
1845    {
1846      if (owner.eNotificationRequired())
1847      {
1848        Object JavaDoc oldValue = dynamicGet(owner, settings, index, false);
1849        settings.dynamicUnset(index);
1850        owner.eNotify
1851          (new ENotificationImpl
1852             (owner, Notification.SET, feature, oldValue, this.defaultValue));
1853      }
1854      else
1855      {
1856        settings.dynamicUnset(index);
1857      }
1858    }
1859
1860    public boolean dynamicIsSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
1861    {
1862      Object JavaDoc setting = settings.dynamicGet(index);
1863      if (setting == null)
1864      {
1865        return false;
1866      }
1867      else if (setting == NIL)
1868      {
1869        return true;
1870      }
1871      else
1872      {
1873        return !setting.equals(this.defaultValue);
1874      }
1875    }
1876  }
1877
1878  public static class InternalSettingDelegateSingleDataDynamic extends InternalSettingDelegateSingleData
1879  {
1880    protected EDataType eDataType;
1881
1882    public InternalSettingDelegateSingleDataDynamic(EDataType eDataType, Object JavaDoc defaultValue, Object JavaDoc intrinsicDefaultValue, EStructuralFeature feature)
1883    {
1884      super(defaultValue, intrinsicDefaultValue, feature);
1885      this.eDataType = eDataType;
1886    }
1887
1888    protected void validate(Object JavaDoc object)
1889    {
1890      if (!eDataType.isInstance(object))
1891      {
1892        throw new ClassCastException JavaDoc("The value of type '" + object.getClass() + "' must be of type '" + eDataType + "'");
1893      }
1894    }
1895  }
1896
1897  public static class InternalSettingDelegateSingleDataStatic extends InternalSettingDelegateSingleData
1898  {
1899    protected Class JavaDoc dataClass;
1900
1901    public InternalSettingDelegateSingleDataStatic(Class JavaDoc dataClass, Object JavaDoc defaultValue, Object JavaDoc intrinsicDefaultValue, EStructuralFeature feature)
1902    {
1903      super(defaultValue, intrinsicDefaultValue, feature);
1904      this.dataClass = dataClass;
1905    }
1906
1907    protected void validate(Object JavaDoc object)
1908    {
1909      if (!dataClass.isInstance(object))
1910      {
1911        throw new ClassCastException JavaDoc("The value of type '" + object.getClass() + "' must be of type '" + dataClass + "'");
1912      }
1913    }
1914  }
1915
1916  public static class InternalSettingDelegateSingleDataUnsettable extends InternalSettingDelegateSingleData
1917  {
1918    public InternalSettingDelegateSingleDataUnsettable(Object JavaDoc defaultValue, Object JavaDoc intrinsicDefaultValue, EStructuralFeature feature)
1919    {
1920      super(defaultValue, intrinsicDefaultValue, feature);
1921    }
1922
1923    public void dynamicSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, Object JavaDoc newValue)
1924    {
1925      if (owner.eNotificationRequired())
1926      {
1927        boolean oldIsSet = true;
1928        Object JavaDoc oldValue = settings.dynamicGet(index);
1929        if (oldValue == null)
1930        {
1931          oldIsSet = false;
1932          oldValue = this.defaultValue;
1933        }
1934        else if (oldValue == NIL)
1935        {
1936          oldValue = null;
1937        }
1938
1939        if (newValue == null)
1940        {
1941          if (intrinsicDefaultValue != null)
1942          {
1943            settings.dynamicSet(index, null);
1944            newValue = this.defaultValue;
1945          }
1946          else
1947          {
1948            settings.dynamicSet(index, NIL);
1949          }
1950        }
1951        else
1952        {
1953          validate(newValue);
1954          settings.dynamicSet(index, newValue);
1955        }
1956
1957        owner.eNotify
1958          (new ENotificationImpl
1959             (owner,
1960              Notification.SET,
1961              feature,
1962              oldValue,
1963              newValue,
1964              !oldIsSet));
1965      }
1966      else
1967      {
1968        if (newValue == null)
1969        {
1970          if (intrinsicDefaultValue != null)
1971          {
1972            settings.dynamicSet(index, null);
1973          }
1974          else
1975          {
1976            settings.dynamicSet(index, NIL);
1977          }
1978        }
1979        else
1980        {
1981          validate(newValue);
1982          settings.dynamicSet(index, newValue);
1983        }
1984      }
1985    }
1986
1987    public void dynamicUnset(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
1988    {
1989      if (owner.eNotificationRequired())
1990      {
1991        boolean oldIsSet = true;
1992        Object JavaDoc oldValue = settings.dynamicGet(index);
1993        if (oldValue == null)
1994        {
1995          oldIsSet = false;
1996          oldValue = this.defaultValue;
1997        }
1998        else if (oldValue == NIL)
1999        {
2000          oldValue = null;
2001        }
2002        settings.dynamicUnset(index);
2003        owner.eNotify
2004          (new ENotificationImpl
2005             (owner, Notification.UNSET, feature, oldValue, this.defaultValue, oldIsSet));
2006      }
2007      else
2008      {
2009        settings.dynamicUnset(index);
2010      }
2011    }
2012
2013    public boolean dynamicIsSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
2014    {
2015      Object JavaDoc setting = settings.dynamicGet(index);
2016      if (setting == null)
2017      {
2018        return false;
2019      }
2020      else
2021      {
2022        return true;
2023      }
2024    }
2025  }
2026
2027  public static class InternalSettingDelegateSingleDataUnsettableDynamic extends InternalSettingDelegateSingleDataUnsettable
2028  {
2029    protected EDataType eDataType;
2030
2031    public InternalSettingDelegateSingleDataUnsettableDynamic(EDataType eDataType, Object JavaDoc defaultValue, Object JavaDoc intrinsicDefaultValue, EStructuralFeature feature)
2032    {
2033      super(defaultValue, intrinsicDefaultValue, feature);
2034      this.eDataType = eDataType;
2035    }
2036
2037    protected void validate(Object JavaDoc object)
2038    {
2039      if (!eDataType.isInstance(object))
2040      {
2041        throw new ClassCastException JavaDoc("The value of type '" + object.getClass() + "' must be of type '" + eDataType + "'");
2042      }
2043    }
2044  }
2045
2046  public static class InternalSettingDelegateSingleDataUnsettableStatic extends InternalSettingDelegateSingleDataUnsettable
2047  {
2048    protected Class JavaDoc dataClass;
2049
2050    public InternalSettingDelegateSingleDataUnsettableStatic(Class JavaDoc dataClass, Object JavaDoc defaultValue, Object JavaDoc intrinsicDefaultValue, EStructuralFeature feature)
2051    {
2052      super(defaultValue, intrinsicDefaultValue, feature);
2053      this.dataClass = dataClass;
2054    }
2055
2056    protected void validate(Object JavaDoc object)
2057    {
2058      if (!dataClass.isInstance(object))
2059      {
2060        throw new ClassCastException JavaDoc("The value of type '" + object.getClass() + "' must be of type '" + dataClass + "'");
2061      }
2062    }
2063  }
2064
2065  public static class InternalSettingDelegateSingleEObject extends InternalSettingDelegateSingle
2066  {
2067    protected EClass eClass;
2068    protected EReference inverseFeature;
2069
2070    public InternalSettingDelegateSingleEObject(EClass eClass, EStructuralFeature feature)
2071    {
2072      super(feature);
2073      this.eClass = eClass;
2074    }
2075
2076    public InternalSettingDelegateSingleEObject(EClass eClass, EStructuralFeature feature, EReference inverseFeature)
2077    {
2078      super(feature);
2079      this.eClass = eClass;
2080      this.inverseFeature = inverseFeature;
2081    }
2082
2083    protected boolean isUnsettable()
2084    {
2085      return false;
2086    }
2087
2088    protected boolean hasInverse()
2089    {
2090      return false;
2091    }
2092
2093    protected boolean isContainment()
2094    {
2095      return false;
2096    }
2097
2098    protected boolean isResolveProxies()
2099    {
2100      return false;
2101    }
2102
2103    public Object JavaDoc dynamicGet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, boolean resolve)
2104    {
2105      Object JavaDoc result = settings.dynamicGet(index);
2106      if (isUnsettable() && result == NIL)
2107      {
2108        return null;
2109      }
2110      else if (isResolveProxies() && resolve && result != null)
2111      {
2112        InternalEObject oldEObject = (InternalEObject)result;
2113        if (oldEObject.eIsProxy())
2114        {
2115          EObject resolvedEObject = owner.eResolveProxy(oldEObject);
2116          if (oldEObject != resolvedEObject)
2117          {
2118            if (!eClass.isInstance(resolvedEObject))
2119            {
2120              throw new ClassCastException JavaDoc("The value of type '" + resolvedEObject.getClass() + "' must be of type '" + eClass + "'");
2121            }
2122            settings.dynamicSet(index, result = resolvedEObject);
2123            if (owner.eNotificationRequired())
2124            {
2125              owner.eNotify
2126                (new ENotificationImpl(owner, Notification.RESOLVE, feature, oldEObject, resolvedEObject));
2127            }
2128          }
2129        }
2130
2131        return result;
2132      }
2133      else
2134      {
2135        return result;
2136      }
2137    }
2138
2139
2140    public void dynamicSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, Object JavaDoc newValue)
2141    {
2142      Object JavaDoc oldValue = settings.dynamicGet(index);
2143      boolean oldIsSet = oldValue != null;
2144      if (isUnsettable() && oldValue == NIL)
2145      {
2146        oldValue = null;
2147      }
2148
2149      NotificationChain notifications = null;
2150      if (hasInverse())
2151      {
2152        if (oldValue != newValue)
2153        {
2154          if (oldValue != null)
2155          {
2156            InternalEObject internalEObject = (InternalEObject)oldValue;
2157            notifications =
2158              internalEObject.eInverseRemove
2159                (owner,
2160                 internalEObject.eClass().getFeatureID(inverseFeature),
2161                 null,
2162                 notifications);
2163          }
2164          if (newValue != null)
2165          {
2166            InternalEObject internalEObject = (InternalEObject)newValue;
2167            notifications =
2168              internalEObject.eInverseAdd
2169                (owner,
2170                 internalEObject.eClass().getFeatureID(inverseFeature),
2171                 null,
2172                 notifications);
2173          }
2174        }
2175      }
2176      else if (isContainment())
2177      {
2178        if (oldValue != newValue)
2179        {
2180          if (oldValue != null)
2181          {
2182            notifications =
2183              ((InternalEObject)oldValue).eInverseRemove
2184                (owner,
2185                 InternalEObject.EOPPOSITE_FEATURE_BASE - feature.getFeatureID(),
2186                 null,
2187                 notifications);
2188          }
2189          if (newValue != null)
2190          {
2191            notifications =
2192              ((InternalEObject)newValue).eInverseAdd
2193                (owner,
2194                 InternalEObject.EOPPOSITE_FEATURE_BASE - feature.getFeatureID(),
2195                 null,
2196                 notifications);
2197          }
2198        }
2199      }
2200
2201      if (newValue == null && isUnsettable())
2202      {
2203        settings.dynamicSet(index, NIL);
2204      }
2205      else
2206      {
2207        settings.dynamicSet(index, newValue);
2208      }
2209
2210      if (owner.eNotificationRequired())
2211      {
2212        Notification notification =
2213          new ENotificationImpl
2214            (owner,
2215             Notification.SET,
2216             feature,
2217             oldValue,
2218             newValue,
2219             isUnsettable() && !oldIsSet);
2220        if (notifications == null)
2221        {
2222          owner.eNotify(notification);
2223        }
2224        else
2225        {
2226          notifications.add(notification);
2227          notifications.dispatch();
2228        }
2229      }
2230      else if (notifications != null)
2231      {
2232        notifications.dispatch();
2233      }
2234    }
2235
2236    public void dynamicUnset(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
2237    {
2238      Object JavaDoc oldValue = settings.dynamicGet(index);
2239      if (isUnsettable() && oldValue == NIL)
2240      {
2241        oldValue = null;
2242      }
2243
2244      NotificationChain notifications = null;
2245      if (oldValue != null)
2246      {
2247        if (hasInverse())
2248        {
2249          InternalEObject internalEObject = (InternalEObject)oldValue;
2250          notifications =
2251            internalEObject.eInverseRemove
2252              (owner,
2253               internalEObject.eClass().getFeatureID(inverseFeature),
2254               null,
2255               notifications);
2256        }
2257        else if (isContainment())
2258        {
2259          notifications =
2260            ((InternalEObject)oldValue).eInverseRemove
2261              (owner,
2262               InternalEObject.EOPPOSITE_FEATURE_BASE - feature.getFeatureID(),
2263               null,
2264               notifications);
2265        }
2266      }
2267
2268      settings.dynamicUnset(index);
2269
2270      if (owner.eNotificationRequired())
2271      {
2272        Notification notification =
2273          new ENotificationImpl
2274            (owner,
2275             isUnsettable() ? Notification.UNSET : Notification.SET,
2276             feature,
2277             oldValue,
2278             null);
2279        if (notifications == null)
2280        {
2281          owner.eNotify(notification);
2282        }
2283        else
2284        {
2285          notifications.add(notification);
2286          notifications.dispatch();
2287        }
2288      }
2289      else if (notifications != null)
2290      {
2291        notifications.dispatch();
2292      }
2293    }
2294
2295    public boolean dynamicIsSet(InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index)
2296    {
2297      Object JavaDoc setting = settings.dynamicGet(index);
2298      if (setting == null)
2299      {
2300        return false;
2301      }
2302      else if (setting == NIL)
2303      {
2304        return true;
2305      }
2306      else if (isUnsettable())
2307      {
2308        return true;
2309      }
2310      else
2311      {
2312        return setting != null;
2313      }
2314    }
2315
2316    public NotificationChain dynamicInverseAdd
2317      (InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, InternalEObject otherEnd, NotificationChain notifications)
2318    {
2319      Object JavaDoc oldValue = settings.dynamicGet(index);
2320      if (oldValue == NIL)
2321      {
2322        oldValue = null;
2323      }
2324
2325      if (hasInverse())
2326      {
2327        if (oldValue != otherEnd && oldValue != null)
2328        {
2329          InternalEObject internalEObject = (InternalEObject)oldValue;
2330          notifications =
2331            internalEObject.eInverseRemove
2332              (owner,
2333               internalEObject.eClass().getFeatureID(inverseFeature),
2334               null,
2335               notifications);
2336        }
2337      }
2338      else if (isContainment())
2339      {
2340        if (oldValue != null)
2341        {
2342          notifications =
2343            ((InternalEObject)oldValue).eInverseRemove
2344              (owner,
2345               InternalEObject.EOPPOSITE_FEATURE_BASE - feature.getFeatureID(),
2346               null,
2347               notifications);
2348        }
2349      }
2350
2351      settings.dynamicSet(index, otherEnd);
2352
2353      if (owner.eNotificationRequired())
2354      {
2355        if (notifications == null) notifications = new NotificationChainImpl(4);
2356        notifications.add
2357          (new ENotificationImpl
2358             (owner,
2359              Notification.SET,
2360              feature,
2361              oldValue,
2362              otherEnd));
2363      }
2364
2365      return notifications;
2366    }
2367
2368    public NotificationChain dynamicInverseRemove
2369      (InternalEObject owner, EStructuralFeature.Internal.DynamicValueHolder settings, int index, InternalEObject otherEnd, NotificationChain notifications)
2370    {
2371      Object JavaDoc oldValue = settings.dynamicGet(index);
2372      if (oldValue == NIL)
2373      {
2374        oldValue = null;
2375      }
2376
2377      settings.dynamicUnset(index);
2378
2379      if (owner.eNotificationRequired())
2380      {
2381        if (notifications == null) notifications = new NotificationChainImpl(4);
2382        if (isUnsettable())
2383        {
2384          notifications.add(new ENotificationImpl(owner, Notification.UNSET, feature, oldValue, null));
2385        }
2386        else
2387        {
2388          notifications.add(new ENotificationImpl(owner, Notification.SET, feature, oldValue, null));
2389        }
2390      }
2391
2392      return notifications;
2393    }
2394  }
2395
2396  public static class InternalSettingDelegateSingleEObjectUnsettable extends InternalSettingDelegateSingleEObject
2397  {
2398    public InternalSettingDelegateSingleEObjectUnsettable(EClass eClass, EStructuralFeature feature)
2399    {
2400      super(eClass, feature);
2401    }
2402
2403    protected boolean isUnsettable()
2404    {
2405      return true;
2406    }
2407  }
2408
2409  public static class InternalSettingDelegateSingleEObjectWithInverse extends InternalSettingDelegateSingleEObject
2410  {
2411    public InternalSettingDelegateSingleEObjectWithInverse(EClass eClass, EStructuralFeature feature, EReference inverseFeature)
2412    {
2413      super(eClass, feature, inverseFeature);
2414    }
2415
2416    protected boolean hasInverse()
2417    {
2418      return true;
2419    }
2420  }
2421
2422  public static class InternalSettingDelegateSingleEObjectWithInverseUnsettable extends InternalSettingDelegateSingleEObjectWithInverse
2423  {
2424    public InternalSettingDelegateSingleEObjectWithInverseUnsettable(EClass eClass, EStructuralFeature feature, EReference inverseFeature)
2425    {
2426      super(eClass, feature, inverseFeature);
2427    }
2428
2429    protected boolean isUnsettable()
2430    {
2431      return true;
2432    }
2433  }
2434
2435  public static class InternalSettingDelegateSingleEObjectContainment extends InternalSettingDelegateSingleEObject
2436  {
2437    public InternalSettingDelegateSingleEObjectContainment(EClass eClass, EStructuralFeature feature)
2438    {
2439      super(eClass, feature);
2440    }
2441
2442    public InternalSettingDelegateSingleEObjectContainment(EClass eClass, EStructuralFeature feature, EReference inverseFeature)
2443    {
2444      super(eClass, feature, inverseFeature);
2445    }
2446
2447    protected boolean isContainment()
2448    {
2449      return true;
2450    }
2451  }
2452
2453  public static class InternalSettingDelegateSingleEObjectContainmentWithInverse extends InternalSettingDelegateSingleEObjectContainment
2454  {
2455    public InternalSettingDelegateSingleEObjectContainmentWithInverse(EClass eClass, EStructuralFeature feature, EReference inverseFeature)
2456    {
2457      super(eClass, feature, inverseFeature);
2458    }
2459
2460    protected boolean hasInverse()
2461    {
2462      return true;
2463    }
2464  }
2465
2466  public static class InternalSettingDelegateSingleEObjectContainmentUnsettable extends InternalSettingDelegateSingleEObjectContainment
2467  {
2468    public InternalSettingDelegateSingleEObjectContainmentUnsettable(EClass eClass, EStructuralFeature feature)
2469    {
2470      super(eClass, feature);
2471    }
2472
2473    protected boolean isUnsettable()
2474    {
2475      return true;
2476    }
2477  }
2478
2479  public static class InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettable extends InternalSettingDelegateSingleEObjectContainmentWithInverse
2480  {
2481    public InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettable(EClass eClass, EStructuralFeature feature, EReference inverseFeature)
2482    {
2483      super(eClass, feature, inverseFeature);
2484    }
2485
2486    protected boolean isUnsettable()
2487    {
2488      return true;
2489    }
2490  }
2491
2492  public static class InternalSettingDelegateSingleEObjectResolving extends InternalSettingDelegateSingleEObject
2493  {
2494    public InternalSettingDelegateSingleEObjectResolving(EClass eClass, EStructuralFeature feature)
2495    {
2496      super(eClass, feature);
2497    }
2498
2499    public InternalSettingDelegateSingleEObjectResolving(EClass eClass, EStructuralFeature feature, EReference inverseFeature)
2500    {
2501      super(eClass, feature, inverseFeature);
2502    }
2503
2504    protected boolean isResolveProxies()
2505    {
2506      return true;
2507    }
2508  }
2509
2510  public static class InternalSettingDelegateSingleEObjectResolvingUnsettable extends InternalSettingDelegateSingleEObject
2511  {
2512    public InternalSettingDelegateSingleEObjectResolvingUnsettable(EClass eClass, EStructuralFeature feature)
2513    {
2514      super(eClass, feature);
2515    }
2516
2517    protected boolean isUnsettable()
2518    {
2519      return true;
2520    }
2521  }
2522
2523  public static class InternalSettingDelegateSingleEObjectResolvingWithInverse extends InternalSettingDelegateSingleEObjectResolving
2524  {
2525    public InternalSettingDelegateSingleEObjectResolvingWithInverse(EClass eClass, EStructuralFeature feature, EReference inverseFeature)
2526    {
2527      super(eClass, feature, inverseFeature);
2528    }
2529
2530    protected boolean hasInverse()
2531    {
2532      return true;
2533    }
2534  }
2535
2536  public static class InternalSettingDelegateSingleEObjectResolvingWithInverseUnsettable extends InternalSettingDelegateSingleEObjectResolvingWithInverse
2537  {
2538    public InternalSettingDelegateSingleEObjectResolvingWithInverseUnsettable(EClass eClass, EStructuralFeature feature, EReference inverseFeature)
2539    {
2540      super(eClass, feature, inverseFeature);
2541    }
2542
2543    protected boolean isUnsettable()
2544    {
2545      return true;
2546    }
2547  }
2548
2549  public static class SettingMany implements EStructuralFeature.Setting
2550  {
2551    protected EObject owner;
2552    protected EStructuralFeature eStructuralFeature;
2553    protected List JavaDoc list;
2554    public SettingMany(EObject owner, EStructuralFeature eStructuralFeature, List JavaDoc list)
2555    {
2556      this.list = list;
2557    }
2558
2559    public EObject getEObject()
2560    {
2561      return owner;
2562    }
2563
2564    public EStructuralFeature getEStructuralFeature()
2565    {
2566      return eStructuralFeature;
2567    }
2568
2569    public Object JavaDoc get(boolean resolve)
2570    {
2571      return list;
2572    }
2573
2574    public void set(Object JavaDoc newValue)
2575    {
2576      list.clear();
2577      list.addAll((List JavaDoc)newValue);
2578    }
2579
2580    public boolean isSet()
2581    {
2582      return
2583        list instanceof InternalEList.Unsettable ?
2584          ((InternalEList.Unsettable)list).isSet() :
2585          !list.isEmpty();
2586    }
2587
2588    public void unset()
2589    {
2590      if (list instanceof InternalEList.Unsettable)
2591      {
2592        ((InternalEList.Unsettable)list).unset();
2593      }
2594      else
2595      {
2596        list.clear();
2597      }
2598    }
2599  }
2600
2601  protected EClassifier cachedEType;
2602  protected boolean cachedIsFeatureMap;
2603
2604  public boolean isFeatureMap()
2605  {
2606    if (cachedEType != eType)
2607    {
2608      cachedEType = getEType();
2609      cachedIsFeatureMap = eType != null && eType.getInstanceClassName() == "org.eclipse.emf.ecore.util.FeatureMap$Entry";
2610    }
2611    return cachedIsFeatureMap;
2612  }
2613
2614  protected BasicExtendedMetaData.EStructuralFeatureExtendedMetaData eStructuralFeatureExtendedMetaData;
2615
2616  public BasicExtendedMetaData.EStructuralFeatureExtendedMetaData getExtendedMetaData()
2617  {
2618    return eStructuralFeatureExtendedMetaData;
2619  }
2620
2621  public void setExtendedMetaData(BasicExtendedMetaData.EStructuralFeatureExtendedMetaData eStructuralFeatureExtendedMetaData)
2622  {
2623    this.eStructuralFeatureExtendedMetaData = eStructuralFeatureExtendedMetaData;
2624  }
2625}
2626
Popular Tags