public interface EObject extends Notifier
EObject
is the root of all modeled objects
so all the method names start with "e" to distinguish
the EMF methods from the client methods.
It provides support for the behaviors and features
common to all modeled objects:
eResource()
eContainer()
eContainingFeature()
eContainmentFeature()
eContents()
eAllContents()
eCrossReferences()
eClass()
eGet(EStructuralFeature)
eGet(EStructuralFeature, boolean)
eSet(EStructuralFeature, Object)
eIsSet(EStructuralFeature)
eUnset(EStructuralFeature)
org.eclipse.emf.common.notify
.
Any EObject
is assumed to also implement InternalEObject
,
which provides lower-level access that is not necessarily suitable for general consumption
but is required for maintaining the EMF support mechanisms.
Implementations of EObject should extend BasicEObjectImpl
or one of its derived classes
because methods can and will be added to this API.
The framework also assumes that implementations will not specialize #equals(Object)
(nor #hashCode()
)
so that "==
" can be always used for equality testing;
EcoreUtil.equals
should be used for doing structural equality testing.
EcorePackage.getEObject()
Modifier and Type | Method and Description |
---|---|
TreeIterator<EObject> |
eAllContents()
Returns a tree iterator that iterates over all the
direct contents and indirect contents of this object. |
EClass |
eClass()
Returns the meta class.
|
EObject |
eContainer()
Returns the containing object, or
null . |
EStructuralFeature |
eContainingFeature()
|
EReference |
eContainmentFeature()
Returns the
containment feature that properly contains the object,
or null , if there is no container. |
EList<EObject> |
eContents()
Returns a list view of the content objects; it is unmodifiable.
|
EList<EObject> |
eCrossReferences()
Returns a list view of the cross referenced objects; it is unmodifiable.
|
java.lang.Object |
eGet(EStructuralFeature feature)
Returns the value of the given feature of this object.
|
java.lang.Object |
eGet(EStructuralFeature feature,
boolean resolve)
Returns the value of the given feature of the object;
the value is optionally
resolved before it is returned. |
java.lang.Object |
eInvoke(EOperation operation,
EList<?> arguments)
Invokes the specified operation of the object.
|
boolean |
eIsProxy()
Indicates whether this object is a proxy.
|
boolean |
eIsSet(EStructuralFeature feature)
Returns whether the feature of the object is considered to be set.
|
Resource |
eResource()
Returns the containing resource, or
null . |
void |
eSet(EStructuralFeature feature,
java.lang.Object newValue)
Sets the value of the given feature of the object to the new value.
|
void |
eUnset(EStructuralFeature feature)
Unsets the feature of the object.
|
eAdapters, eDeliver, eNotify, eSetDeliver
EClass eClass()
The meta class defines the features
available for reflective access.
EClass.getEAllStructuralFeatures()
Resource eResource()
null
.
An object is contained in a resource
if it, or one of it's containers
,
appears in the contents
of that resource.
An object must be contained by a resource in order to be serialized
.
EcoreUtil.remove(EObject)
,
eContainer()
EObject eContainer()
null
.
An object is contained by another object
if it appears in the contents
of that object.
The object will be contained by a containment feature
of the containing object.
eResource()
,
EcoreUtil.remove(EObject)
,
eContainmentFeature()
,
eContainingFeature()
,
EcoreUtil.getRootContainer(EObject)
,
eContents()
EStructuralFeature eContainingFeature()
feature
of the container
that actually holds the object,
or null
, if there is no container.
Because of support for wildcard content,
this feature may be an attribute representing a feature map
;
in this case the object is referenced by the containment
feature
of an entry
in the map,
i.e., the eContainmentFeature
.
eContainer()
,
eContainmentFeature()
,
EClass.getEAllContainments()
,
EReference.isContainment()
,
FeatureMap.Entry.getEStructuralFeature()
EReference eContainmentFeature()
containment
feature that properly contains the object,
or null
, if there is no container.
Because of support for wildcard content,
this feature may not be a direct feature of the container's class
,
but rather a feature
of an entry in a feature map feature
of the container's class.
eContainer()
,
eContainingFeature()
,
EReference.isContainment()
,
EClass.getEAllContainments()
,
FeatureMap.Entry.getEStructuralFeature()
EList<EObject> eContents()
This will be the list of EObject
s determined by the
contents
of the containment features
of this object's meta class
.
Objects can, indirectly
, be removed
and will change to reflect container
changes.
The implicit tree
of contents is also directly available.
eContainer()
,
EClass.getEAllContainments()
,
eGet(EStructuralFeature)
,
EcoreUtil.remove(EObject)
,
eAllContents()
TreeIterator<EObject> eAllContents()
direct contents
and indirect contents of this object.Resource.getAllContents()
,
EcoreUtil.getAllContents(EObject, boolean)
boolean eIsProxy()
A proxy is an object that is defined in a Resource
that has not been loaded.
An object may be a proxy either because proxy resolution was disabled
when the object was accessed (see eGet(EStructuralFeature,boolean)
)
or because proxy resolution
failed.
true
if this object is a proxy or false
, otherwise.Resource.unload()
,
EcoreUtil.resolve(EObject, org.eclipse.emf.ecore.resource.ResourceSet)
EList<EObject> eCrossReferences()
This will be the list of EObject
s determined by the
contents
of the reference features
of this object's meta class
,
excluding containment features
and their opposites
.
The cross reference list's iterator will be of type EContentsEList.FeatureIterator
,
for efficient determination of the feature
of each cross reference in the list, e.g.,
for (EContentsEList.FeatureIterator featureIterator = (EContentsEList.FeatureIterator)eObject.eCrossReferences().iterator(); featureIterator.hasNext(); ) { EObject eObject = (EObject)featureIterator.next(); EReference eReference = (EReference)featureIterator.feature(); ... }
eContents()
,
EClass.getEAllReferences()
,
EClass.getEAllContainments()
,
eGet(EStructuralFeature)
,
EcoreUtil.CrossReferencer
java.lang.Object eGet(EStructuralFeature feature)
It returns the resolved value, i.e., it returns
eObject.eGet
(feature, true)
feature
- the feature of the value to fetch.eGet(EStructuralFeature, boolean)
java.lang.Object eGet(EStructuralFeature feature, boolean resolve)
resolved
before it is returned.
If the feature is many-valued
,
the result will be an EList
and each object in the list will be an instance of
the feature's type
;
the list's contents are not affected by resolve
argument.
Otherwise the result directly will be an instance of the feature's type;
if it is a proxy
,
it is resolved.
feature
- the feature of the value to fetch.resolve
- whether to resolve.java.lang.IllegalArgumentException
- if the feature is not one the meta class
's
features
and is also not affiliated
with one of the meta class's features.
Note that for high-performance generated model implementation classes,
full checking whether the feature is among of the meta class's features
is performed only if assertions are enabled for the JVM.
As such,
the return value for an invalid feature,
in the absence of enabled assertions,
is undefined,
though typically it will be the value of the meta class's feature
with the same ID
as the given feature.
InternalEList.basicIterator()
,
InternalEList.basicList()
,
EcoreUtil.resolve(EObject, org.eclipse.emf.ecore.resource.ResourceSet)
,
eSet(EStructuralFeature, Object)
,
eUnset(EStructuralFeature)
,
eIsSet(EStructuralFeature)
,
eGet(EStructuralFeature)
void eSet(EStructuralFeature feature, java.lang.Object newValue)
If the feature is many-valued
,
the new value must be an EList
and each object in that list must be an instance of
the feature's type
;
the existing contents are cleared and the contents of the new value are added.
However, if the new value is the content list itself, or is modified as a side effect of modifying the content list
(i.e., if it is a view on the content list),
the behavior is undefined and will likely result in simply clearing the list.
If the feature is single-valued, the new value directly must be an instance of the feature's type
and it becomes the new value of the feature of the object.
If the feature is unsettable
,
the modeled state becomes set;
otherwise, the feature may still not considered set
if the new value is the same as the default.
feature
- the feature of the value to set.java.lang.IllegalArgumentException
- if the feature is not one the meta class
's
features
,
or it isn't changeable
.java.lang.ClassCastException
- if there is a type conflict.java.lang.ArrayStoreException
- if there is a type conflict.eUnset(EStructuralFeature)
,
eIsSet(EStructuralFeature)
,
eGet(EStructuralFeature, boolean)
boolean eIsSet(EStructuralFeature feature)
If the feature is many-valued
,
the value must be an EList
and the feature is considered set if the list is not empty.
If the feature is unsettable
,
the modeled state is directly available and is used.
Otherwise,
the unresolved value
of the feature of the object
is compared against the feature's default value
or the meta class
's default value
,
as appropriate;
the feature is considered set if it's not the same as the default.
This property can affect serialization, since defaults are typically omitted in a compact serialization.
feature
- the feature in question.java.lang.IllegalArgumentException
- if the feature is not one the meta class
's
features
.eSet(EStructuralFeature, Object)
,
eUnset(EStructuralFeature)
,
eGet(EStructuralFeature, boolean)
void eUnset(EStructuralFeature feature)
If the feature is many-valued
,
the value must be an EList
and that list is cleared.
Otherwise,
the value of the feature of the object
is set to the feature's default value
or the meta class
's default value
,
as appropriate.
If the feature is unsettable
,
the modeled state becomes unset.
In any case, the feature will no longer be considered set
.
feature
- the feature in question.java.lang.IllegalArgumentException
- if the feature is not one the meta class
's
features
,
or it isn't changeable
.eIsSet(EStructuralFeature)
,
eSet(EStructuralFeature, Object)
,
eGet(EStructuralFeature, boolean)
java.lang.Object eInvoke(EOperation operation, EList<?> arguments) throws java.lang.reflect.InvocationTargetException
Invokes the specified operation of the object. If the operation has parameters, then corresponding arguments must be supplied. There are no optional parameters in Ecore operations.
If the operation is a void operation, then on successful execution, the
result of this invocation is null
. Otherwise, if the
operation is multi-valued
, then an
EList
is returned (possibly empty). If single-valued, then an
instance of the operation's type
is
returned, or possibly null
.
If the invoked operation fails with an
exception
, then it is re-thrown,
wrapped in an InvocationTargetException
.
java.lang.reflect.InvocationTargetException