Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » how to get stereotyped-property's value
how to get stereotyped-property's value [message #475902] Sun, 16 September 2007 14:26 Go to next message
Jerry is currently offline JerryFriend
Messages: 32
Registered: July 2009
Member
Dear,
How could I get the value of an property which has a stereotype?
e.g., In my model (e.g., model1), I have two stereotypes: stereotype1 and
stereotype2. They are applied on classA and classB respectively (i.e.,
<<stereotype1>>classA and <<stereotype2>>classB). ClassA has a property
named propertyA1 and one property named propertyA2. The type of propertyA1
is stereotype2, and the value of propertyA1 is classB. Type of propertyA2
is String and value of propertyA2 is "stringvalue".
EList allElement = model1.allOwnedElements();
for (Object obj : allElement){
if(obj instanceof NamedElement){ //*to find classA by element
name*
NamedElement nobj = (NamedElement) obj;
...// now nobj.getQualifiedName equals classA

EList list1 = nobj.getAppliedStereotypes();
Stereotype stero = (Stereotype)list1.get(0);
//**only stereotype1 is applied**

EList steroAtt = stero.getAllAttributes();

...//**suppose we got propertyA1 and propertyA2 now**

Object propertyValue1 = nobj.getValue(stero, propertyA1);
Object propertyValue2 = nobj.getValue(stero, propertyA2);

//**now the propertyValue2.toString returns "stringvalue" which is same as
expected, but the propertyValue1 returns
[org.eclipse.emf.ecore.impl.DynamicEObjectImpl@c21e52 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@125e5eb (name: stereotype2)
(instanceClassName: null) (abstract: false, interface: false))]****

Type proptype = propertyA2.getType();
//** it returns org.eclipse.uml2.uml.internal.impl.StereotypeImpl@ff89d7
(name: stereotype2, visibility: <unset>) (isLeaf: false, visibility:
public, isAbstract: false) (isActive: false, isAbstract: false)***
}
}
so my question is how could I get the value of propertyA2 i.e., "classB"?
Thank you very much!
Re: how to get stereotyped-property's value [message #475903 is a reply to message #475902] Sun, 16 September 2007 14:37 Go to previous messageGo to next message
Jerry is currently offline JerryFriend
Messages: 32
Registered: July 2009
Member
more precisly, I would like to get the name "classB", so that I could
search the model and find it.

thank you!
Re: how to get stereotyped-property's value [message #475924 is a reply to message #475903] Tue, 18 September 2007 17:40 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
.... see posting from 9/18/2007 ...

"Jerry" <jianlin@md.kth.se> wrote in message
news:6bcb245df81a4baee70f9c11db87c394$1@www.eclipse.org...
> more precisly, I would like to get the name "classB", so that I could
> search the model and find it.
>
> thank you!
>
Re: how to get stereotyped-property's value [message #624795 is a reply to message #475902] Sun, 16 September 2007 14:37 Go to previous message
Jerry is currently offline JerryFriend
Messages: 32
Registered: July 2009
Member
more precisly, I would like to get the name "classB", so that I could
search the model and find it.

thank you!
Re: how to get stereotyped-property's value [message #624817 is a reply to message #475903] Tue, 18 September 2007 17:40 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
.... see posting from 9/18/2007 ...

"Jerry" <jianlin@md.kth.se> wrote in message
news:6bcb245df81a4baee70f9c11db87c394$1@www.eclipse.org...
> more precisly, I would like to get the name "classB", so that I could
> search the model and find it.
>
> thank you!
>
Previous Topic:Help, please look at this issue
Next Topic:Handle stereotypes as inheritance?
Goto Forum:
  


Current Time: Fri Apr 26 08:35:56 GMT 2024

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

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

Back to the top