KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > sdo > impl > EPropertyImpl


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2003-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: EPropertyImpl.java,v 1.7 2005/06/08 06:24:25 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.sdo.impl;
18
19
20 import org.eclipse.emf.common.notify.Adapter;
21 import org.eclipse.emf.common.notify.Notification;
22 import org.eclipse.emf.common.notify.NotificationChain;
23 import org.eclipse.emf.common.notify.Notifier;
24 import org.eclipse.emf.ecore.EClass;
25 import org.eclipse.emf.ecore.EReference;
26 import org.eclipse.emf.ecore.EStructuralFeature;
27 import org.eclipse.emf.ecore.impl.ENotificationImpl;
28 import org.eclipse.emf.ecore.impl.EObjectImpl;
29 import org.eclipse.emf.ecore.sdo.EProperty;
30 import org.eclipse.emf.ecore.sdo.SDOPackage;
31 import org.eclipse.emf.ecore.sdo.util.SDOUtil;
32 import org.eclipse.emf.ecore.util.EcoreUtil;
33
34 import commonj.sdo.Type;
35
36
37 /**
38  * <!-- begin-user-doc -->
39  * An implementation of the model object '<em><b>EProperty</b></em>'.
40  * @extends Adapter
41  * <!-- end-user-doc -->
42  * <p>
43  * The following features are implemented:
44  * <ul>
45  * <li>{@link org.eclipse.emf.ecore.sdo.impl.EPropertyImpl#getName <em>Name</em>}</li>
46  * <li>{@link org.eclipse.emf.ecore.sdo.impl.EPropertyImpl#isMany <em>Many</em>}</li>
47  * <li>{@link org.eclipse.emf.ecore.sdo.impl.EPropertyImpl#isContainment <em>Containment</em>}</li>
48  * <li>{@link org.eclipse.emf.ecore.sdo.impl.EPropertyImpl#getDefault <em>Default</em>}</li>
49  * <li>{@link org.eclipse.emf.ecore.sdo.impl.EPropertyImpl#getType <em>Type</em>}</li>
50  * <li>{@link org.eclipse.emf.ecore.sdo.impl.EPropertyImpl#getContainingType <em>Containing Type</em>}</li>
51  * <li>{@link org.eclipse.emf.ecore.sdo.impl.EPropertyImpl#getEStructuralFeature <em>EStructural Feature</em>}</li>
52  * </ul>
53  * </p>
54  *
55  * @generated
56  */

57 public class EPropertyImpl extends EObjectImpl implements EProperty, Adapter
58 {
59   /**
60    * The default value of the '{@link #getName() <em>Name</em>}' attribute.
61    * <!-- begin-user-doc -->
62    * <!-- end-user-doc -->
63    * @see #getName()
64    * @generated
65    * @ordered
66    */

67   protected static final String JavaDoc NAME_EDEFAULT = null;
68
69   /**
70    * The default value of the '{@link #isMany() <em>Many</em>}' attribute.
71    * <!-- begin-user-doc -->
72    * <!-- end-user-doc -->
73    * @see #isMany()
74    * @generated
75    * @ordered
76    */

77   protected static final boolean MANY_EDEFAULT = false;
78
79   /**
80    * The default value of the '{@link #isContainment() <em>Containment</em>}' attribute.
81    * <!-- begin-user-doc -->
82    * <!-- end-user-doc -->
83    * @see #isContainment()
84    * @generated
85    * @ordered
86    */

87   protected static final boolean CONTAINMENT_EDEFAULT = false;
88
89   /**
90    * The default value of the '{@link #getDefault() <em>Default</em>}' attribute.
91    * <!-- begin-user-doc -->
92    * <!-- end-user-doc -->
93    * @see #getDefault()
94    * @generated
95    * @ordered
96    */

97   protected static final Object JavaDoc DEFAULT_EDEFAULT = null;
98
99   /**
100    * The cached value of the '{@link #getEStructuralFeature() <em>EStructural Feature</em>}' reference.
101    * <!-- begin-user-doc -->
102    * <!-- end-user-doc -->
103    * @see #getEStructuralFeature()
104    * @generated
105    * @ordered
106    */

107   protected EStructuralFeature eStructuralFeature = null;
108
109   /**
110    * <!-- begin-user-doc -->
111    * <!-- end-user-doc -->
112    * @generated
113    */

114   protected EPropertyImpl()
115   {
116     super();
117   }
118
119   /**
120    * <!-- begin-user-doc -->
121    * <!-- end-user-doc -->
122    * @generated
123    */

124   protected EClass eStaticClass()
125   {
126     return SDOPackage.eINSTANCE.getEProperty();
127   }
128
129   /**
130    * <!-- begin-user-doc -->
131    * <!-- end-user-doc -->
132    * @generated NOT
133    */

134   public String JavaDoc getName()
135   {
136     return eStructuralFeature.getName();
137   }
138
139   /**
140    * <!-- begin-user-doc -->
141    * <!-- end-user-doc -->
142    * @generated NOT
143    */

144   public boolean isMany()
145   {
146     return eStructuralFeature.isMany();
147   }
148
149   /**
150    * <!-- begin-user-doc -->
151    * <!-- end-user-doc -->
152    * @generated NOT
153    */

154   public boolean isContainment()
155   {
156     return eStructuralFeature instanceof EReference && ((EReference)eStructuralFeature).isContainment();
157   }
158
159   /**
160    * <!-- begin-user-doc -->
161    * <!-- end-user-doc -->
162    * @generated NOT
163    */

164   public Object JavaDoc getDefault()
165   {
166     return eStructuralFeature.getDefaultValue();
167   }
168
169   /**
170    * <!-- begin-user-doc -->
171    * <!-- end-user-doc -->
172    * @generated NOT
173    */

174   public Type getType()
175   {
176     return SDOUtil.adaptType(eStructuralFeature.getEType());
177   }
178
179   /**
180    * <!-- begin-user-doc -->
181    * <!-- end-user-doc -->
182    * @generated NOT
183    */

184   public Type getContainingType()
185   {
186     return SDOUtil.adaptType(eStructuralFeature.getEContainingClass());
187   }
188
189   /**
190    * <!-- begin-user-doc -->
191    * <!-- end-user-doc -->
192    * @generated
193    */

194   public EStructuralFeature getEStructuralFeature()
195   {
196     return eStructuralFeature;
197   }
198
199   /**
200    * <!-- begin-user-doc -->
201    * <!-- end-user-doc -->
202    * @generated
203    */

204   public void setEStructuralFeature(EStructuralFeature newEStructuralFeature)
205   {
206     EStructuralFeature oldEStructuralFeature = eStructuralFeature;
207     eStructuralFeature = newEStructuralFeature;
208     if (eNotificationRequired())
209       eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.EPROPERTY__ESTRUCTURAL_FEATURE, oldEStructuralFeature, eStructuralFeature));
210   }
211
212   public boolean isAdapterForType(Object JavaDoc type)
213   {
214     return type == EProperty.class;
215   }
216
217   public void notifyChanged(Notification msg)
218   {
219   }
220
221   public Notifier getTarget()
222   {
223     return getEStructuralFeature();
224   }
225
226   public void setTarget(Notifier newTarget)
227   {
228     setEStructuralFeature((EStructuralFeature)newTarget);
229   }
230
231   public boolean isReadOnly()
232   {
233     return "true".equals(EcoreUtil.getAnnotation(eStructuralFeature, "commonj.sdo", "readOnly"));
234   }
235
236   public void setReadOnly(boolean readOnly)
237   {
238     EcoreUtil.setAnnotation(eStructuralFeature, "commonj.sdo", "readOnly", readOnly ? "true" : "false");
239   }
240
241   /**
242    * <!-- begin-user-doc -->
243    * <!-- end-user-doc -->
244    * @generated
245    */

246   public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs)
247   {
248     if (eContainerFeatureID >= 0)
249     {
250       switch (eContainerFeatureID)
251       {
252         case SDOPackage.EPROPERTY__CONTAINING_TYPE:
253           return eContainer.eInverseRemove(this, SDOPackage.TYPE__PROPERTIES, Type.class, msgs);
254         default:
255           return eDynamicBasicRemoveFromContainer(msgs);
256       }
257     }
258     return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
259   }
260
261   /**
262    * <!-- begin-user-doc -->
263    * <!-- end-user-doc -->
264    * @generated
265    */

266   public Object JavaDoc eGet(EStructuralFeature eFeature, boolean resolve)
267   {
268     switch (eDerivedStructuralFeatureID(eFeature))
269     {
270       case SDOPackage.EPROPERTY__NAME:
271         return getName();
272       case SDOPackage.EPROPERTY__MANY:
273         return isMany() ? Boolean.TRUE : Boolean.FALSE;
274       case SDOPackage.EPROPERTY__CONTAINMENT:
275         return isContainment() ? Boolean.TRUE : Boolean.FALSE;
276       case SDOPackage.EPROPERTY__DEFAULT:
277         return getDefault();
278       case SDOPackage.EPROPERTY__TYPE:
279         return getType();
280       case SDOPackage.EPROPERTY__CONTAINING_TYPE:
281         return getContainingType();
282       case SDOPackage.EPROPERTY__ESTRUCTURAL_FEATURE:
283         return getEStructuralFeature();
284     }
285     return eDynamicGet(eFeature, resolve);
286   }
287
288   /**
289    * <!-- begin-user-doc -->
290    * <!-- end-user-doc -->
291    * @generated
292    */

293   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
294   {
295     switch (eDerivedStructuralFeatureID(eFeature))
296     {
297       case SDOPackage.EPROPERTY__ESTRUCTURAL_FEATURE:
298         setEStructuralFeature((EStructuralFeature)newValue);
299         return;
300     }
301     eDynamicSet(eFeature, newValue);
302   }
303
304   /**
305    * <!-- begin-user-doc -->
306    * <!-- end-user-doc -->
307    * @generated
308    */

309   public void eUnset(EStructuralFeature eFeature)
310   {
311     switch (eDerivedStructuralFeatureID(eFeature))
312     {
313       case SDOPackage.EPROPERTY__ESTRUCTURAL_FEATURE:
314         setEStructuralFeature((EStructuralFeature)null);
315         return;
316     }
317     eDynamicUnset(eFeature);
318   }
319
320   /**
321    * <!-- begin-user-doc -->
322    * <!-- end-user-doc -->
323    * @generated
324    */

325   public boolean eIsSet(EStructuralFeature eFeature)
326   {
327     switch (eDerivedStructuralFeatureID(eFeature))
328     {
329       case SDOPackage.EPROPERTY__NAME:
330         return NAME_EDEFAULT == null ? getName() != null : !NAME_EDEFAULT.equals(getName());
331       case SDOPackage.EPROPERTY__MANY:
332         return isMany() != MANY_EDEFAULT;
333       case SDOPackage.EPROPERTY__CONTAINMENT:
334         return isContainment() != CONTAINMENT_EDEFAULT;
335       case SDOPackage.EPROPERTY__DEFAULT:
336         return DEFAULT_EDEFAULT == null ? getDefault() != null : !DEFAULT_EDEFAULT.equals(getDefault());
337       case SDOPackage.EPROPERTY__TYPE:
338         return getType() != null;
339       case SDOPackage.EPROPERTY__CONTAINING_TYPE:
340         return getContainingType() != null;
341       case SDOPackage.EPROPERTY__ESTRUCTURAL_FEATURE:
342         return eStructuralFeature != null;
343     }
344     return eDynamicIsSet(eFeature);
345   }
346
347 } //EPropertyImpl
348
Popular Tags