How to assign a value for a slot of instance specification [message #1028066] |
Wed, 27 March 2013 19:52 |
Mariem Makni 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 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03406 seconds