KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: EClassImpl.java,v 1.17 2005/06/08 06:20:10 nickb Exp $
16  */

17
18 package org.eclipse.emf.ecore.impl;
19
20
21 import java.util.Collection JavaDoc;
22 import java.util.HashMap JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.Map JavaDoc;
25
26 import org.eclipse.emf.common.notify.Notification;
27 import org.eclipse.emf.common.notify.NotificationChain;
28 import org.eclipse.emf.common.util.BasicEList;
29 import org.eclipse.emf.common.util.EList;
30 import org.eclipse.emf.common.util.UniqueEList;
31 import org.eclipse.emf.ecore.EAttribute;
32 import org.eclipse.emf.ecore.EClass;
33 import org.eclipse.emf.ecore.EClassifier;
34 import org.eclipse.emf.ecore.EObject;
35 import org.eclipse.emf.ecore.EOperation;
36 import org.eclipse.emf.ecore.EPackage;
37 import org.eclipse.emf.ecore.EReference;
38 import org.eclipse.emf.ecore.EStructuralFeature;
39 import org.eclipse.emf.ecore.EcorePackage;
40 import org.eclipse.emf.ecore.InternalEObject;
41 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
42 import org.eclipse.emf.ecore.util.EObjectResolvingEList;
43 import org.eclipse.emf.ecore.util.EcoreEList;
44 import org.eclipse.emf.ecore.util.EcoreUtil;
45 import org.eclipse.emf.ecore.util.ExtendedMetaData;
46 import org.eclipse.emf.ecore.util.FeatureMapUtil;
47 import org.eclipse.emf.ecore.util.InternalEList;
48
49
50 /**
51  * <!-- begin-user-doc -->
52  * An implementation of the model object '<em><b>EClass</b></em>'.
53  * @extends ESuperAdapter.Holder
54  * @ignore
55  * <!-- end-user-doc -->
56  * <p>
57  * The following features are implemented:
58  * <ul>
59  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#isAbstract <em>Abstract</em>}</li>
60  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#isInterface <em>Interface</em>}</li>
61  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getESuperTypes <em>ESuper Types</em>}</li>
62  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getEOperations <em>EOperations</em>}</li>
63  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getEAllAttributes <em>EAll Attributes</em>}</li>
64  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getEAllReferences <em>EAll References</em>}</li>
65  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getEReferences <em>EReferences</em>}</li>
66  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getEAttributes <em>EAttributes</em>}</li>
67  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getEAllContainments <em>EAll Containments</em>}</li>
68  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getEAllOperations <em>EAll Operations</em>}</li>
69  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getEAllStructuralFeatures <em>EAll Structural Features</em>}</li>
70  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getEAllSuperTypes <em>EAll Super Types</em>}</li>
71  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getEIDAttribute <em>EID Attribute</em>}</li>
72  * <li>{@link org.eclipse.emf.ecore.impl.EClassImpl#getEStructuralFeatures <em>EStructural Features</em>}</li>
73  * </ul>
74  * </p>
75  *
76  * @generated
77  */

78 public class EClassImpl extends EClassifierImpl implements EClass, ESuperAdapter.Holder
79 {
80   public interface FeatureSubsetSupplier
81   {
82     EStructuralFeature [] containments();
83     EStructuralFeature [] crossReferences();
84     EStructuralFeature [] features();
85   }
86
87   protected EAttribute eIDAttribute;
88   protected BasicEList eAllAttributes;
89   protected BasicEList eAllReferences;
90   protected BasicEList eAllStructuralFeatures;
91   protected EStructuralFeature[] eAllStructuralFeaturesData;
92   protected BasicEList eAllContainments;
93   protected BasicEList eAllOperations;
94   protected BasicEList eAllSuperTypes;
95   protected Map JavaDoc eNameToFeatureMap;
96   protected ESuperAdapter eSuperAdapter;
97
98   /**
99    * <!-- begin-user-doc -->
100    * <!-- end-user-doc -->
101    * @generated
102    */

103   protected EClassImpl()
104   {
105     super();
106   }
107
108   public void freeze()
109   {
110     getEAllAttributes();
111     getEAllReferences();
112     getEAllContainments();
113     getEAllOperations();
114     getEAllStructuralFeatures();
115     getEAllSuperTypes();
116
117     getESuperAdapter().getSubclasses().clear();
118     
119     super.freeze();
120   }
121   
122   public boolean isFrozen()
123   {
124     return super.isFrozen();
125   }
126
127   /**
128    * <!-- begin-user-doc -->
129    * <!-- end-user-doc -->
130    * @generated
131    */

132   protected EClass eStaticClass()
133   {
134     return EcorePackage.eINSTANCE.getEClass();
135   }
136
137   /**
138    * <!-- begin-user-doc -->
139    * <!-- end-user-doc -->
140    * @generated NOT
141    */

142   public EAttribute getEIDAttribute()
143   {
144     getEAllAttributes();
145     return eIDAttribute;
146   }
147
148   /**
149    * <!-- begin-user-doc -->
150    * <!-- end-user-doc -->
151    * @generated
152    */

153   public EList getEStructuralFeatures()
154   {
155     if (eStructuralFeatures == null)
156     {
157       eStructuralFeatures = new EObjectContainmentWithInverseEList(EStructuralFeature.class, this, EcorePackage.ECLASS__ESTRUCTURAL_FEATURES, EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS);
158     }
159     return eStructuralFeatures;
160   }
161
162   public EList getEAllAttributes()
163   {
164     if (eAllAttributes == null)
165     {
166       eIDAttribute = null;
167
168       BasicEList result =
169         new UniqueEList()
170         {
171           protected Object JavaDoc [] newData(int capacity)
172           {
173             return new EAttribute [capacity];
174           }
175
176           protected boolean useEquals()
177           {
178             return false;
179           }
180
181           protected void didAdd(int index, Object JavaDoc object)
182           {
183             EAttribute eAttribute = (EAttribute)object;
184             if (eAttribute.isID() && eIDAttribute == null)
185             {
186               eIDAttribute = eAttribute;
187             }
188           }
189         };
190
191       BasicEList attributes =
192         new UniqueEList()
193         {
194           protected Object JavaDoc [] newData(int capacity)
195           {
196             return new EAttribute [capacity];
197           }
198
199           protected boolean useEquals()
200           {
201             return false;
202           }
203         };
204
205       for (Iterator JavaDoc i = getESuperTypes().iterator(); i.hasNext(); )
206       {
207         EClass eSuperType = (EClass)i.next();
208         result.addAll(eSuperType.getEAllAttributes());
209       }
210       for (Iterator JavaDoc i = getEStructuralFeatures().iterator(); i.hasNext(); )
211       {
212         EStructuralFeature eStructuralFeature = (EStructuralFeature)i.next();
213         if (eStructuralFeature instanceof EAttribute)
214         {
215           attributes.add(eStructuralFeature);
216         }
217       }
218
219       attributes.shrink();
220       eAttributes =
221         new EcoreEList.UnmodifiableEList.FastCompare
222           (this, EcorePackage.eINSTANCE.getEClass_EAttributes(), attributes.size(), attributes.data())
223         {
224           public void addUnique(Object JavaDoc object)
225           {
226             ((InternalEList)getEStructuralFeatures()).addUnique(object);
227           }
228
229           public boolean add(Object JavaDoc object)
230           {
231             System.err.println("Please fix your code to add using EClass.getEStructuralFeatures() instead of EClass.getEAttributes()");
232             return ((InternalEList)getEStructuralFeatures()).add(object);
233           }
234         };
235
236       result.addAll(eAttributes);
237       result.shrink();
238       eAllAttributes =
239         new EcoreEList.UnmodifiableEList.FastCompare
240           (this, EcorePackage.eINSTANCE.getEClass_EAllAttributes(), result.size(), result.data());
241       getESuperAdapter().setAllAttributesCollectionModified(false);
242     }
243
244     return eAllAttributes;
245   }
246
247   public EList getEAllReferences()
248   {
249     if (eAllReferences == null)
250     {
251       class ReferenceList extends UniqueEList
252       {
253         public ReferenceList()
254         {
255         }
256
257         protected Object JavaDoc [] newData(int capacity)
258         {
259           return new EReference [capacity];
260         }
261
262         protected boolean useEquals()
263         {
264           return false;
265         }
266       }
267       BasicEList result = new ReferenceList();
268       BasicEList references = new ReferenceList();
269
270       for (Iterator JavaDoc i = getESuperTypes().iterator(); i.hasNext(); )
271       {
272         EClass eSuperType = (EClass)i.next();
273         result.addAll(eSuperType.getEAllReferences());
274       }
275       for (Iterator JavaDoc i = getEStructuralFeatures().iterator(); i.hasNext(); )
276       {
277         EStructuralFeature eStructuralFeature = (EStructuralFeature)i.next();
278         if (eStructuralFeature instanceof EReference)
279         {
280           references.add(eStructuralFeature);
281         }
282       }
283
284       references.shrink();
285       eReferences =
286         new EcoreEList.UnmodifiableEList.FastCompare
287           (this, EcorePackage.eINSTANCE.getEClass_EReferences(), references.size(), references.data())
288         {
289           public void addUnique(Object JavaDoc object)
290           {
291             ((InternalEList)getEStructuralFeatures()).addUnique(object);
292           }
293
294           public boolean add(Object JavaDoc object)
295           {
296             System.err.println("Please fix your code to add using EClass.getEStructuralFeatures() instead of EClass.getEReferences()");
297             return ((InternalEList)getEStructuralFeatures()).add(object);
298           }
299         };
300
301       result.addAll(eReferences);
302       result.shrink();
303       eAllReferences =
304         new EcoreEList.UnmodifiableEList.FastCompare
305           (this, EcorePackage.eINSTANCE.getEClass_EAllReferences(), result.size(), result.data());
306       getESuperAdapter().setAllReferencesCollectionModified(false);
307     }
308
309     return eAllReferences;
310   }
311
312   /**
313    * <!-- begin-user-doc -->
314    * <!-- end-user-doc -->
315    * @generated NOT
316    */

317   public EList getEReferences()
318   {
319     getEAllReferences();
320     return eReferences;
321   }
322
323   /**
324    * <!-- begin-user-doc -->
325    * <!-- end-user-doc -->
326    * @generated NOT
327    */

328   public EList getEAttributes()
329   {
330     getEAllAttributes();
331     return eAttributes;
332   }
333
334   /**
335    * <!-- begin-user-doc -->
336    * <!-- end-user-doc -->
337    * @generated modifiable
338    */

339   public EList getEAllStructuralFeatures()
340   {
341     // The algorithm for the order of the features in this list should never change.
342
// Also, the fact that a new list is created whenever the contents change
343
// is something else that should never change.
344
// There are clients who rely on both these behaviors,
345
// and they will need to agree to any change,
346
// so that they can adjust their own code.
347
//
348
if (eAllStructuralFeatures == null)
349     {
350       class EStructuralFeatureUniqueEList extends UniqueEList
351       {
352         protected Object JavaDoc [] newData(int capacity)
353         {
354           return new EStructuralFeature [capacity];
355         }
356
357         protected boolean useEquals()
358         {
359           return false;
360         }
361       }
362
363       BasicEList result = new EStructuralFeatureUniqueEList();
364
365       for (Iterator JavaDoc i = getESuperTypes().iterator(); i.hasNext(); )
366       {
367         EClass eSuperType = (EClass)i.next();
368         result.addAll(eSuperType.getEAllStructuralFeatures());
369       }
370       int featureID = result.size();
371       for (Iterator JavaDoc i = getEStructuralFeatures().iterator(); i.hasNext(); ++featureID)
372       {
373         ((EStructuralFeatureImpl)i.next()).setFeatureID(featureID);
374       }
375       result.addAll(getEStructuralFeatures());
376
377       class EAllStructuralFeaturesList extends EcoreEList.UnmodifiableEList.FastCompare implements FeatureSubsetSupplier
378       {
379         protected EStructuralFeature [] containments;
380         protected EStructuralFeature [] crossReferences;
381
382         public EAllStructuralFeaturesList(BasicEList eAllStructuralFeatures)
383         {
384           super
385             (EClassImpl.this,
386              EcorePackage.eINSTANCE.getEClass_EAllStructuralFeatures(),
387              eAllStructuralFeatures.size(),
388              eAllStructuralFeatures.data()) ;
389
390           BasicEList containmentsList = new EStructuralFeatureUniqueEList();
391           BasicEList crossReferencesList = new EStructuralFeatureUniqueEList();
392           boolean isMixed = "mixed".equals(EcoreUtil.getAnnotation(EClassImpl.this, ExtendedMetaData.ANNOTATION_URI, "kind"));
393           for (int i = 0; i < size; ++i)
394           {
395             // Skip derived features.
396
//
397
EStructuralFeature eStructuralFeature = (EStructuralFeature)data[i];
398             if (eStructuralFeature instanceof EReference)
399             {
400               EReference eReference = (EReference)eStructuralFeature;
401               if (eReference.isContainment())
402               {
403                 if (!eReference.isDerived())
404                 {
405                   containmentsList.add(eReference);
406                 }
407               }
408               else if (!eReference.isContainer())
409               {
410                 // Include derived relations only if they won't also come from mixed or a group.
411
//
412
if (!eReference.isDerived() ||
413                       !isMixed && EcoreUtil.getAnnotation(eReference, ExtendedMetaData.ANNOTATION_URI, "group") == null)
414                 {
415                   crossReferencesList.add(eReference);
416                 }
417               }
418             }
419             else if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
420             {
421               if (!eStructuralFeature.isDerived())
422               {
423                 containmentsList.add(eStructuralFeature);
424                 crossReferencesList.add(eStructuralFeature);
425               }
426             }
427           }
428           containmentsList.shrink();
429           crossReferencesList.shrink();
430           containments = (EStructuralFeature [])containmentsList.data();
431           crossReferences = (EStructuralFeature [])crossReferencesList.data();
432         }
433
434         public EStructuralFeature [] containments()
435         {
436           return containments;
437         }
438
439         public EStructuralFeature [] crossReferences()
440         {
441           return crossReferences;
442         }
443
444         public EStructuralFeature [] features()
445         {
446           return (EStructuralFeature [])data;
447         }
448
449         public int indexOf(Object JavaDoc object)
450         {
451           if (object instanceof EStructuralFeature)
452           {
453             EStructuralFeature eStructuralFeature = (EStructuralFeature)object;
454             int index = eStructuralFeature.getFeatureID();
455             if (index != -1)
456             {
457               for (int last = this.size; index < last; ++index)
458               {
459                 if (data[index] == object)
460                 {
461                   return index;
462                 }
463               }
464             }
465           }
466           return -1;
467         }
468       }
469
470       result.shrink();
471       eAllStructuralFeatures = new EAllStructuralFeaturesList(result);
472       eAllStructuralFeaturesData = (EStructuralFeature[])result.data();
473       if (eAllStructuralFeaturesData == null)
474       {
475         eAllStructuralFeaturesData = NO_EALL_STRUCTURE_FEATURES_DATA;
476       }
477
478       eNameToFeatureMap = null;
479       
480       getESuperAdapter().setAllStructuralFeaturesCollectionModified(false);
481     }
482
483     return eAllStructuralFeatures;
484   }
485   
486   private static final EStructuralFeature[] NO_EALL_STRUCTURE_FEATURES_DATA = {};
487
488   /**
489    * <!-- begin-user-doc -->
490    * <!-- end-user-doc -->
491    * @generated modifiable
492    */

493   public EList getEAllOperations()
494   {
495     if (eAllOperations == null)
496     {
497       BasicEList result =
498         new UniqueEList()
499         {
500           protected Object JavaDoc [] newData(int capacity)
501           {
502             return new EOperation [capacity];
503           }
504
505           protected boolean useEquals()
506           {
507             return false;
508           }
509         };
510
511       for (Iterator JavaDoc i = getESuperTypes().iterator(); i.hasNext(); )
512       {
513         result.addAll(((EClass)i.next()).getEAllOperations());
514       }
515       result.addAll(getEOperations());
516       result.shrink();
517       eAllOperations =
518         new EcoreEList.UnmodifiableEList.FastCompare
519           (this, EcorePackage.eINSTANCE.getEClass_EAllOperations(), result.size(), result.data());
520       getESuperAdapter().setAllOperationsCollectionModified(false);
521     }
522
523     return eAllOperations;
524   }
525
526   /**
527    * <!-- begin-user-doc -->
528    * <!-- end-user-doc -->
529    * @generated
530    */

531   public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
532   {
533     if (featureID >= 0)
534     {
535       switch (eDerivedStructuralFeatureID(featureID, baseClass))
536       {
537         case EcorePackage.ECLASS__EANNOTATIONS:
538           return ((InternalEList)getEAnnotations()).basicRemove(otherEnd, msgs);
539         case EcorePackage.ECLASS__EPACKAGE:
540           return eBasicSetContainer(null, EcorePackage.ECLASS__EPACKAGE, msgs);
541         case EcorePackage.ECLASS__EOPERATIONS:
542           return ((InternalEList)getEOperations()).basicRemove(otherEnd, msgs);
543         case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES:
544           return ((InternalEList)getEStructuralFeatures()).basicRemove(otherEnd, msgs);
545         default:
546           return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
547       }
548     }
549     return eBasicSetContainer(null, featureID, msgs);
550   }
551
552   /**
553    * <!-- begin-user-doc -->
554    * <!-- end-user-doc -->
555    * @generated
556    */

557   public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs)
558   {
559     if (eContainerFeatureID >= 0)
560     {
561       switch (eContainerFeatureID)
562       {
563         case EcorePackage.ECLASS__EPACKAGE:
564           return eContainer.eInverseRemove(this, EcorePackage.EPACKAGE__ECLASSIFIERS, EPackage.class, msgs);
565         default:
566           return eDynamicBasicRemoveFromContainer(msgs);
567       }
568     }
569     return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
570   }
571
572   public EList getEAllContainments()
573   {
574     if (eAllContainments == null)
575     {
576       BasicEList result =
577         new UniqueEList()
578         {
579           protected Object JavaDoc [] newData(int capacity)
580           {
581             return new EReference [capacity];
582           }
583
584           protected boolean useEquals()
585           {
586             return false;
587           }
588         };
589
590       for (Iterator JavaDoc i = getEAllReferences().iterator(); i.hasNext(); )
591       {
592         EReference eReference = (EReference)i.next();
593         if (eReference.isContainment())
594         {
595           result.add(eReference);
596         }
597       }
598
599       result.shrink();
600       eAllContainments =
601         new EcoreEList.UnmodifiableEList.FastCompare
602           (this, EcorePackage.eINSTANCE.getEClass_EAllContainments(), result.size(), result.data());
603       getESuperAdapter().setAllContainmentsCollectionModified(false);
604     }
605
606     return eAllContainments;
607   }
608
609   public EStructuralFeature getEStructuralFeature(String JavaDoc name)
610   {
611     getFeatureCount();
612     if (eNameToFeatureMap == null)
613     {
614       Map JavaDoc result = new HashMap JavaDoc(3 * eAllStructuralFeatures.size() / 2 + 1);
615       for (Iterator JavaDoc i = eAllStructuralFeatures.iterator(); i.hasNext(); )
616       {
617         EStructuralFeature eStructuralFeature = (EStructuralFeature)i.next();
618         result.put(eStructuralFeature.getName(), eStructuralFeature);
619       }
620       eNameToFeatureMap = result;
621     }
622     return (EStructuralFeatureImpl)eNameToFeatureMap.get(name);
623   }
624
625   protected EStructuralFeature[] getEAllStructuralFeaturesData()
626   {
627     if (eAllStructuralFeaturesData == null)
628     {
629       getEAllStructuralFeatures();
630     }
631     return eAllStructuralFeaturesData;
632   }
633   
634   /**
635    * <!-- begin-user-doc -->
636    * <!-- end-user-doc -->
637    * @generated NOT
638    */

639   public int getFeatureCount()
640   {
641     return getEAllStructuralFeaturesData().length;
642   }
643   
644   public EStructuralFeature getEStructuralFeature(int featureID)
645   {
646     EStructuralFeature [] eAllStructuralFeaturesData = getEAllStructuralFeaturesData();
647     return
648       featureID >= 0 && featureID < eAllStructuralFeaturesData.length ?
649         eAllStructuralFeaturesData[featureID] :
650         null;
651   }
652
653   /**
654    * <!-- begin-user-doc -->
655    * <!-- end-user-doc -->
656    * @generated NOT
657    */

658   public int getFeatureID(EStructuralFeature feature)
659   {
660     EStructuralFeature [] eAllStructuralFeaturesData = getEAllStructuralFeaturesData();
661     int index = feature.getFeatureID();
662     if (index != -1)
663     {
664       for (int last = eAllStructuralFeaturesData.length; index < last; ++index)
665       {
666         if (eAllStructuralFeaturesData[index] == feature)
667         {
668           return index;
669         }
670       }
671     }
672     return -1;
673   }
674
675   /**
676    * <!-- begin-user-doc -->
677    * <!-- end-user-doc -->
678    * @generated
679    */

680   public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
681   {
682     if (featureID >= 0)
683     {
684       switch (eDerivedStructuralFeatureID(featureID, baseClass))
685       {
686         case EcorePackage.ECLASS__EANNOTATIONS:
687           return ((InternalEList)getEAnnotations()).basicAdd(otherEnd, msgs);
688         case EcorePackage.ECLASS__EPACKAGE:
689           if (eContainer != null)
690             msgs = eBasicRemoveFromContainer(msgs);
691           return eBasicSetContainer(otherEnd, EcorePackage.ECLASS__EPACKAGE, msgs);
692         case EcorePackage.ECLASS__EOPERATIONS:
693           return ((InternalEList)getEOperations()).basicAdd(otherEnd, msgs);
694         case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES:
695           return ((InternalEList)getEStructuralFeatures()).basicAdd(otherEnd, msgs);
696         default:
697           return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
698       }
699     }
700     if (eContainer != null)
701       msgs = eBasicRemoveFromContainer(msgs);
702     return eBasicSetContainer(otherEnd, featureID, msgs);
703   }
704
705   /**
706    * The default value of the '{@link #isAbstract() <em>Abstract</em>}' attribute.
707    * <!-- begin-user-doc -->
708    * <!-- end-user-doc -->
709    * @see #isAbstract()
710    * @generated
711    * @ordered
712    */

713   protected static final boolean ABSTRACT_EDEFAULT = false;
714
715   /**
716    * The flag representing the value of the '{@link #isAbstract() <em>Abstract</em>}' attribute.
717    * <!-- begin-user-doc -->
718    * <!-- end-user-doc -->
719    * @see #isAbstract()
720    * @generated
721    * @ordered
722    */

723   protected static final int ABSTRACT_EFLAG = 1 << 8;
724
725   /**
726    * The default value of the '{@link #isInterface() <em>Interface</em>}' attribute.
727    * <!-- begin-user-doc -->
728    * <!-- end-user-doc -->
729    * @see #isInterface()
730    * @generated
731    * @ordered
732    */

733   protected static final boolean INTERFACE_EDEFAULT = false;
734
735   /**
736    * The flag representing the value of the '{@link #isInterface() <em>Interface</em>}' attribute.
737    * <!-- begin-user-doc -->
738    * <!-- end-user-doc -->
739    * @see #isInterface()
740    * @generated
741    * @ordered
742    */

743   protected static final int INTERFACE_EFLAG = 1 << 9;
744
745   /**
746    * The cached value of the '{@link #getESuperTypes() <em>ESuper Types</em>}' reference list.
747    * <!-- begin-user-doc -->
748    * <!-- end-user-doc -->
749    * @see #getESuperTypes()
750    * @generated
751    * @ordered
752    */

753   protected EList eSuperTypes = null;
754
755   /**
756    * The cached value of the '{@link #getEOperations() <em>EOperations</em>}' containment reference list.
757    * <!-- begin-user-doc -->
758    * <!-- end-user-doc -->
759    * @see #getEOperations()
760    * @generated
761    * @ordered
762    */

763   protected EList eOperations = null;
764
765   /**
766    * The cached value of the '{@link #getEReferences() <em>EReferences</em>}' containment reference list.
767    * <!-- begin-user-doc -->
768    * <!-- end-user-doc -->
769    * @see #getEReferences()
770    * @generated NOT
771    * @ordered
772    */

773   protected BasicEList eReferences = null;
774
775   /**
776    * The cached value of the '{@link #getEAttributes() <em>EAttributes</em>}' containment reference list.
777    * <!-- begin-user-doc -->
778    * <!-- end-user-doc -->
779    * @see #getEAttributes()
780    * @generated NOT
781    * @ordered
782    */

783   protected BasicEList eAttributes = null;
784
785   /**
786    * The cached value of the '{@link #getEStructuralFeatures() <em>EStructural Features</em>}' containment reference list.
787    * <!-- begin-user-doc -->
788    * <!-- end-user-doc -->
789    * @see #getEStructuralFeatures()
790    * @generated
791    * @ordered
792    */

793   protected EList eStructuralFeatures = null;
794
795   /**
796    * <!-- begin-user-doc -->
797    * <!-- end-user-doc -->
798    * @generated
799    */

800   public boolean isAbstract()
801   {
802     return (eFlags & ABSTRACT_EFLAG) != 0;
803   }
804
805   /**
806    * <!-- begin-user-doc -->
807    * <!-- end-user-doc -->
808    * @generated
809    */

810   public void setAbstract(boolean newAbstract)
811   {
812     boolean oldAbstract = (eFlags & ABSTRACT_EFLAG) != 0;
813     if (newAbstract) eFlags |= ABSTRACT_EFLAG; else eFlags &= ~ABSTRACT_EFLAG;
814     if (eNotificationRequired())
815       eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ECLASS__ABSTRACT, oldAbstract, newAbstract));
816   }
817
818   /**
819    * <!-- begin-user-doc -->
820    * <!-- end-user-doc -->
821    * @generated
822    */

823   public boolean isInterface()
824   {
825     return (eFlags & INTERFACE_EFLAG) != 0;
826   }
827
828   /**
829    * <!-- begin-user-doc -->
830    * <!-- end-user-doc -->
831    * @generated
832    */

833   public void setInterface(boolean newInterface)
834   {
835     boolean oldInterface = (eFlags & INTERFACE_EFLAG) != 0;
836     if (newInterface) eFlags |= INTERFACE_EFLAG; else eFlags &= ~INTERFACE_EFLAG;
837     if (eNotificationRequired())
838       eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ECLASS__INTERFACE, oldInterface, newInterface));
839   }
840
841   /**
842    * <!-- begin-user-doc -->
843    * <!-- end-user-doc -->
844    * @generated
845    */

846   public Object JavaDoc eGet(EStructuralFeature eFeature, boolean resolve)
847   {
848     switch (eDerivedStructuralFeatureID(eFeature))
849     {
850       case EcorePackage.ECLASS__EANNOTATIONS:
851         return getEAnnotations();
852       case EcorePackage.ECLASS__NAME:
853         return getName();
854       case EcorePackage.ECLASS__INSTANCE_CLASS_NAME:
855         return getInstanceClassName();
856       case EcorePackage.ECLASS__INSTANCE_CLASS:
857         return getInstanceClass();
858       case EcorePackage.ECLASS__DEFAULT_VALUE:
859         return getDefaultValue();
860       case EcorePackage.ECLASS__EPACKAGE:
861         return getEPackage();
862       case EcorePackage.ECLASS__ABSTRACT:
863         return isAbstract() ? Boolean.TRUE : Boolean.FALSE;
864       case EcorePackage.ECLASS__INTERFACE:
865         return isInterface() ? Boolean.TRUE : Boolean.FALSE;
866       case EcorePackage.ECLASS__ESUPER_TYPES:
867         return getESuperTypes();
868       case EcorePackage.ECLASS__EOPERATIONS:
869         return getEOperations();
870       case EcorePackage.ECLASS__EALL_ATTRIBUTES:
871         return getEAllAttributes();
872       case EcorePackage.ECLASS__EALL_REFERENCES:
873         return getEAllReferences();
874       case EcorePackage.ECLASS__EREFERENCES:
875         return getEReferences();
876       case EcorePackage.ECLASS__EATTRIBUTES:
877         return getEAttributes();
878       case EcorePackage.ECLASS__EALL_CONTAINMENTS:
879         return getEAllContainments();
880       case EcorePackage.ECLASS__EALL_OPERATIONS:
881         return getEAllOperations();
882       case EcorePackage.ECLASS__EALL_STRUCTURAL_FEATURES:
883         return getEAllStructuralFeatures();
884       case EcorePackage.ECLASS__EALL_SUPER_TYPES:
885         return getEAllSuperTypes();
886       case EcorePackage.ECLASS__EID_ATTRIBUTE:
887         return getEIDAttribute();
888       case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES:
889         return getEStructuralFeatures();
890     }
891     return eDynamicGet(eFeature, resolve);
892   }
893
894   /**
895    * <!-- begin-user-doc -->
896    * <!-- end-user-doc -->
897    * @generated
898    */

899   public boolean eIsSet(EStructuralFeature eFeature)
900   {
901     switch (eDerivedStructuralFeatureID(eFeature))
902     {
903       case EcorePackage.ECLASS__EANNOTATIONS:
904         return eAnnotations != null && !eAnnotations.isEmpty();
905       case EcorePackage.ECLASS__NAME:
906         return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
907       case EcorePackage.ECLASS__INSTANCE_CLASS_NAME:
908         return INSTANCE_CLASS_NAME_EDEFAULT == null ? instanceClassName != null : !INSTANCE_CLASS_NAME_EDEFAULT.equals(instanceClassName);
909       case EcorePackage.ECLASS__INSTANCE_CLASS:
910         return INSTANCE_CLASS_EDEFAULT == null ? getInstanceClass() != null : !INSTANCE_CLASS_EDEFAULT.equals(getInstanceClass());
911       case EcorePackage.ECLASS__DEFAULT_VALUE:
912         return DEFAULT_VALUE_EDEFAULT == null ? getDefaultValue() != null : !DEFAULT_VALUE_EDEFAULT.equals(getDefaultValue());
913       case EcorePackage.ECLASS__EPACKAGE:
914         return getEPackage() != null;
915       case EcorePackage.ECLASS__ABSTRACT:
916         return ((eFlags & ABSTRACT_EFLAG) != 0) != ABSTRACT_EDEFAULT;
917       case EcorePackage.ECLASS__INTERFACE:
918         return ((eFlags & INTERFACE_EFLAG) != 0) != INTERFACE_EDEFAULT;
919       case EcorePackage.ECLASS__ESUPER_TYPES:
920         return eSuperTypes != null && !eSuperTypes.isEmpty();
921       case EcorePackage.ECLASS__EOPERATIONS:
922         return eOperations != null && !eOperations.isEmpty();
923       case EcorePackage.ECLASS__EALL_ATTRIBUTES:
924         return !getEAllAttributes().isEmpty();
925       case EcorePackage.ECLASS__EALL_REFERENCES:
926         return !getEAllReferences().isEmpty();
927       case EcorePackage.ECLASS__EREFERENCES:
928         return !getEReferences().isEmpty();
929       case EcorePackage.ECLASS__EATTRIBUTES:
930         return !getEAttributes().isEmpty();
931       case EcorePackage.ECLASS__EALL_CONTAINMENTS:
932         return !getEAllContainments().isEmpty();
933       case EcorePackage.ECLASS__EALL_OPERATIONS:
934         return !getEAllOperations().isEmpty();
935       case EcorePackage.ECLASS__EALL_STRUCTURAL_FEATURES:
936         return !getEAllStructuralFeatures().isEmpty();
937       case EcorePackage.ECLASS__EALL_SUPER_TYPES:
938         return !getEAllSuperTypes().isEmpty();
939       case EcorePackage.ECLASS__EID_ATTRIBUTE:
940         return getEIDAttribute() != null;
941       case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES:
942         return eStructuralFeatures != null && !eStructuralFeatures.isEmpty();
943     }
944     return eDynamicIsSet(eFeature);
945   }
946
947   /**
948    * <!-- begin-user-doc -->
949    * <!-- end-user-doc -->
950    * @generated
951    */

952   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
953   {
954     switch (eDerivedStructuralFeatureID(eFeature))
955     {
956       case EcorePackage.ECLASS__EANNOTATIONS:
957         getEAnnotations().clear();
958         getEAnnotations().addAll((Collection JavaDoc)newValue);
959         return;
960       case EcorePackage.ECLASS__NAME:
961         setName((String JavaDoc)newValue);
962         return;
963       case EcorePackage.ECLASS__INSTANCE_CLASS_NAME:
964         setInstanceClassName((String JavaDoc)newValue);
965         return;
966       case EcorePackage.ECLASS__ABSTRACT:
967         setAbstract(((Boolean JavaDoc)newValue).booleanValue());
968         return;
969       case EcorePackage.ECLASS__INTERFACE:
970         setInterface(((Boolean JavaDoc)newValue).booleanValue());
971         return;
972       case EcorePackage.ECLASS__ESUPER_TYPES:
973         getESuperTypes().clear();
974         getESuperTypes().addAll((Collection JavaDoc)newValue);
975         return;
976       case EcorePackage.ECLASS__EOPERATIONS:
977         getEOperations().clear();
978         getEOperations().addAll((Collection JavaDoc)newValue);
979         return;
980       case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES:
981         getEStructuralFeatures().clear();
982         getEStructuralFeatures().addAll((Collection JavaDoc)newValue);
983         return;
984     }
985     eDynamicSet(eFeature, newValue);
986   }
987
988   /**
989    * <!-- begin-user-doc -->
990    * <!-- end-user-doc -->
991    * @generated
992    */

993   public void eUnset(EStructuralFeature eFeature)
994   {
995     switch (eDerivedStructuralFeatureID(eFeature))
996     {
997       case EcorePackage.ECLASS__EANNOTATIONS:
998         getEAnnotations().clear();
999         return;
1000      case EcorePackage.ECLASS__NAME:
1001        setName(NAME_EDEFAULT);
1002        return;
1003      case EcorePackage.ECLASS__INSTANCE_CLASS_NAME:
1004        setInstanceClassName(INSTANCE_CLASS_NAME_EDEFAULT);
1005        return;
1006      case EcorePackage.ECLASS__ABSTRACT:
1007        setAbstract(ABSTRACT_EDEFAULT);
1008        return;
1009      case EcorePackage.ECLASS__INTERFACE:
1010        setInterface(INTERFACE_EDEFAULT);
1011        return;
1012      case EcorePackage.ECLASS__ESUPER_TYPES:
1013        getESuperTypes().clear();
1014        return;
1015      case EcorePackage.ECLASS__EOPERATIONS:
1016        getEOperations().clear();
1017        return;
1018      case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES:
1019        getEStructuralFeatures().clear();
1020        return;
1021    }
1022    eDynamicUnset(eFeature);
1023  }
1024
1025  /**
1026   * <!-- begin-user-doc -->
1027   * <!-- end-user-doc -->
1028   * @generated
1029   */

1030  public String JavaDoc toString()
1031  {
1032    if (eIsProxy()) return super.toString();
1033
1034    StringBuffer JavaDoc result = new StringBuffer JavaDoc(super.toString());
1035    result.append(" (abstract: ");
1036    result.append((eFlags & ABSTRACT_EFLAG) != 0);
1037    result.append(", interface: ");
1038    result.append((eFlags & INTERFACE_EFLAG) != 0);
1039    result.append(')');
1040    return result.toString();
1041  }
1042
1043  /**
1044   * <!-- begin-user-doc -->
1045   * <!-- end-user-doc -->
1046   * @generated
1047   */

1048  public EList getESuperTypesGen()
1049  {
1050    if (eSuperTypes == null)
1051    {
1052      eSuperTypes = new EObjectResolvingEList(EClass.class, this, EcorePackage.ECLASS__ESUPER_TYPES);
1053    }
1054    return eSuperTypes;
1055  }
1056
1057  public EList getESuperTypes()
1058  {
1059    getESuperAdapter();
1060    return getESuperTypesGen();
1061  }
1062  
1063  /**
1064   * <!-- begin-user-doc -->
1065   * <!-- end-user-doc -->
1066   * @generated
1067   */

1068  public EList getEOperations()
1069  {
1070    if (eOperations == null)
1071    {
1072      eOperations = new EObjectContainmentWithInverseEList(EOperation.class, this, EcorePackage.ECLASS__EOPERATIONS, EcorePackage.EOPERATION__ECONTAINING_CLASS);
1073    }
1074    return eOperations;
1075  }
1076
1077  /**
1078   * Determines if the class or interface represented by this Class object is either
1079   * the same as, or is a superclass or superinterface of, the class or interface
1080   * represented by the specified someClass parameter. Semantics are the same as
1081   * java.lang.Class#isAssignableFrom
1082   */

1083  public boolean isSuperTypeOf(EClass someClass)
1084  {
1085    return someClass == this || someClass.getEAllSuperTypes().contains(this);
1086  }
1087
1088  /**
1089   * Returns all the supertypes in the hierarchy.
1090   */

1091  public EList getEAllSuperTypes()
1092  {
1093    if (eAllSuperTypes == null)
1094    {
1095      BasicEList result =
1096        new UniqueEList()
1097        {
1098          protected Object JavaDoc [] newData(int capacity)
1099          {
1100            return new EClassifier [capacity];
1101          }
1102
1103          protected boolean useEquals()
1104          {
1105            return false;
1106          }
1107        };
1108
1109      EList immediateSupers = getESuperTypes();
1110      Iterator JavaDoc i = immediateSupers.iterator();
1111      while (i.hasNext())
1112      {
1113        EClass supertype = (EClass)i.next();
1114        EList higherSupers = supertype.getEAllSuperTypes();
1115        result.addAll(higherSupers);
1116        result.add(supertype);
1117      }
1118
1119      result.shrink();
1120      eAllSuperTypes =
1121        new EcoreEList.UnmodifiableEList.FastCompare
1122          (this, EcorePackage.eINSTANCE.getEClass_EAllSuperTypes(), result.size(), result.data());
1123      getESuperAdapter().setAllSuperCollectionModified(false);
1124    }
1125
1126    return eAllSuperTypes;
1127  }
1128
1129  protected boolean dynamicIsInstance(EObject eObject)
1130  {
1131    return isSuperTypeOf(eObject.eClass());
1132  }
1133
1134  public ESuperAdapter getESuperAdapter()
1135  {
1136    if (eSuperAdapter == null)
1137    {
1138      eSuperAdapter =
1139        new ESuperAdapter()
1140        {
1141          void setFlags(int featureId)
1142          {
1143            super.setFlags(featureId);
1144            
1145            if (isAllAttributesCollectionModified())
1146            {
1147              eAllAttributes = null;
1148            }
1149            if (isAllReferencesCollectionModified())
1150            {
1151              eAllReferences = null;
1152            }
1153            if (isAllStructuralFeaturesCollectionModified())
1154            {
1155              eAllStructuralFeatures = null;
1156              eAllStructuralFeaturesData = null;
1157            }
1158            if (isAllOperationsCollectionModified())
1159            {
1160              eAllOperations = null;
1161            }
1162            if (isAllContainmentsCollectionModified())
1163            {
1164              eAllContainments = null;
1165            }
1166            if (isAllSuperCollectionModified())
1167            {
1168              eAllSuperTypes = null;
1169            }
1170          }
1171        };
1172      eAdapters().add(0, eSuperAdapter);
1173    }
1174    return eSuperAdapter;
1175  }
1176
1177  public void eSetDeliver(boolean deliver)
1178  {
1179    super.eSetDeliver(deliver);
1180
1181    if (deliver)
1182    {
1183      for (Iterator JavaDoc eSuperTypes = getESuperTypes().iterator(); eSuperTypes.hasNext(); )
1184      {
1185        EClass eSuperType = (EClass)eSuperTypes.next();
1186        ESuperAdapter eSuperAdapter = ((ESuperAdapter.Holder)eSuperType).getESuperAdapter();
1187        eSuperAdapter.getSubclasses().add(this);
1188      }
1189    }
1190  }
1191}
1192
Popular Tags