eGet of an Attribute results in an IllegalArgumentException [message #1706069] |
Fri, 21 August 2015 12:11  |
Eclipse User |
|
|
|
Hey guys!
I'm writing my bachelors thesis on a runtime Model extension for emf, but i have a "basic" problem. Somehow i can't set the values of EAttributes. See the following function.
public EAttribute createEAttribute(EClass clazz) {
EAttribute attribute = emfFactory.createEAttribute();
attribute.setName("new Attribute");
attribute.setChangeable(true);
attribute.setEType(EcoreFactory.eINSTANCE.getEcorePackage().getEInt());
clazz.getEStructuralFeatures().add(attribute);
clazz.eSet(attribute, 42);
return attribute;
}
The pararmeter clazz has already been added to a package and this hat been registerd by:
private void registerEPackage(EPackage ep) {
EPackage.Registry.INSTANCE.put(ep.getNsURI(), ep);
}
The exception i get is the following:
Quote: java.lang.IllegalArgumentException: The feature 'new Attribute' is not a valid changeable feature
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenSet(BasicEObjectImpl.java:1155)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1085)
at org.unicase.model.dynamicextension.dynamicModel.DynamicObjectManager.createEAttribute(DynamicObjectManager.java:85)
Can anyone help me?
Kind regards
|
|
|
Re: eGet of an Attribute results in an IllegalArgumentException [message #1706185 is a reply to message #1706069] |
Mon, 24 August 2015 09:42  |
Eclipse User |
|
|
|
Hi,
You are trying to set a value for this attribute in your EClass, but
EClass doesn't define that attribute. You need to try to set it in an
*instance* of your EClass.
It's like defining a Person class with a name attribute in Java and
then trying to do Person.class.setName("Christian").
Cheers,
Christian
On 2015-08-24 13:38:39 +0000, Jochen Cl said:
> Hey guys!
>
> I'm writing my bachelors thesis on a runtime Model extension for emf,
> but i have a "basic" problem. Somehow i can't set the values of
> EAttributes. See the following function.
>
> public EAttribute createEAttribute(EClass clazz) {
> EAttribute attribute = emfFactory.createEAttribute();
> attribute.setName("new Attribute");
> attribute.setChangeable(true);
> attribute.setEType(EcoreFactory.eINSTANCE.getEcorePackage().getEInt());
> clazz.getEStructuralFeatures().add(attribute);
> clazz.eSet(attribute, 42);
> return attribute;
> }
>
>
> The pararmeter clazz has already been added to a package and this hat
> been registerd by:
>
> private void registerEPackage(EPackage ep) {
> EPackage.Registry.INSTANCE.put(ep.getNsURI(), ep);
> }
>
>
> The exception i get is the following:
> Quote:
>> java.lang.IllegalArgumentException: The feature 'new Attribute' is not
>> a valid changeable feature
>> at
>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenSet(BasicEObjectImpl.java:1155)
>>
>> at
>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1085)
>>
>> at
>> org.unicase.model.dynamicextension.dynamicModel.DynamicObjectManager.createEAttribute(DynamicObjectManager.java:85)
>>
>
>
> Can anyone help me?
> Kind regards
|
|
|
Powered by
FUDForum. Page generated in 0.03628 seconds