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 #624794] Sun, 16 September 2007 14:26
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!
Previous Topic:Same Model Load method returns different results
Next Topic:stereotype a stereotype
Goto Forum:
  


Current Time: Thu Sep 26 13:50:27 GMT 2024

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

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

Back to the top