Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » How to assign a value for a slot of instance specification(How to assign a value for a slot of instance specification?)
How to assign a value for a slot of instance specification [message #1028066] Wed, 27 March 2013 19:52 Go to next message
Mariem Makni is currently offline Mariem MakniFriend
Messages: 46
Registered: February 2013
Member
Hi,


I have created an instance specification, then I created a slot for the property "value", and then to assign a value I'm using the getValues().add(ValueSpecification e) method, but my requirement is how to modify the value of my valueSpecification.

I used this code in java:
InstanceSpecification is = UMLFactory.eINSTANCE.createInstanceSpecification();
is.setName("Instance");
is.getClassifiers().add(myClass);
Slot sn = is.createSlot();
Property value = myClass.getAttribute("value", Integer);
sn.setDefiningFeature(value);
//sn.getValues.add(e)


The valueSpecification which I want to modify its value is:
org.eclipse.uml2.uml.internal.impl.LiteralIntegerImpl@6f564a (name: <unset>, visibility: <unset>) (value: 5)


I want to assign for example the value 20 insteadof the value 5.

Can you help me please.

Thanks in advance

[Updated on: Wed, 27 March 2013 20:09]

Report message to a moderator

Re: How to assign a value for instance specification [message #1028092 is a reply to message #1028066] Wed, 27 March 2013 20:31 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Sabrina,

The Slot owns its values, so you probably shouldn't change the value of
a LiteralInteger that exists elsewhere in the model because it can't be
shared with another element (only one element can own the value). You
probably should create a new LiteralInteger.

So, for example:

LiteralInteger literal = (LiteralInteger) sn.createValue(null, null,
UMLPackage.Literals.LITERAL_INTEGER);
literal.setValue(5);

HTH,

Christian


On 2013-03-27 19:53:00 +0000, sabrina ing said:

> Hi,
>
>
> I have created an instance specification, then I created a slot for the
> property "value", and then to assign a value I'm using the
> getValues().add(ValueSpecification e) method, but my requirement is how
> to modify the value of my valueSpecification.
> I used this code in java:
> InstanceSpecification is = UMLFactory.eINSTANCE.createInstanceSpecification();
> is.setName("Instance");
> is.getClassifiers().add(myClass);
> Slot sn = is.createSlot();
> Property value = myClass.getAttribute("value", Integer);
> sn.setDefiningFeature(value);
> //sn.getValues.add(e)
>
> The valueSpecification which I want to modify its value is:
> org.eclipse.uml2.uml.internal.impl.LiteralIntegerImpl@6f564a (name:
> <unset>, visibility: <unset>) (value: 5)
>
> I want to assign for example the value 20 insteadof the value 5.
>
> Can you help me please.
>
> Thanks in advance
Re: How to assign a value for instance specification [message #1028104 is a reply to message #1028092] Wed, 27 March 2013 20:59 Go to previous message
Mariem Makni is currently offline Mariem MakniFriend
Messages: 46
Registered: February 2013
Member
Hi,

Thank you Christian, it is working now.
I'm very grateful for your help Smile
Previous Topic:Position of a Class in a Composite Structure Diagram
Next Topic:The UML metemodel of Papyrus
Goto Forum:
  


Current Time: Fri Apr 26 10:07:23 GMT 2024

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

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

Back to the top