KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > codegen > ecore > genmodel > impl > GenFeatureImpl


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: GenFeatureImpl.java,v 1.23 2005/06/08 06:18:44 nickb Exp $
16  */

17 package org.eclipse.emf.codegen.ecore.genmodel.impl;
18
19
20 import java.util.Collection JavaDoc;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.HashSet JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.Set JavaDoc;
28
29 import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
30 import org.eclipse.emf.codegen.ecore.genmodel.GenDataType;
31 import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
32 import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage;
33 import org.eclipse.emf.codegen.ecore.genmodel.GenOperation;
34 import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
35 import org.eclipse.emf.codegen.ecore.genmodel.GenPropertyKind;
36 import org.eclipse.emf.common.notify.Notification;
37 import org.eclipse.emf.common.notify.NotificationChain;
38 import org.eclipse.emf.common.util.EList;
39
40 import org.eclipse.emf.ecore.EAttribute;
41 import org.eclipse.emf.ecore.EClass;
42 import org.eclipse.emf.ecore.EClassifier;
43 import org.eclipse.emf.ecore.EDataType;
44 import org.eclipse.emf.ecore.EEnum;
45 import org.eclipse.emf.ecore.EModelElement;
46 import org.eclipse.emf.ecore.EReference;
47 import org.eclipse.emf.ecore.EStructuralFeature;
48 import org.eclipse.emf.ecore.ETypedElement;
49 import org.eclipse.emf.ecore.InternalEObject;
50 import org.eclipse.emf.ecore.impl.ENotificationImpl;
51 import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
52 import org.eclipse.emf.ecore.util.EcoreUtil;
53 import org.eclipse.emf.ecore.util.ExtendedMetaData;
54 import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
55
56
57 /**
58  * <!-- begin-user-doc -->
59  * An implementation of the model object '<em><b>Gen Feature</b></em>'.
60  * <!-- end-user-doc -->
61  * <p>
62  * The following features are implemented:
63  * <ul>
64  * <li>{@link org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl#getProperty <em>Property</em>}</li>
65  * <li>{@link org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl#isNotify <em>Notify</em>}</li>
66  * <li>{@link org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl#isChildren <em>Children</em>}</li>
67  * <li>{@link org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl#isCreateChild <em>Create Child</em>}</li>
68  * <li>{@link org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl#getPropertyCategory <em>Property Category</em>}</li>
69  * <li>{@link org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl#getPropertyFilterFlags <em>Property Filter Flags</em>}</li>
70  * <li>{@link org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl#getPropertyDescription <em>Property Description</em>}</li>
71  * <li>{@link org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl#getGenClass <em>Gen Class</em>}</li>
72  * <li>{@link org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl#getEcoreFeature <em>Ecore Feature</em>}</li>
73  * </ul>
74  * </p>
75  *
76  * @generated
77  */

78 public class GenFeatureImpl extends GenTypedElementImpl implements GenFeature
79 {
80   /**
81    * The default value of the '{@link #getProperty() <em>Property</em>}' attribute.
82    * <!-- begin-user-doc -->
83    * <!-- end-user-doc -->
84    * @see #getProperty()
85    * @generated
86    * @ordered
87    */

88   protected static final GenPropertyKind PROPERTY_EDEFAULT = GenPropertyKind.EDITABLE_LITERAL;
89
90   /**
91    * The cached value of the '{@link #getProperty() <em>Property</em>}' attribute.
92    * <!-- begin-user-doc -->
93    * <!-- end-user-doc -->
94    * @see #getProperty()
95    * @generated
96    * @ordered
97    */

98   protected GenPropertyKind property = PROPERTY_EDEFAULT;
99
100   /**
101    * The default value of the '{@link #isNotify() <em>Notify</em>}' attribute.
102    * <!-- begin-user-doc -->
103    * <!-- end-user-doc -->
104    * @see #isNotify()
105    * @generated
106    * @ordered
107    */

108   protected static final boolean NOTIFY_EDEFAULT = true;
109
110   /**
111    * The cached value of the '{@link #isNotify() <em>Notify</em>}' attribute.
112    * <!-- begin-user-doc -->
113    * <!-- end-user-doc -->
114    * @see #isNotify()
115    * @generated
116    * @ordered
117    */

118   protected boolean notify = NOTIFY_EDEFAULT;
119
120   /**
121    * The default value of the '{@link #isChildren() <em>Children</em>}' attribute.
122    * <!-- begin-user-doc -->
123    * <!-- end-user-doc -->
124    * @see #isChildren()
125    * @generated
126    * @ordered
127    */

128   protected static final boolean CHILDREN_EDEFAULT = false;
129
130   /**
131    * The cached value of the '{@link #isChildren() <em>Children</em>}' attribute.
132    * <!-- begin-user-doc -->
133    * <!-- end-user-doc -->
134    * @see #isChildren()
135    * @generated
136    * @ordered
137    */

138   protected boolean children = CHILDREN_EDEFAULT;
139
140   /**
141    * The default value of the '{@link #isCreateChild() <em>Create Child</em>}' attribute.
142    * <!-- begin-user-doc -->
143    * <!-- end-user-doc -->
144    * @see #isCreateChild()
145    * @generated
146    * @ordered
147    */

148   protected static final boolean CREATE_CHILD_EDEFAULT = false;
149
150   /**
151    * The cached value of the '{@link #isCreateChild() <em>Create Child</em>}' attribute.
152    * <!-- begin-user-doc -->
153    * <!-- end-user-doc -->
154    * @see #isCreateChild()
155    * @generated
156    * @ordered
157    */

158   protected boolean createChild = CREATE_CHILD_EDEFAULT;
159
160   /**
161    * This is true if the Create Child attribute has been set.
162    * <!-- begin-user-doc -->
163    * <!-- end-user-doc -->
164    * @generated
165    * @ordered
166    */

167   protected boolean createChildESet = false;
168
169   /**
170    * The default value of the '{@link #getPropertyCategory() <em>Property Category</em>}' attribute.
171    * <!-- begin-user-doc -->
172    * <!-- end-user-doc -->
173    * @see #getPropertyCategory()
174    * @generated
175    * @ordered
176    */

177   protected static final String JavaDoc PROPERTY_CATEGORY_EDEFAULT = null;
178
179   /**
180    * The cached value of the '{@link #getPropertyCategory() <em>Property Category</em>}' attribute.
181    * <!-- begin-user-doc -->
182    * <!-- end-user-doc -->
183    * @see #getPropertyCategory()
184    * @generated
185    * @ordered
186    */

187   protected String JavaDoc propertyCategory = PROPERTY_CATEGORY_EDEFAULT;
188
189   /**
190    * The cached value of the '{@link #getPropertyFilterFlags() <em>Property Filter Flags</em>}' attribute list.
191    * <!-- begin-user-doc -->
192    * <!-- end-user-doc -->
193    * @see #getPropertyFilterFlags()
194    * @generated
195    * @ordered
196    */

197   protected EList propertyFilterFlags = null;
198
199   /**
200    * The default value of the '{@link #getPropertyDescription() <em>Property Description</em>}' attribute.
201    * <!-- begin-user-doc -->
202    * <!-- end-user-doc -->
203    * @see #getPropertyDescription()
204    * @generated
205    * @ordered
206    */

207   protected static final String JavaDoc PROPERTY_DESCRIPTION_EDEFAULT = null;
208
209   /**
210    * The cached value of the '{@link #getPropertyDescription() <em>Property Description</em>}' attribute.
211    * <!-- begin-user-doc -->
212    * <!-- end-user-doc -->
213    * @see #getPropertyDescription()
214    * @generated
215    * @ordered
216    */

217   protected String JavaDoc propertyDescription = PROPERTY_DESCRIPTION_EDEFAULT;
218
219   /**
220    * The cached value of the '{@link #getEcoreFeature() <em>Ecore Feature</em>}' reference.
221    * <!-- begin-user-doc -->
222    * <!-- end-user-doc -->
223    * @see #getEcoreFeature()
224    * @generated
225    * @ordered
226    */

227   protected EStructuralFeature ecoreFeature = null;
228
229   /**
230    * <!-- begin-user-doc -->
231    * <!-- end-user-doc -->
232    * @generated modifiable
233    */

234   protected GenFeatureImpl()
235   {
236     super();
237   }
238
239   /**
240    * <!-- begin-user-doc -->
241    * <!-- end-user-doc -->
242    * @generated
243    */

244   protected EClass eStaticClass()
245   {
246     return GenModelPackage.eINSTANCE.getGenFeature();
247   }
248
249   /**
250    * <!-- begin-user-doc -->
251    * <!-- end-user-doc -->
252    * @generated
253    */

254   public GenPropertyKind getProperty()
255   {
256     return property;
257   }
258
259   public boolean isProperty()
260   {
261     return property != GenPropertyKind.NONE_LITERAL;
262   }
263
264   /**
265    * <!-- begin-user-doc -->
266    * <!-- end-user-doc -->
267    * @generated
268    */

269   public void setProperty(GenPropertyKind newProperty)
270   {
271     GenPropertyKind oldProperty = property;
272     property = newProperty == null ? PROPERTY_EDEFAULT : newProperty;
273     if (eNotificationRequired())
274       eNotify(new ENotificationImpl(this, Notification.SET, GenModelPackage.GEN_FEATURE__PROPERTY, oldProperty, property));
275   }
276
277   /**
278    * <!-- begin-user-doc -->
279    * <!-- end-user-doc -->
280    * @generated
281    */

282   public boolean isNotify()
283   {
284     return notify;
285   }
286
287   /**
288    * <!-- begin-user-doc -->
289    * <!-- end-user-doc -->
290    * @generated
291    */

292   public void setNotify(boolean newNotify)
293   {
294     boolean oldNotify = notify;
295     notify = newNotify;
296     if (eNotificationRequired())
297       eNotify(new ENotificationImpl(this, Notification.SET, GenModelPackage.GEN_FEATURE__NOTIFY, oldNotify, notify));
298   }
299
300   /**
301    * <!-- begin-user-doc -->
302    * <!-- end-user-doc -->
303    * @generated
304    */

305   public boolean isChildren()
306   {
307     return children;
308   }
309
310   /**
311    * <!-- begin-user-doc -->
312    * <!-- end-user-doc -->
313    * @generated
314    */

315   public void setChildren(boolean newChildren)
316   {
317     boolean oldChildren = children;
318     children = newChildren;
319     if (eNotificationRequired())
320       eNotify(new ENotificationImpl(this, Notification.SET, GenModelPackage.GEN_FEATURE__CHILDREN, oldChildren, children));
321   }
322
323   /*
324    * Set from {@link #isChildren children} if unset, and return value.
325    */

326   public boolean isCreateChild()
327   {
328     autoSetCreateChild();
329     return isCreateChildGen();
330   }
331
332   /**
333    * <!-- begin-user-doc -->
334    * <!-- end-user-doc -->
335    * @generated
336    */

337   public boolean isCreateChildGen()
338   {
339     return createChild;
340   }
341
342   /**
343    * <!-- begin-user-doc -->
344    * <!-- end-user-doc -->
345    * @generated
346    */

347   public void setCreateChild(boolean newCreateChild)
348   {
349     boolean oldCreateChild = createChild;
350     createChild = newCreateChild;
351     boolean oldCreateChildESet = createChildESet;
352     createChildESet = true;
353     if (eNotificationRequired())
354       eNotify(new ENotificationImpl(this, Notification.SET, GenModelPackage.GEN_FEATURE__CREATE_CHILD, oldCreateChild, createChild, !oldCreateChildESet));
355   }
356
357   /**
358    * <!-- begin-user-doc -->
359    * <!-- end-user-doc -->
360    * @generated
361    */

362   public void unsetCreateChild()
363   {
364     boolean oldCreateChild = createChild;
365     boolean oldCreateChildESet = createChildESet;
366     createChild = CREATE_CHILD_EDEFAULT;
367     createChildESet = false;
368     if (eNotificationRequired())
369       eNotify(new ENotificationImpl(this, Notification.UNSET, GenModelPackage.GEN_FEATURE__CREATE_CHILD, oldCreateChild, CREATE_CHILD_EDEFAULT, oldCreateChildESet));
370   }
371
372   /**
373    * Set from {@link #isChildren children} if necessary, and return true.
374    */

375   public boolean isSetCreateChild()
376   {
377     autoSetCreateChild();
378     return isSetCreateChildGen();
379   }
380
381   /**
382    * <!-- begin-user-doc -->
383    * <!-- end-user-doc -->
384    * @generated
385    */

386   public boolean isSetCreateChildGen()
387   {
388     return createChildESet;
389   }
390
391   /**
392    * <!-- begin-user-doc -->
393    * <!-- end-user-doc -->
394    * @generated
395    */

396   public String JavaDoc getPropertyCategory()
397   {
398     return propertyCategory;
399   }
400
401   /**
402    * <!-- begin-user-doc -->
403    * <!-- end-user-doc -->
404    * @generated
405    */

406   public void setPropertyCategory(String JavaDoc newPropertyCategory)
407   {
408     String JavaDoc oldPropertyCategory = propertyCategory;
409     propertyCategory = newPropertyCategory;
410     if (eNotificationRequired())
411       eNotify(new ENotificationImpl(this, Notification.SET, GenModelPackage.GEN_FEATURE__PROPERTY_CATEGORY, oldPropertyCategory, propertyCategory));
412   }
413
414   /**
415    * <!-- begin-user-doc -->
416    * <!-- end-user-doc -->
417    * @generated
418    */

419   public EList getPropertyFilterFlags()
420   {
421     if (propertyFilterFlags == null)
422     {
423       propertyFilterFlags = new EDataTypeUniqueEList(String JavaDoc.class, this, GenModelPackage.GEN_FEATURE__PROPERTY_FILTER_FLAGS);
424     }
425     return propertyFilterFlags;
426   }
427
428   /**
429    * <!-- begin-user-doc -->
430    * <!-- end-user-doc -->
431    * @generated
432    */

433   public String JavaDoc getPropertyDescription()
434   {
435     return propertyDescription;
436   }
437
438   /**
439    * <!-- begin-user-doc -->
440    * <!-- end-user-doc -->
441    * @generated
442    */

443   public void setPropertyDescription(String JavaDoc newPropertyDescription)
444   {
445     String JavaDoc oldPropertyDescription = propertyDescription;
446     propertyDescription = newPropertyDescription;
447     if (eNotificationRequired())
448       eNotify(new ENotificationImpl(this, Notification.SET, GenModelPackage.GEN_FEATURE__PROPERTY_DESCRIPTION, oldPropertyDescription, propertyDescription));
449   }
450
451   protected void autoSetCreateChild()
452   {
453     if (!isSetCreateChildGen())
454     {
455       setCreateChild(isChildren());
456     }
457   }
458
459   /**
460    * <!-- begin-user-doc -->
461    * <!-- end-user-doc -->
462    * @generated
463    */

464   public GenClass getGenClass()
465   {
466     if (eContainerFeatureID != GenModelPackage.GEN_FEATURE__GEN_CLASS) return null;
467     return (GenClass)eContainer;
468   }
469
470   /**
471    * <!-- begin-user-doc -->
472    * <!-- end-user-doc -->
473    * @generated
474    */

475   public void setGenClass(GenClass newGenClass)
476   {
477     if (newGenClass != eContainer || (eContainerFeatureID != GenModelPackage.GEN_FEATURE__GEN_CLASS && newGenClass != null))
478     {
479       if (EcoreUtil.isAncestor(this, newGenClass))
480         throw new IllegalArgumentException JavaDoc("Recursive containment not allowed for " + toString());
481       NotificationChain msgs = null;
482       if (eContainer != null)
483         msgs = eBasicRemoveFromContainer(msgs);
484       if (newGenClass != null)
485         msgs = ((InternalEObject)newGenClass).eInverseAdd(this, GenModelPackage.GEN_CLASS__GEN_FEATURES, GenClass.class, msgs);
486       msgs = eBasicSetContainer((InternalEObject)newGenClass, GenModelPackage.GEN_FEATURE__GEN_CLASS, msgs);
487       if (msgs != null) msgs.dispatch();
488     }
489     else if (eNotificationRequired())
490       eNotify(new ENotificationImpl(this, Notification.SET, GenModelPackage.GEN_FEATURE__GEN_CLASS, newGenClass, newGenClass));
491   }
492
493   /**
494    * <!-- begin-user-doc -->
495    * <!-- end-user-doc -->
496    * @generated
497    */

498   public EStructuralFeature getEcoreFeature()
499   {
500     if (ecoreFeature != null && ecoreFeature.eIsProxy())
501     {
502       EStructuralFeature oldEcoreFeature = ecoreFeature;
503       ecoreFeature = (EStructuralFeature)eResolveProxy((InternalEObject)ecoreFeature);
504       if (ecoreFeature != oldEcoreFeature)
505       {
506         if (eNotificationRequired())
507           eNotify(new ENotificationImpl(this, Notification.RESOLVE, GenModelPackage.GEN_FEATURE__ECORE_FEATURE, oldEcoreFeature, ecoreFeature));
508       }
509     }
510     return ecoreFeature;
511   }
512
513   /**
514    * <!-- begin-user-doc -->
515    * <!-- end-user-doc -->
516    * @generated
517    */

518   public EStructuralFeature basicGetEcoreFeature()
519   {
520     return ecoreFeature;
521   }
522
523   /**
524    * <!-- begin-user-doc -->
525    * <!-- end-user-doc -->
526    * @generated
527    */

528   public void setEcoreFeature(EStructuralFeature newEcoreFeature)
529   {
530     EStructuralFeature oldEcoreFeature = ecoreFeature;
531     ecoreFeature = newEcoreFeature;
532     if (eNotificationRequired())
533       eNotify(new ENotificationImpl(this, Notification.SET, GenModelPackage.GEN_FEATURE__ECORE_FEATURE, oldEcoreFeature, ecoreFeature));
534   }
535
536   /**
537    * <!-- begin-user-doc -->
538    * <!-- end-user-doc -->
539    * @generated
540    */

541   public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
542   {
543     if (featureID >= 0)
544     {
545       switch (eDerivedStructuralFeatureID(featureID, baseClass))
546       {
547         case GenModelPackage.GEN_FEATURE__GEN_CLASS:
548           if (eContainer != null)
549             msgs = eBasicRemoveFromContainer(msgs);
550           return eBasicSetContainer(otherEnd, GenModelPackage.GEN_FEATURE__GEN_CLASS, msgs);
551         default:
552           return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
553       }
554     }
555     if (eContainer != null)
556       msgs = eBasicRemoveFromContainer(msgs);
557     return eBasicSetContainer(otherEnd, featureID, msgs);
558   }
559
560   /**
561    * <!-- begin-user-doc -->
562    * <!-- end-user-doc -->
563    * @generated
564    */

565   public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
566   {
567     if (featureID >= 0)
568     {
569       switch (eDerivedStructuralFeatureID(featureID, baseClass))
570       {
571         case GenModelPackage.GEN_FEATURE__GEN_CLASS:
572           return eBasicSetContainer(null, GenModelPackage.GEN_FEATURE__GEN_CLASS, msgs);
573         default:
574           return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
575       }
576     }
577     return eBasicSetContainer(null, featureID, msgs);
578   }
579
580   /**
581    * <!-- begin-user-doc -->
582    * <!-- end-user-doc -->
583    * @generated
584    */

585   public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs)
586   {
587     if (eContainerFeatureID >= 0)
588     {
589       switch (eContainerFeatureID)
590       {
591         case GenModelPackage.GEN_FEATURE__GEN_CLASS:
592           return eContainer.eInverseRemove(this, GenModelPackage.GEN_CLASS__GEN_FEATURES, GenClass.class, msgs);
593         default:
594           return eDynamicBasicRemoveFromContainer(msgs);
595       }
596     }
597     return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
598   }
599
600   /**
601    * <!-- begin-user-doc -->
602    * <!-- end-user-doc -->
603    * @generated
604    */

605   public Object JavaDoc eGet(EStructuralFeature eFeature, boolean resolve)
606   {
607     switch (eDerivedStructuralFeatureID(eFeature))
608     {
609       case GenModelPackage.GEN_FEATURE__PROPERTY:
610         return getProperty();
611       case GenModelPackage.GEN_FEATURE__NOTIFY:
612         return isNotify() ? Boolean.TRUE : Boolean.FALSE;
613       case GenModelPackage.GEN_FEATURE__CHILDREN:
614         return isChildren() ? Boolean.TRUE : Boolean.FALSE;
615       case GenModelPackage.GEN_FEATURE__CREATE_CHILD:
616         return isCreateChild() ? Boolean.TRUE : Boolean.FALSE;
617       case GenModelPackage.GEN_FEATURE__PROPERTY_CATEGORY:
618         return getPropertyCategory();
619       case GenModelPackage.GEN_FEATURE__PROPERTY_FILTER_FLAGS:
620         return getPropertyFilterFlags();
621       case GenModelPackage.GEN_FEATURE__PROPERTY_DESCRIPTION:
622         return getPropertyDescription();
623       case GenModelPackage.GEN_FEATURE__GEN_CLASS:
624         return getGenClass();
625       case GenModelPackage.GEN_FEATURE__ECORE_FEATURE:
626         if (resolve) return getEcoreFeature();
627         return basicGetEcoreFeature();
628     }
629     return eDynamicGet(eFeature, resolve);
630   }
631
632   /**
633    * <!-- begin-user-doc -->
634    * <!-- end-user-doc -->
635    * @generated
636    */

637   public boolean eIsSet(EStructuralFeature eFeature)
638   {
639     switch (eDerivedStructuralFeatureID(eFeature))
640     {
641       case GenModelPackage.GEN_FEATURE__PROPERTY:
642         return property != PROPERTY_EDEFAULT;
643       case GenModelPackage.GEN_FEATURE__NOTIFY:
644         return notify != NOTIFY_EDEFAULT;
645       case GenModelPackage.GEN_FEATURE__CHILDREN:
646         return children != CHILDREN_EDEFAULT;
647       case GenModelPackage.GEN_FEATURE__CREATE_CHILD:
648         return isSetCreateChild();
649       case GenModelPackage.GEN_FEATURE__PROPERTY_CATEGORY:
650         return PROPERTY_CATEGORY_EDEFAULT == null ? propertyCategory != null : !PROPERTY_CATEGORY_EDEFAULT.equals(propertyCategory);
651       case GenModelPackage.GEN_FEATURE__PROPERTY_FILTER_FLAGS:
652         return propertyFilterFlags != null && !propertyFilterFlags.isEmpty();
653       case GenModelPackage.GEN_FEATURE__PROPERTY_DESCRIPTION:
654         return PROPERTY_DESCRIPTION_EDEFAULT == null ? propertyDescription != null : !PROPERTY_DESCRIPTION_EDEFAULT.equals(propertyDescription);
655       case GenModelPackage.GEN_FEATURE__GEN_CLASS:
656         return getGenClass() != null;
657       case GenModelPackage.GEN_FEATURE__ECORE_FEATURE:
658         return ecoreFeature != null;
659     }
660     return eDynamicIsSet(eFeature);
661   }
662
663   /**
664    * <!-- begin-user-doc -->
665    * <!-- end-user-doc -->
666    * @generated
667    */

668   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
669   {
670     switch (eDerivedStructuralFeatureID(eFeature))
671     {
672       case GenModelPackage.GEN_FEATURE__PROPERTY:
673         setProperty((GenPropertyKind)newValue);
674         return;
675       case GenModelPackage.GEN_FEATURE__NOTIFY:
676         setNotify(((Boolean JavaDoc)newValue).booleanValue());
677         return;
678       case GenModelPackage.GEN_FEATURE__CHILDREN:
679         setChildren(((Boolean JavaDoc)newValue).booleanValue());
680         return;
681       case GenModelPackage.GEN_FEATURE__CREATE_CHILD:
682         setCreateChild(((Boolean JavaDoc)newValue).booleanValue());
683         return;
684       case GenModelPackage.GEN_FEATURE__PROPERTY_CATEGORY:
685         setPropertyCategory((String JavaDoc)newValue);
686         return;
687       case GenModelPackage.GEN_FEATURE__PROPERTY_FILTER_FLAGS:
688         getPropertyFilterFlags().clear();
689         getPropertyFilterFlags().addAll((Collection JavaDoc)newValue);
690         return;
691       case GenModelPackage.GEN_FEATURE__PROPERTY_DESCRIPTION:
692         setPropertyDescription((String JavaDoc)newValue);
693         return;
694       case GenModelPackage.GEN_FEATURE__GEN_CLASS:
695         setGenClass((GenClass)newValue);
696         return;
697       case GenModelPackage.GEN_FEATURE__ECORE_FEATURE:
698         setEcoreFeature((EStructuralFeature)newValue);
699         return;
700     }
701     eDynamicSet(eFeature, newValue);
702   }
703
704   /**
705    * <!-- begin-user-doc -->
706    * <!-- end-user-doc -->
707    * @generated
708    */

709   public void eUnset(EStructuralFeature eFeature)
710   {
711     switch (eDerivedStructuralFeatureID(eFeature))
712     {
713       case GenModelPackage.GEN_FEATURE__PROPERTY:
714         setProperty(PROPERTY_EDEFAULT);
715         return;
716       case GenModelPackage.GEN_FEATURE__NOTIFY:
717         setNotify(NOTIFY_EDEFAULT);
718         return;
719       case GenModelPackage.GEN_FEATURE__CHILDREN:
720         setChildren(CHILDREN_EDEFAULT);
721         return;
722       case GenModelPackage.GEN_FEATURE__CREATE_CHILD:
723         unsetCreateChild();
724         return;
725       case GenModelPackage.GEN_FEATURE__PROPERTY_CATEGORY:
726         setPropertyCategory(PROPERTY_CATEGORY_EDEFAULT);
727         return;
728       case GenModelPackage.GEN_FEATURE__PROPERTY_FILTER_FLAGS:
729         getPropertyFilterFlags().clear();
730         return;
731       case GenModelPackage.GEN_FEATURE__PROPERTY_DESCRIPTION:
732         setPropertyDescription(PROPERTY_DESCRIPTION_EDEFAULT);
733         return;
734       case GenModelPackage.GEN_FEATURE__GEN_CLASS:
735         setGenClass((GenClass)null);
736         return;
737       case GenModelPackage.GEN_FEATURE__ECORE_FEATURE:
738         setEcoreFeature((EStructuralFeature)null);
739         return;
740     }
741     eDynamicUnset(eFeature);
742   }
743
744   /**
745    * <!-- begin-user-doc -->
746    * <!-- end-user-doc -->
747    * @generated
748    */

749   public String JavaDoc toString()
750   {
751     if (eIsProxy()) return super.toString();
752
753     StringBuffer JavaDoc result = new StringBuffer JavaDoc(super.toString());
754     result.append(" (property: ");
755     result.append(property);
756     result.append(", notify: ");
757     result.append(notify);
758     result.append(", children: ");
759     result.append(children);
760     result.append(", createChild: ");
761     if (createChildESet) result.append(createChild); else result.append("<unset>");
762     result.append(", propertyCategory: ");
763     result.append(propertyCategory);
764     result.append(", propertyFilterFlags: ");
765     result.append(propertyFilterFlags);
766     result.append(", propertyDescription: ");
767     result.append(propertyDescription);
768     result.append(')');
769     return result.toString();
770   }
771
772   public ETypedElement getEcoreTypedElement()
773   {
774     return getEcoreFeature();
775   }
776
777   public String JavaDoc getName()
778   {
779     return getEcoreFeature().getName();
780   }
781
782   public String JavaDoc getCapName()
783   {
784     return capName(getName());
785   }
786
787   public String JavaDoc getAccessorName()
788   {
789     return isMapEntryFeature() ? "Typed" + getCapName() : getCapName();
790   }
791
792   public String JavaDoc getGetAccessor()
793   {
794     String JavaDoc capName = getCapName();
795     if (isMapEntryFeature()) return "getTyped" + capName;
796     String JavaDoc result = isBooleanType() ? "is" + capName : "get" + ("Class".equals(capName) ? "Class_" : capName);
797
798     GenClass rootImplementsInterface = getGenModel().getRootImplementsInterfaceGenClass();
799     if (rootImplementsInterface != null && !rootImplementsInterface.isEObject())
800     {
801       for (Iterator JavaDoc i = rootImplementsInterface.getAllGenOperations().iterator(); i.hasNext(); )
802       {
803         GenOperation genOperation = (GenOperation)i.next();
804         if (genOperation.getName().equals(result) &&
805               genOperation.getGenParameters().isEmpty() &&
806               !genOperation.getType().equals(getType()))
807         {
808           result = result + "_";
809           break;
810         }
811       }
812     }
813
814     return result;
815   }
816
817   public String JavaDoc getSafeName()
818   {
819     return safeName(uncapPrefixedName(getName()));
820   }
821
822   public String JavaDoc getSafeNameAsEObject()
823   {
824     String JavaDoc result = getSafeName();
825     if (!isEObjectExtensionType())
826     {
827       result = "((" + getGenModel().getImportedName("org.eclipse.emf.ecore.EObject") + ")" + result + ")";
828     }
829     return result;
830   }
831
832   public String JavaDoc getFormattedName()
833   {
834     return format(getCapName(), ' ', null, false);
835   }
836
837   public String JavaDoc getUpperName()
838   {
839     return format(getName(), '_', null, false).toUpperCase();
840   }
841
842   public String JavaDoc getUncapName()
843   {
844     return uncapPrefixedName(getName());
845   }
846
847   public String JavaDoc getIsName()
848   {
849     String JavaDoc name = getName();
850     if (name.startsWith("is") && name.length() > 2 && Character.isUpperCase(name.charAt(2)))
851     {
852       return name.substring(2);
853     }
854     else
855     {
856       return capName(name);
857     }
858   }
859
860   public GenPackage getGenPackage()
861   {
862     return getGenClass().getGenPackage();
863   }
864
865   public String JavaDoc getFeatureAccessorName()
866   {
867     return getGenClass().getName() + "_" + getCapName();
868   }
869
870   public String JavaDoc getQualifiedFeatureAccessorName()
871   {
872     return getGenPackage().getImportedPackageInterfaceName() + ".eINSTANCE.get" + getFeatureAccessorName();
873   }
874
875   public String JavaDoc getMetaType()
876   {
877     String JavaDoc importedName = getImportedMetaType();
878     return importedName.substring(importedName.lastIndexOf(".") + 1);
879   }
880
881   public String JavaDoc getImportedMetaType()
882   {
883     if (getEcoreFeature() instanceof EReference)
884       return getGenModel().getImportedName("org.eclipse.emf.ecore.EReference");
885     else
886       return getGenModel().getImportedName("org.eclipse.emf.ecore.EAttribute");
887   }
888
889   public String JavaDoc getFeatureKind()
890   {
891     String JavaDoc kind =
892       getEcoreFeature() instanceof EReference ?
893         isContains() ?
894           isJavaUtilMapEntry(getEcoreFeature().getEType().getInstanceClassName()) ?
895             "map" :
896             "containment reference" :
897           isContainer() ? "container reference" : "reference" :
898         "attribute";
899     return
900       !"map".equals(kind) && getEcoreFeature().isMany() ?
901         kind + " list" :
902         kind;
903   }
904
905   public boolean isReferenceType()
906   {
907     return getEcoreFeature() instanceof EReference;
908   }
909
910   protected boolean isEObjectExtensionType()
911   {
912     return isReferenceType() && super.isEObjectExtensionType();
913   }
914
915   protected boolean isEObjectType()
916   {
917     return isReferenceType() && super.isEObjectType();
918   }
919
920   public boolean isMapType()
921   {
922     return !isContainer() && super.isMapType();
923   }
924
925   public boolean isFlag()
926   {
927     return isBooleanType() && !isVolatile();
928   }
929
930   public boolean isESetFlag()
931   {
932     return isUnsettable() && !isListType() && !isVolatile();
933   }
934
935   public boolean isSetDefaultValue()
936   {
937     return getEcoreFeature().getDefaultValueLiteral() != null;
938   }
939
940   public String JavaDoc getDefaultValue()
941   {
942     if (!isSetDefaultValue()) return null;
943     return "\"" + getEcoreFeature().getDefaultValueLiteral() + "\"";
944   }
945
946   public String JavaDoc getStaticDefaultValue()
947   {
948     String JavaDoc defaultString = getEcoreFeature().getDefaultValueLiteral();
949     EClassifier eType = getEcoreFeature().getEType();
950     if (eType instanceof EDataType)
951     {
952       GenDataType genDataType = (GenDataType)findGenClassifier(eType);
953       return genDataType.getStaticValue(defaultString);
954     }
955
956     return "null";
957   }
958
959   protected boolean isMapEntryFeature()
960   {
961     return getGenClass().isMapEntry() && ("key".equals(getName()) || "value".equals(getName()));
962   }
963
964   public boolean isContainer()
965   {
966     if (isReferenceType())
967     {
968       EReference opposite = ((EReference)getEcoreFeature()).getEOpposite();
969       return opposite != null && opposite.isContainment();
970     }
971     return false;
972   }
973
974   public boolean isContains()
975   {
976     return isReferenceType() && ((EReference)getEcoreFeature()).isContainment();
977   }
978
979   public boolean isBidirectional()
980   {
981     if (isReferenceType())
982     {
983       EReference eReverseFeature = ((EReference)getEcoreFeature()).getEOpposite();
984       return eReverseFeature != null; // && eReverseFeature.isNavigable();
985
}
986     return false;
987   }
988
989   public GenFeature getReverse()
990   {
991     EReference eReverseFeature = ((EReference)getEcoreFeature()).getEOpposite();
992     if (eReverseFeature != null)
993     {
994       EClass eReverseClass = (EClass)eReverseFeature.eContainer();
995       GenClass genClass = findGenClass(eReverseClass);
996       if (genClass != null)
997       {
998         for (Iterator JavaDoc iter = genClass.getGenFeatures().iterator(); iter.hasNext(); )
999         {
1000          GenFeature genFeature = (GenFeature)iter.next();
1001          if (genFeature.getEcoreFeature() == eReverseFeature)
1002          {
1003            return genFeature;
1004          }
1005        }
1006      }
1007    }
1008    return null;
1009  }
1010
1011  public String JavaDoc getContainerClass()
1012  {
1013    return getGenClass().isDocumentRoot() ? "null" : getGenClass().getImportedInterfaceName() + ".class";
1014  }
1015
1016  public String JavaDoc getDerivedFlag()
1017  {
1018    String JavaDoc result = !getEcoreFeature().isDerived() ? "!" : "";
1019    return result + "IS_DERIVED";
1020  }
1021
1022  public String JavaDoc getTransientFlag()
1023  {
1024    String JavaDoc result = !getEcoreFeature().isTransient() ? "!" : "";
1025    return result + "IS_TRANSIENT";
1026  }
1027
1028  public String JavaDoc getVolatileFlag()
1029  {
1030    String JavaDoc result = !getEcoreFeature().isVolatile() ? "!" : "";
1031    return result + "IS_VOLATILE";
1032  }
1033
1034  public String JavaDoc getChangeableFlag()
1035  {
1036    String JavaDoc result = !getEcoreFeature().isChangeable() ? "!" : "";
1037    return result + "IS_CHANGEABLE";
1038  }
1039
1040  public String JavaDoc getUnsettableFlag()
1041  {
1042    String JavaDoc result = !isUnsettable() ? "!" : "";
1043    return result + "IS_UNSETTABLE";
1044  }
1045
1046  public String JavaDoc getIDFlag()
1047  {
1048    String JavaDoc result = !isID() ? "!" : "";
1049    return result + "IS_ID";
1050  }
1051
1052  public String JavaDoc getContainmentFlag()
1053  {
1054    String JavaDoc result = !((EReference)getEcoreFeature()).isContainment() ? "!" : "";
1055    return result + "IS_COMPOSITE";
1056  }
1057
1058  public String JavaDoc getResolveProxiesFlag()
1059  {
1060    String JavaDoc result = !isResolveProxies() ? "!" : "";
1061    return result + "IS_RESOLVE_PROXIES";
1062  }
1063
1064  public boolean isResolveProxies()
1065  {
1066    EStructuralFeature eStructuralFeature = getEcoreFeature();
1067    return !isContainer() && !isContains() &&
1068           eStructuralFeature instanceof EReference && ((EReference)eStructuralFeature).isResolveProxies();
1069  }
1070
1071  public boolean isVolatile()
1072  {
1073    // We treat the feature as volatile if it is volatile itself or if it is
1074
// a reference whose opposite end is volatile.
1075

1076    EReference eReverseFeature = isReferenceType() ?
1077      ((EReference)getEcoreFeature()).getEOpposite() : null;
1078
1079    return (getEcoreFeature().isVolatile() ||
1080            (eReverseFeature != null && eReverseFeature.isVolatile()));
1081  }
1082
1083  public boolean isChangeable()
1084  {
1085    return getEcoreFeature().isChangeable();
1086  }
1087
1088  public boolean isUnsettable()
1089  {
1090    EStructuralFeature eStructuralFeature = getEcoreFeature();
1091    return eStructuralFeature.isUnsettable() && !isContainer();
1092  }
1093
1094  public boolean isID()
1095  {
1096    EStructuralFeature eStructuralFeature = getEcoreFeature();
1097    return eStructuralFeature instanceof EAttribute && ((EAttribute)eStructuralFeature).isID();
1098  }
1099  public boolean isDerived()
1100  {
1101    return getEcoreFeature().isDerived();
1102  }
1103
1104  public boolean hasDelegateFeature()
1105  {
1106    EStructuralFeature ecoreFeature = getEcoreFeature();
1107    EClass ecoreClass = ecoreFeature.getEContainingClass();
1108    EStructuralFeature mixedFeature = getExtendedMetaData().getMixedFeature(ecoreClass);
1109    return
1110      (mixedFeature != null && mixedFeature != ecoreFeature) ||
1111      getExtendedMetaData().getGroup(ecoreFeature) != null;
1112  }
1113
1114  public GenFeature getDelegateFeature()
1115  {
1116    EStructuralFeature ecoreFeature = getEcoreFeature();
1117    EClass ecoreClass = ecoreFeature.getEContainingClass();
1118    EStructuralFeature eStructuralFeature = getExtendedMetaData().getGroup(ecoreFeature);
1119    if (eStructuralFeature == null)
1120    {
1121      eStructuralFeature = getExtendedMetaData().getMixedFeature(ecoreClass);
1122    }
1123    if (eStructuralFeature != null && eStructuralFeature != ecoreFeature)
1124    {
1125      return findGenFeature(eStructuralFeature);
1126    }
1127    else
1128    {
1129      return null;
1130    }
1131  }
1132
1133  /**
1134   * It considers mixed types, model groups, subsitution groups and wildcards.
1135   */

1136  public List JavaDoc/*of GenFeature*/ getDelegatedFeatures()
1137  {
1138    if (!isFeatureMapType()) return Collections.EMPTY_LIST;
1139
1140    GenClass genClass = getGenClass();
1141    List JavaDoc delegated = new ArrayList JavaDoc();
1142
1143    ExtendedMetaData extendedMetaData = getExtendedMetaData();
1144    if (genClass.getMixedGenFeature() == this)
1145    {
1146       delegated.add(findGenFeature(XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Comment()));
1147       delegated.add(findGenFeature(XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text()));
1148
1149       if (!genClass.isDocumentRoot())
1150       {
1151         delegated.add(findGenFeature(XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_CDATA()));
1152       }
1153
1154       for (Iterator JavaDoc iter = genClass.getGenFeatures().iterator(); iter.hasNext(); )
1155       {
1156         GenFeature otherFeature = (GenFeature)iter.next();
1157         if (otherFeature != this && otherFeature.isDerived() &&
1158             extendedMetaData.getGroup(otherFeature.getEcoreFeature()) == null)
1159         {
1160           delegated.add(otherFeature);
1161         }
1162       }
1163    }
1164    else
1165    {
1166      switch (extendedMetaData.getFeatureKind(getEcoreFeature()))
1167      {
1168        case ExtendedMetaData.GROUP_FEATURE:
1169        {
1170          Set JavaDoc allDelegated = new HashSet JavaDoc();
1171          Set JavaDoc qNames = new HashSet JavaDoc();
1172          for (Iterator JavaDoc i = genClass.getGenFeatures().iterator(); i.hasNext(); )
1173          {
1174            GenFeature otherFeature = (GenFeature)i.next();
1175            if (otherFeature != this && otherFeature.isDerived() &&
1176                extendedMetaData.getGroup(otherFeature.getEcoreFeature()) == getEcoreFeature())
1177            {
1178              if (otherFeature.isChangeable())
1179              {
1180                delegated.add(otherFeature);
1181                qNames.add
1182                  (extendedMetaData.getNamespace(otherFeature.getEcoreFeature()) + "#" +
1183                     extendedMetaData.getName(otherFeature.getEcoreFeature()));
1184              }
1185              allDelegated.add(otherFeature.getEcoreFeature());
1186            }
1187          }
1188          
1189          for (Iterator JavaDoc i = getGenModel().getAllGenAndUsedGenPackagesWithClassifiers().iterator(); i.hasNext(); )
1190          {
1191            GenPackage genPackage = (GenPackage)i.next();
1192            if (genPackage.hasDocumentRoot())
1193            {
1194              GenClass documentRoot = findGenClass(extendedMetaData.getDocumentRoot(genPackage.getEcorePackage()));
1195              for (Iterator JavaDoc j = documentRoot.getGenFeatures().iterator(); j.hasNext(); )
1196              {
1197                GenFeature otherFeature = (GenFeature)j.next();
1198                if (otherFeature != this &&
1199                      otherFeature.isChangeable() &&
1200                      otherFeature.isDerived() &&
1201                      allDelegated.contains(extendedMetaData.getAffiliation(genClass.getEcoreClass(), otherFeature.getEcoreFeature())))
1202                {
1203                  if (qNames.add
1204                        (extendedMetaData.getNamespace(otherFeature.getEcoreFeature()) + "#" +
1205                           extendedMetaData.getName(otherFeature.getEcoreFeature())))
1206                  {
1207                    delegated.add(otherFeature);
1208                  }
1209                }
1210              }
1211            }
1212          }
1213            
1214          break;
1215        }
1216        case ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE:
1217        case ExtendedMetaData.ELEMENT_WILDCARD_FEATURE:
1218        {
1219          for (Iterator JavaDoc i = getGenModel().getAllGenAndUsedGenPackagesWithClassifiers().iterator(); i.hasNext(); )
1220          {
1221            GenPackage genPackage = (GenPackage)i.next();
1222            if (genPackage.hasDocumentRoot())
1223            {
1224              GenClass documentRoot = findGenClass(extendedMetaData.getDocumentRoot(genPackage.getEcorePackage()));
1225              for (Iterator JavaDoc j = documentRoot.getGenFeatures().iterator(); j.hasNext(); )
1226              {
1227                GenFeature otherFeature = (GenFeature)j.next();
1228                if (otherFeature != this &&
1229                      otherFeature.isChangeable() &&
1230                      otherFeature.isDerived() &&
1231                      extendedMetaData.getAffiliation(genClass.getEcoreClass(), otherFeature.getEcoreFeature()) == getEcoreFeature())
1232                {
1233                  delegated.add(otherFeature);
1234                }
1235              }
1236            }
1237          }
1238          break;
1239        }
1240      }
1241    }
1242   /*
1243    else if (extendedMetaData.getFeatureKind(getEcoreFeature()) == ExtendedMetaData.GROUP_FEATURE)
1244    {
1245      for (Iterator iter = genClass.getGenFeatures().iterator(); iter.hasNext(); )
1246      {
1247        GenFeature otherFeature = (GenFeature)iter.next();
1248        if (otherFeature != this && otherFeature.isDerived() && otherFeature.isChangeable() &&
1249            extendedMetaData.getGroup(otherFeature.getEcoreFeature()) == getEcoreFeature())
1250        {
1251          delegated.add(otherFeature);
1252        }
1253      }
1254    }
1255    */

1256
1257    List JavaDoc result = new ArrayList JavaDoc();
1258    for (Iterator JavaDoc iter = delegated.iterator(); iter.hasNext(); )
1259    {
1260      GenFeature feature = (GenFeature)iter.next();
1261      if (feature.isFeatureMapType())
1262      {
1263        result.addAll(feature.getDelegatedFeatures());
1264      }
1265      else
1266      {
1267        result.add(feature);
1268      }
1269    }
1270    return result;
1271  }
1272
1273  public String JavaDoc getCreateChildValueLiteral()
1274  {
1275    String JavaDoc result = getDefaultValue();
1276
1277    if (result == null)
1278    {
1279      Class JavaDoc c = getEcoreFeature().getEType().getInstanceClass();
1280
1281      if (c == Boolean.TYPE || c == Boolean JavaDoc.class)
1282      {
1283        result = "\"false\"";
1284      }
1285      else if (c == String JavaDoc.class)
1286      {
1287        result = "\"\"";
1288      }
1289      else if (c == Character JavaDoc.class)
1290      {
1291        result = "\"0\"";
1292      }
1293      else if (c == Byte.TYPE || c == Short.TYPE || c == Integer.TYPE || c == Long.TYPE || c == Float.TYPE || c == Double.TYPE ||
1294               (c != null && Number JavaDoc.class.isAssignableFrom(c)))
1295      {
1296        result = "\"0\"";
1297      }
1298    }
1299    return result;
1300  }
1301
1302  public boolean isSuppressedGetVisibility()
1303  {
1304    return EcoreUtil.isSuppressedVisibility(getEcoreFeature(), EcoreUtil.GET);
1305  }
1306
1307  public boolean isSuppressedSetVisibility()
1308  {
1309    return EcoreUtil.isSuppressedVisibility(getEcoreFeature(), EcoreUtil.SET);
1310  }
1311
1312  public boolean isSuppressedIsSetVisibility()
1313  {
1314    return EcoreUtil.isSuppressedVisibility(getEcoreFeature(), EcoreUtil.IS_SET);
1315  }
1316
1317  public boolean isSuppressedUnsetVisibility()
1318  {
1319    return EcoreUtil.isSuppressedVisibility(getEcoreFeature(), EcoreUtil.UNSET);
1320  }
1321
1322  public void initialize(EStructuralFeature eFeature)
1323  {
1324    if (eFeature != getEcoreFeature())
1325    {
1326      setEcoreFeature(eFeature);
1327  
1328      if (eFeature instanceof EReference)
1329      {
1330        EReference eReference = (EReference)eFeature;
1331        if (!eReference.isContainer() && !eReference.isContainment())
1332        {
1333          setProperty(eFeature.isChangeable() ? GenPropertyKind.EDITABLE_LITERAL : GenPropertyKind.READONLY_LITERAL);
1334        }
1335        else
1336        {
1337          setProperty(GenPropertyKind.NONE_LITERAL);
1338        }
1339        setChildren(eReference.isContainment() && !hasDelegateFeature());
1340        setCreateChild(isChildren() && isChangeable());
1341        setNotify(isChildren());
1342      }
1343      else if (isFeatureMapType())
1344      {
1345        setProperty(GenPropertyKind.NONE_LITERAL);
1346        setChildren(!hasDelegateFeature());
1347        setCreateChild(isChildren() && isChangeable());
1348        setNotify(isChildren());
1349      }
1350      else
1351      {
1352        setProperty(eFeature.isChangeable() ? GenPropertyKind.EDITABLE_LITERAL : GenPropertyKind.READONLY_LITERAL);
1353        setChildren(false);
1354        setCreateChild(false);
1355        setNotify(true);
1356      }
1357    }
1358  }
1359
1360  public String JavaDoc getModelInfo()
1361  {
1362    return getModelInfo(false);
1363  }
1364
1365  public String JavaDoc getQualifiedModelInfo()
1366  {
1367    return getModelInfo(true);
1368  }
1369
1370  AnnotationFilter DEFAULT_GEN_FEATURE_ANNOTATION_FILTER =
1371    new AnnotationFilterImpl()
1372    {
1373      public boolean accept(EModelElement eModelElement, String JavaDoc source, String JavaDoc key, String JavaDoc value)
1374      {
1375        return
1376          super.accept(eModelElement, source, key, value) &&
1377            !(GenModelPackage.eNS_URI.equals(source) &&
1378                ("suppressedSetVisibility".equals(key) ||
1379                   "suppressedGetVisibility".equals(key) ||
1380                   "suppressedIsSetVisibility".equals(key) ||
1381                   "suppressedUnsetVisibility".equals(key)));
1382      }
1383    };
1384
1385  public String JavaDoc getModelInfo(boolean qualified)
1386  {
1387    EStructuralFeature eStructuralFeature = getEcoreFeature();
1388    StringBuffer JavaDoc result = new StringBuffer JavaDoc();
1389    boolean defaultTransient = false;
1390
1391    // We don't want keyType and valueType on a map type specification in a package interface.
1392
// But, we also use qualified model information when defining a feature with suppressed get accessor
1393
// on the interface, and we do want to include these properties in that case.
1394
//
1395
String JavaDoc mapModelInfo = getMapModelInfo(qualified, (!qualified || isSuppressedGetVisibility()) && !isContainer());
1396    if (mapModelInfo != null)
1397    {
1398      result.append(mapModelInfo);
1399    }
1400    else
1401    {
1402      if (eStructuralFeature.isMany() && !isFeatureMapType() || qualified)
1403      {
1404        appendModelSetting(result, qualified, "type", getType(eStructuralFeature.getEType(), false));
1405      }
1406
1407      if (eStructuralFeature instanceof EReference)
1408      {
1409        EReference reference = (EReference) eStructuralFeature;
1410        EReference opposite = reference.getEOpposite();
1411        if (opposite != null)
1412        {
1413          appendModelSetting(result, qualified, "opposite", opposite.getName());
1414
1415          if (opposite.isContainment())
1416          {
1417            defaultTransient = true;
1418          }
1419        }
1420        if (reference.isContainment())
1421        {
1422          appendModelSetting(result, qualified, "containment", "true");
1423        }
1424        if (!reference.isResolveProxies())
1425        {
1426          appendModelSetting(result, qualified, "resolveProxies", "false");
1427        }
1428        if (reference.isUnsettable())
1429        {
1430          appendModelSetting(result, qualified, "unsettable", "true");
1431        }
1432      }
1433      else if (eStructuralFeature instanceof EAttribute)
1434      {
1435        EAttribute attribute = (EAttribute) eStructuralFeature;
1436        if (eStructuralFeature.getDefaultValueLiteral() != null)
1437        {
1438          appendModelSetting(result, qualified, "default", eStructuralFeature.getDefaultValueLiteral());
1439        }
1440        if (!eStructuralFeature.isUnique())
1441        {
1442          appendModelSetting(result, qualified, "unique", "false");
1443        }
1444        if (attribute.isUnsettable())
1445        {
1446          appendModelSetting(result, qualified, "unsettable", "true");
1447        }
1448        if (attribute.isID())
1449        {
1450          appendModelSetting(result, qualified, "id", "true");
1451        }
1452
1453        EDataType eDataType = attribute.getEAttributeType();
1454        if (!(eDataType instanceof EEnum))
1455        {
1456          GenPackage genPackage = findGenPackage(eDataType.getEPackage());
1457          if (genPackage != null && (isFeatureMapType() || !genPackage.isEcorePackage()))
1458          {
1459            appendModelSetting(result, qualified, "dataType", genPackage.getInterfacePackageName() + '.' + eDataType.getName());
1460          }
1461        }
1462      }
1463
1464      result.append(getMultiplicityModelInfo(qualified));
1465    }
1466
1467    if (eStructuralFeature.isTransient() && !defaultTransient)
1468    {
1469      appendModelSetting(result, qualified, "transient", "true");
1470    }
1471
1472    if (!eStructuralFeature.isChangeable())
1473    {
1474      appendModelSetting(result, qualified, "changeable", "false");
1475    }
1476
1477    if (eStructuralFeature.isVolatile())
1478    {
1479      appendModelSetting(result, qualified, "volatile", "true");
1480    }
1481
1482    if (eStructuralFeature.isDerived())
1483    {
1484      appendModelSetting(result, qualified, "derived", "true");
1485    }
1486
1487    if (!eStructuralFeature.isOrdered())
1488    {
1489      appendModelSetting(result, qualified, "ordered", "false");
1490    }
1491
1492    if (isSuppressedGetVisibility())
1493    {
1494      appendModelSetting(result, qualified, "suppressedGetVisibility", "true");
1495    }
1496    if (isSuppressedSetVisibility())
1497    {
1498      appendModelSetting(result, qualified, "suppressedSetVisibility", "true");
1499    }
1500    if (isSuppressedIsSetVisibility())
1501    {
1502      appendModelSetting(result, qualified, "suppressedIsSetVisibility", "true");
1503    }
1504    if (isSuppressedUnsetVisibility())
1505    {
1506      appendModelSetting(result, qualified, "suppressedUnsetVisibility", "true");
1507    }
1508
1509    appendAnnotationInfo(result, qualified, eStructuralFeature, DEFAULT_GEN_FEATURE_ANNOTATION_FILTER);
1510    return result.toString().trim();
1511  }
1512
1513  //
1514
// EMFEdit generation
1515
//
1516

1517  public String JavaDoc getPropertyImageName()
1518  {
1519    EClassifier eType = getEcoreFeature().getEType();
1520    if (isPrimitiveType(eType))
1521    {
1522      Class JavaDoc instanceClass = eType.getInstanceClass();
1523      if (instanceClass == Boolean.TYPE || instanceClass == Boolean JavaDoc.class)
1524      {
1525        return "BOOLEAN_VALUE_IMAGE";
1526      }
1527      else if (instanceClass == Byte.TYPE || instanceClass == Byte JavaDoc.class ||
1528               instanceClass == Integer.TYPE || instanceClass == Integer JavaDoc.class ||
1529               instanceClass == Long.TYPE || instanceClass == Long JavaDoc.class ||
1530               instanceClass == Short.TYPE || instanceClass == Short JavaDoc.class)
1531      {
1532        return "INTEGRAL_VALUE_IMAGE";
1533      }
1534      else if (instanceClass == Character.TYPE || instanceClass == Character JavaDoc.class ||
1535               instanceClass == String JavaDoc.class)
1536      {
1537        return "TEXT_VALUE_IMAGE";
1538      }
1539      else if (instanceClass == Double.TYPE || instanceClass == Double JavaDoc.class ||
1540               instanceClass == Float.TYPE || instanceClass == Float JavaDoc.class)
1541      {
1542        return "REAL_VALUE_IMAGE";
1543      }
1544    }
1545
1546    return "GENERIC_VALUE_IMAGE";
1547  }
1548
1549  public boolean reconcile(GenFeature oldGenFeatureVersion)
1550  {
1551    if (getEcoreFeature().getName().equals(oldGenFeatureVersion.getEcoreFeature().getName()))
1552    {
1553      reconcileSettings(oldGenFeatureVersion);
1554      return true;
1555    }
1556    else
1557    {
1558      return false;
1559    }
1560  }
1561
1562  protected void reconcileSettings(GenFeature oldGenFeatureVersion)
1563  {
1564    setProperty(oldGenFeatureVersion.getProperty());
1565    setNotify(oldGenFeatureVersion.isNotify());
1566    setChildren(oldGenFeatureVersion.isChildren());
1567    setCreateChild(oldGenFeatureVersion.isCreateChild());
1568    setPropertyCategory(oldGenFeatureVersion.getPropertyCategory());
1569    setPropertyDescription(oldGenFeatureVersion.getPropertyDescription());
1570
1571    getPropertyFilterFlags().addAll(oldGenFeatureVersion.getPropertyFilterFlags());
1572  }
1573
1574  public boolean reconcile()
1575  {
1576    EStructuralFeature eFeature = getEcoreFeature();
1577    if (eFeature == null || eFeature.eIsProxy() || eFeature.eResource() == null)
1578    {
1579      return false;
1580    }
1581    else
1582    {
1583      return true;
1584    }
1585  }
1586
1587  public boolean isField()
1588  {
1589    return !isContainer() && !isVolatile();
1590  }
1591
1592  public boolean isESetField()
1593  {
1594    return !isContainer() && !isListType() && isUnsettable() && !isVolatile();
1595  }
1596
1597  public boolean isGet()
1598  {
1599    return true;
1600  }
1601
1602  public boolean isBasicGet()
1603  {
1604    return !getGenModel().isReflectiveDelegation() && isResolveProxies() && !isListType();
1605  }
1606
1607  public boolean isBasicSet()
1608  {
1609    return !getGenModel().isReflectiveDelegation() && !isListType()
1610      && (isBidirectional() && !isContainer() && !isVolatile() || isContains());
1611  }
1612
1613  public boolean isSet()
1614  {
1615    return !isListType() && isChangeable();
1616  }
1617
1618  public boolean isBasicUnset()
1619  {
1620    return isUnsettable() && isChangeable() && !isListType() && isReferenceType() && (isBidirectional() || isContains());
1621  }
1622
1623  public boolean isUnset()
1624  {
1625    return isUnsettable() && isChangeable();
1626  }
1627
1628  public boolean isIsSet()
1629  {
1630    return isUnsettable();
1631  }
1632
1633} //GenFeatureImpl
1634
Popular Tags