Skip to main content



      Home
Home » Modeling » UML2 » how to get stereotyped-property's value
how to get stereotyped-property's value [message #624794] Sun, 16 September 2007 10:26
Eclipse UserFriend
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: Wed Jul 02 20:40:00 EDT 2025

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

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

Back to the top