KickJava   Java API By Example, From Geeks To Geeks.

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


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

17 package org.eclipse.emf.ecore.impl;
18
19
20 import org.eclipse.emf.common.util.BasicEList;
21 import org.eclipse.emf.common.util.EList;
22 import org.eclipse.emf.common.util.URI;
23 import org.eclipse.emf.ecore.EClass;
24 import org.eclipse.emf.ecore.EObject;
25 import org.eclipse.emf.ecore.EcorePackage;
26 import org.eclipse.emf.ecore.InternalEObject;
27
28
29 /**
30  * <!-- begin-user-doc -->
31  * An implementation of the model object '<em><b>EObject</b></em>'.
32  * <!-- end-user-doc -->
33  * <p>
34  * </p>
35  *
36  * @generated NOT
37  */

38 public class EObjectImpl extends BasicEObjectImpl implements EObject
39 {
40   /**
41    * The bit of {@link #eFlags} that is used to represent {@link #eDeliver}.
42    */

43   protected static final int EDELIVER = 0x0001;
44   
45   /**
46    * The bit of {@link #eFlags} that is used to represent whether there is a dynamic EClass.
47    */

48   protected static final int EDYNAMIC_CLASS = 0x0002;
49
50   /**
51    * The bit of {@link #eFlags} that is used to represent {@link #eIsProxy}.
52    */

53   protected static final int EPROXY = 0x004;
54
55   /**
56    * The last bit used by this class; derived classes may use bit values higher than this.
57    */

58   protected static final int ELAST_NOTIFIER_FLAG = EPROXY;
59
60   /**
61    * The last bit used by this class; derived classes may use bit values higher than this.
62    */

63   public static final int ELAST_EOBJECT_FLAG = ELAST_NOTIFIER_FLAG;
64
65   /**
66    * An extensible set of bit flags;
67    * the first bit is used for {@link #EDELIVER} to implement {@link #eDeliver}
68    * and the second bit is used for {@link #EPROXY} to implement {@link #eIsProxy}.
69    */

70   protected int eFlags = EDELIVER;
71
72   /**
73    * The list of {@link org.eclipse.emf.common.notify.Adapter}s associated with the notifier.
74    */

75   protected BasicEList eAdapters;
76
77   /**
78    * The container of this object.
79    */

80   protected InternalEObject eContainer;
81
82   /**
83    * The feature ID of this object's container holding feature, if there is one,
84    * or {@link #EOPPOSITE_FEATURE_BASE EOPPOSITE_FEATURE_BASE} minus the feature ID of the container's feature that contains this object.
85    */

86   protected int eContainerFeatureID;
87
88   /**
89    * Additional less frequently used fields.
90    */

91   protected EPropertiesHolder eProperties;
92   
93   /**
94    * <!-- begin-user-doc -->
95    * Creates an EObject.
96    * <!-- end-user-doc -->
97    * @generated
98    */

99   protected EObjectImpl()
100   {
101     super();
102   }
103
104   /**
105    * <!-- begin-user-doc -->
106    * <!-- end-user-doc -->
107    * @generated
108    */

109   protected EClass eStaticClass()
110   {
111     return EcorePackage.eINSTANCE.getEObject();
112   }
113
114   /*
115    * Javadoc copied from interface.
116    */

117   public EList eAdapters()
118   {
119     if (eAdapters == null)
120     {
121       eAdapters = new EAdapterList(this);
122     }
123     return eAdapters;
124   }
125
126   protected BasicEList eBasicAdapters()
127   {
128     return eAdapters;
129   }
130
131   /*
132    * Javadoc copied from interface.
133    */

134   public boolean eDeliver()
135   {
136     return (eFlags & EDELIVER) != 0;
137   }
138
139   /*
140    * Javadoc copied from interface.
141    */

142   public void eSetDeliver(boolean deliver)
143   {
144     if (deliver)
145     {
146       eFlags |= EDELIVER;
147     }
148     else
149     {
150       eFlags &= ~EDELIVER;
151     }
152   }
153
154   /*
155    * @see org.eclipse.emf.ecore.EObject#eIsProxy()
156    */

157   public boolean eIsProxy()
158   {
159     return (eFlags & EPROXY) != 0;
160   }
161   
162   /*
163    * @see org.eclipse.emf.ecore.InternalEObject#eSetProxyURI(org.eclipse.emf.common.util.URI)
164    */

165   public void eSetProxyURI(URI uri)
166   {
167     super.eSetProxyURI(uri);
168     if (uri != null)
169     {
170       eFlags |= EPROXY;
171     }
172     else
173     {
174       eFlags &= ~EPROXY;
175     }
176   }
177   
178   protected EPropertiesHolder eProperties()
179   {
180     if (eProperties == null)
181     {
182       eProperties = new EPropertiesHolderImpl();
183     }
184     return eProperties;
185   }
186
187   protected EPropertiesHolder eBasicProperties()
188   {
189     return eProperties;
190   }
191
192   protected InternalEObject eInternalContainer()
193   {
194     return eContainer;
195   }
196
197   public int eContainerFeatureID()
198   {
199     return eContainerFeatureID;
200   }
201
202   protected void eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID)
203   {
204     eContainer = newContainer;
205     eContainerFeatureID = newContainerFeatureID;
206   }
207
208   public EClass eClass()
209   {
210     return (eFlags & EDYNAMIC_CLASS) == 0 ? eStaticClass() : eProperties().getEClass();
211   }
212
213   public void eSetClass(EClass eClass)
214   {
215     super.eSetClass(eClass);
216     if (eClass != null)
217     {
218       eFlags |= EDYNAMIC_CLASS;
219     }
220     else
221     {
222       eFlags &= ~EDYNAMIC_CLASS;
223     }
224   }
225 }
226
Popular Tags