KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > InternalEObject


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

17 package org.eclipse.emf.ecore;
18
19
20 import org.eclipse.emf.common.notify.NotificationChain;
21 import org.eclipse.emf.common.util.URI;
22 import org.eclipse.emf.ecore.resource.Resource;
23
24
25 /**
26  * An internal interface implemented by all {@link EObject}s.
27  */

28 public interface InternalEObject extends EObject
29 {
30   /**
31    * The base value for negative, i.e., opposite-end, eContainerFeatureID values.
32    */

33   static final int EOPPOSITE_FEATURE_BASE = -1;
34
35   /**
36    * Returns whether {@link org.eclipse.emf.common.notify.Notifier#eNotify eNotify} needs to be called.
37    * <p>
38    * This may return <code>true</code> even when {@link org.eclipse.emf.common.notify.Notifier#eDeliver eDeliver} is <code>false</code>
39    * or when {@link org.eclipse.emf.common.notify.Notifier#eAdapters eAdapters} is empty.
40    * <p>
41    * @return <code>true</code> if eNotify needs to be called.
42    */

43   boolean eNotificationRequired();
44
45   /**
46    * Returns the fragment segment that,
47    * when passed to {@link #eObjectForURIFragmentSegment eObjectForURIFragmentSegment},
48    * will resolve to the given object in this object's given feature.
49    * <p>
50    * The feature argument may be <code>null</code> in which case it will be deduced, if possible.
51    * The default result will be of the form:
52    *<pre>
53    * "@&lt;feature-name>[.&lt;index>]"
54    *</pre>
55    * The index is used only for {@link EStructuralFeature#isMany many-valued} features;
56    * it represents the position within the list.
57    * </p>
58    * @param eFeature the feature relating the given object to this object, or <code>null</code>.
59    * @param eObject the object to be identified.
60    * @return the fragment segment that resolves to the given object in this object's given feature.
61    */

62   String JavaDoc eURIFragmentSegment(EStructuralFeature eFeature, EObject eObject);
63
64   /**
65    * Returns the object resolved by the fragment segment.
66    * <p>
67    * The fragment segment encoding will typically be of the form returned by {@link #eURIFragmentSegment eURIFragmentSegment}.
68    * @param uriFragmentSegment a fragment segment.
69    * @return the fragment segment that resolves to the given object in this object's given feature.
70    */

71   EObject eObjectForURIFragmentSegment(String JavaDoc uriFragmentSegment);
72
73   /**
74    * Sets the meta class.
75    * An object with a set meta class is, by definition, a dynamic instance;
76    * it will support dynamic {@link #eSetting settings}.
77    * an.
78    * @param eClass the dynamic meta class.
79    * @see #eSetting(EStructuralFeature)
80    */

81   void eSetClass(EClass eClass);
82
83   /**
84    * Returns a setting that can be used to access this object's feature.
85    * @param feature the feature of the desired setting.
86    * @return a setting that can be used to access this object's feature.
87    */

88   EStructuralFeature.Setting eSetting(EStructuralFeature feature);
89
90   /**
91    * Returns the feature ID relative to the base class, given a feature ID relative to this derived object's actual class.
92    * @param derivedFeatureID the ID in the actual derived class
93    * @param baseClass the base class for which a relative ID is desired.
94    * @return the up-cast feature ID.
95    */

96   int eBaseStructuralFeatureID(int derivedFeatureID, Class JavaDoc baseClass);
97
98   /**
99    * Returns the container feature ID.
100    * If the container isn't a navigable feature, this will be a negative ID indicating the inverse of the containment feature's ID.
101    * @return the container feature ID.
102    * @see #eContainmentFeature()
103    * @see #EOPPOSITE_FEATURE_BASE
104    */

105   int eContainerFeatureID();
106
107   /**
108    * Returns the feature ID relative to this derived object's actual class, given a feature ID relative to the given base class.
109    * @param baseFeatureID the ID relative to a base class.
110    * @param baseClass the base class to which the ID is relative.
111    * @return the down-cast feature ID.
112    */

113   int eDerivedStructuralFeatureID(int baseFeatureID, Class JavaDoc baseClass);
114
115   /**
116    * Sets this object to be directly contained by the resource
117    * and returns accumulated notifications.
118    * This is only done as the inverse of {@link Resource#getContents()}<code>.add(this)</code>.
119    * @return accumulated notifications.
120    */

121   NotificationChain eSetResource(Resource.Internal resource, NotificationChain notifications);
122
123   /**
124    * Adds the object at the other end of a bidirectional reference to the appropriate feature
125    * and returns accumulated notifications.
126    * @return accumulated notifications.
127    */

128   NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain notifications);
129
130   /**
131    * Removes the object at the other end of a bidirectional reference from the appropriate feature
132    * and returns accumulated notifications.
133    * @return accumulated notifications.
134    */

135   NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain notifications);
136
137   /**
138    * Sets the container to be new container and appropriate feature.
139    * and returns accumulated notifications.
140    * Since the container feature may not be navigable, i.e., may not exist, the containment feature may be encoded instead.
141    * @return accumulated notifications.
142    */

143   NotificationChain eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID, NotificationChain notifications);
144
145   /**
146    * Removes this object from whatever container holds it,
147    * and returns accumulated notifications.
148    * @return accumulated notifications.
149    */

150   NotificationChain eBasicRemoveFromContainer(NotificationChain notifications);
151
152   /**
153    * Returns the proxy URI of this object.
154    * It can be used to {@link org.eclipse.emf.ecore.util.EcoreUtil#resolve resolve} to the actual object.
155    * @return the proxy URI of this object.
156    * @see org.eclipse.emf.ecore.util.EcoreUtil#resolve(EObject, org.eclipse.emf.ecore.resource.ResourceSet)
157    * @see Resource#unload
158    */

159   URI eProxyURI();
160
161   /**
162    * Set the proxy URI of this object.
163    * It will be used to {@link org.eclipse.emf.ecore.util.EcoreUtil#resolve(EObject, EObject) resolve} to the actual object.
164    * @param uri the URI.
165    * @see org.eclipse.emf.ecore.util.EcoreUtil#resolve(EObject, org.eclipse.emf.ecore.resource.ResourceSet)
166    * @see Resource#unload
167    */

168   void eSetProxyURI(URI uri);
169
170   /**
171    * Resolves the {@link EObject#eIsProxy proxy} object relative to this object.
172    * @see org.eclipse.emf.ecore.util.EcoreUtil#resolve(EObject,EObject)
173    * @return the resolved object, or the original if the proxy can't be resolved.
174    */

175   EObject eResolveProxy(InternalEObject proxy);
176
177   /**
178    * Returns the containing internal resource, or <code>null</code>.
179    * @return the containing internal resource.
180    * @see EObject#eResource
181    */

182   Resource.Internal eInternalResource();
183
184
185   /**
186    * Returns the store associated with this object.
187    * @return the store associated with this object.
188    */

189   EStore eStore();
190
191   /**
192    * Set the store associated with this object.
193    * Most objects will <b>not</b> support this.
194    * @param store the store to associate with this object.
195    * @throws UnsupportedOperationException
196    */

197   void eSetStore(EStore store);
198
199   /**
200    * An external backing store to which an {@link EObject object} may delegate all access.
201    */

202   public interface EStore
203   {
204     /**
205      * A value indicating that no index is specified.
206      * It is used in the case of accessing {@link EStructuralFeature#isMany single-valued} features
207      * where an index would be meaningless.
208      */

209     int NO_INDEX = -1;
210
211     /**
212      * Returns the value at the index in the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature.
213      * @param object the object in question.
214      * @param feature a feature of the object.
215      * @param index an index within the content or {@link #NO_INDEX}.
216      * @return the value at the index in the content of the object's feature.
217      */

218     Object JavaDoc get(InternalEObject object, EStructuralFeature feature, int index);
219
220     /**
221      * Sets the value at the index in the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature.
222      * @param object the object in question.
223      * @param feature a feature of the object.
224      * @param index an index within the content or {@link #NO_INDEX}.
225      * @param value the new value.
226      * @return the previous value.
227      */

228     Object JavaDoc set(InternalEObject object, EStructuralFeature feature, int index, Object JavaDoc value);
229
230     /**
231      * Returns whether the object's feature is considered set.
232      * @param object the object in question.
233      * @param feature a feature of the object.
234      * @return <code>true</code> if the object's feature is considered set.
235      */

236     boolean isSet(InternalEObject object, EStructuralFeature feature);
237
238     /**
239      * Unsets the feature of the object.
240      * @param object the object in question.
241      * @param feature a feature of the object.
242      */

243     void unset(InternalEObject object, EStructuralFeature feature);
244
245     /**
246      * Returns whether the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature is empty.
247      * @param object the object in question.
248      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
249      * @return <code>true</code> if the content of the object's feature is empty.
250      */

251     boolean isEmpty(InternalEObject object, EStructuralFeature feature);
252
253     /**
254      * Returns the number of values in the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature.
255      * @param object the object in question.
256      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
257      * @return the number of values in the content of the object's feature.
258      */

259     int size(InternalEObject object, EStructuralFeature feature);
260
261     /**
262      * Returns whether the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature contains the given value.
263      * @param object the object in question.
264      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
265      * @param value the value in question.
266      * @return <code>true</code> if the content of the object's feature contains the given value.
267      */

268     boolean contains(InternalEObject object, EStructuralFeature feature, Object JavaDoc value);
269     
270     /**
271      * Returns the first index of the given value in the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature.
272      * @param object the object in question.
273      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
274      * @param value the value in question.
275      * @return the first index of the given value in the content of the object's feature.
276      */

277     int indexOf(InternalEObject object, EStructuralFeature feature, Object JavaDoc value);
278
279     /**
280      * Returns the last index of the given value in the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature.
281      * @param object the object in question.
282      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
283      * @param value the value in question.
284      * @return the last index of the given value in the content of the object's feature.
285      */

286     int lastIndexOf(InternalEObject object, EStructuralFeature feature, Object JavaDoc value);
287
288     /**
289      * Adds the value at the index in the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature.
290      * @param object the object in question.
291      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
292      * @param index an index within the content.
293      * @param value the value to add.
294      */

295     void add(InternalEObject object, EStructuralFeature feature, int index, Object JavaDoc value);
296
297     /**
298      * Removes the value at the index in the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature.
299      * @param object the object in question.
300      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
301      * @param index the index within the feature's content of the value to remove.
302      * @return the removed value.
303      */

304     Object JavaDoc remove(InternalEObject object, EStructuralFeature feature, int index);
305
306     /**
307      * Moves the value at the source index in the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature
308      * to the target index.
309      * @param object the object in question.
310      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
311      * @param targetIndex the index within the feature's content to which to move the value.
312      * @param sourceIndex the index within the feature's content of the value to move.
313      * @return the moved value.
314      */

315     Object JavaDoc move(InternalEObject object, EStructuralFeature feature, int targetIndex, int sourceIndex);
316
317     /**
318      * Removes all values form the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature
319      * @param object the object in question.
320      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
321      */

322     void clear(InternalEObject object, EStructuralFeature feature);
323       
324     /**
325      * Returns a new array of the values in the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature.
326      * @param object the object in question.
327      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
328      * @return a new array of the values in the content of the object's feature.
329      */

330     Object JavaDoc[] toArray(InternalEObject object, EStructuralFeature feature);
331
332     /**
333      * Returns an array of the values in the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature.
334      * The given array will be used, unless it's too small, in which case a new array of the same type is allocated instead.
335      * @param object the object in question.
336      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
337      * @param array the array to fill.
338      * @return an array of the values in the content of the object's feature.
339      */

340     Object JavaDoc[] toArray(InternalEObject object, EStructuralFeature feature, Object JavaDoc[] array);
341
342     /**
343      * Returns the hash code of the {@link EObject#eGet(EStructuralFeature,boolean) content} of the object's feature.
344      * @param object the object in question.
345      * @param feature a {@link EStructuralFeature#isMany many-valued} feature of the object.
346      * @return the hash code of the content of the object's feature.
347      */

348     int hashCode(InternalEObject object, EStructuralFeature feature);
349    
350     /**
351      * Returns the object's {@link EObject#eContainer container}.
352      * @return the object's container.
353      * @see EObject#eContainer
354      */

355     InternalEObject getContainer(InternalEObject object);
356
357     /**
358      * Returns the object's {@link EObject#eContainingFeature containing feature}.
359      * @return the object's containing feature.
360      * @see EObject#eContainingFeature
361      */

362     EStructuralFeature getContainingFeature(InternalEObject object);
363
364     /**
365      * Creates a new instance of the class.
366      * @param eClass the class to instantiate.
367      * @return a new instance of the class.
368      */

369     EObject create(EClass eClass);
370   }
371 }
372
Popular Tags