Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » eGet of an Attribute results in an IllegalArgumentException
eGet of an Attribute results in an IllegalArgumentException [message #1706069] Fri, 21 August 2015 16:11 Go to next message
Jochen Cl is currently offline Jochen ClFriend
Messages: 1
Registered: August 2015
Junior Member
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 13:42 Go to previous message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1199
Registered: July 2009
Location: Canada
Senior Member

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
Previous Topic:Call for Submissions: Modeling,Symposium @ EclipseCon Europe 2015
Next Topic:Derived Property
Goto Forum:
  


Current Time: Tue Oct 22 05:59:20 GMT 2019

Powered by FUDForum. Page generated in 0.01641 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top