Home » Modeling » UML2 » Help, please look at this issue
Help, please look at this issue [message #475921] |
Tue, 18 September 2007 16:52 |
Jerry Messages: 32 Registered: July 2009 |
Member |
|
|
This question might be too easy or even stupid, but I could not find the
solution. Please give me some hints. Thanks a lot!
To get Stereotype Property values, I know I can use
namedElement1.getValue(stereotype1, property1.getName()); if the type of
property1 is primitive types, e.g., String, Boolean..or Enumeration, there
is no problem. BUT when it is another Stereotype (let's say stereotype2)
and the value of property1 is <<stereotype2>><Class>NamedElement2, the
above method returns only the stereotype2! e.g., it looks like this:
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
(instanceClassName: null) (abstract: false, interface: false)).
So how could I get the NamedElement2?
Thank you very much for help!
|
|
|
Re: Help, please look at this issue [message #475922 is a reply to message #475921] |
Tue, 18 September 2007 17:37 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Jerry,
Sorry about the delayed response...
You might want to use UML2Util.getBaseElement() to get the element that the
stereotype is applied to ( I believe that's what you are looking for )
I hope that helps.
- James.
"Jerry" <jianlin@md.kth.se> wrote in message
news:fda13189341cc86449b1579f93ba73a8$1@www.eclipse.org...
> This question might be too easy or even stupid, but I could not find the
> solution. Please give me some hints. Thanks a lot!
>
> To get Stereotype Property values, I know I can use
> namedElement1.getValue(stereotype1, property1.getName()); if the type of
> property1 is primitive types, e.g., String, Boolean..or Enumeration, there
> is no problem. BUT when it is another Stereotype (let's say stereotype2)
> and the value of property1 is <<stereotype2>><Class>NamedElement2, the
> above method returns only the stereotype2! e.g., it looks like this:
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
> (instanceClassName: null) (abstract: false, interface: false)).
> So how could I get the NamedElement2?
>
> Thank you very much for help!
>
|
|
|
Re: Help, please look at this issue [message #475923 is a reply to message #475922] |
Tue, 18 September 2007 17:39 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
.... that's UMLUtil::getBaseElement() ...
...there are other helpful functions like UMLUtil.getStereotype() that will
return a UML stereotype if you pass in the stereotype application
(DynamicEObject).
Cheers,
- James.
"James Bruck" <jbruck@ca.ibm.com> wrote in message
news:fcp2cn$7fa$2@build.eclipse.org...
> Hi Jerry,
>
> Sorry about the delayed response...
> You might want to use UML2Util.getBaseElement() to get the element that
the
> stereotype is applied to ( I believe that's what you are looking for )
>
> I hope that helps.
>
> - James.
>
> "Jerry" <jianlin@md.kth.se> wrote in message
> news:fda13189341cc86449b1579f93ba73a8$1@www.eclipse.org...
> > This question might be too easy or even stupid, but I could not find the
> > solution. Please give me some hints. Thanks a lot!
> >
> > To get Stereotype Property values, I know I can use
> > namedElement1.getValue(stereotype1, property1.getName()); if the type of
> > property1 is primitive types, e.g., String, Boolean..or Enumeration,
there
> > is no problem. BUT when it is another Stereotype (let's say stereotype2)
> > and the value of property1 is <<stereotype2>><Class>NamedElement2, the
> > above method returns only the stereotype2! e.g., it looks like this:
> > org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d (eClass:
> > org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
> > (instanceClassName: null) (abstract: false, interface: false)).
> > So how could I get the NamedElement2?
> >
> > Thank you very much for help!
> >
>
>
|
|
| |
Re: Help, please look at this issue [message #476012 is a reply to message #475923] |
Thu, 20 September 2007 12:21 |
Jerry Messages: 32 Registered: July 2009 |
Member |
|
|
Thank you, and I got further questions :(
Object obj1 = namedElement1.getValue(stereotype1, property1.getName());
sometime it returns an EcoreEList$Dynamic<E>
[org.eclipse.emf.ecore.impl.DynamicEObjectImpl@caf6e7 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@6014f7 (name: ErrorModel)
(instanceClassName: null) (abstract: false, interface: false))]
if check the obj1.getClass().getCanonicalName() -->
returns{org.eclipse.emf.ecore.util.EcoreEList.Dynamic}
now the baseElement = UMLUtil.getBaseElement((EObject) obj1); get
Exception in thread "main" java.lang.ClassCastException:
org.eclipse.emf.ecore.util.EcoreEList$Dynamic
sometimes it works and gives following expected results:
DynamicEObjectImpl [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d
(eClass:org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
(instanceClassName: null) (abstract: false, interface: false))].
and
org.eclipse.uml2.uml.internal.impl.ClassImpl@10e7c9e (name: Element2,
visibility: <unset>) (isLeaf: false, visibility: public, isAbstract:
false) (isActive: false, isAbstract: false)
Could you please explain what's the reason? Thank you!
|
|
|
Re: Help, please look at this issue [message #476013 is a reply to message #476012] |
Thu, 20 September 2007 12:36 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Jerry,
Comments below.
Jerry wrote:
> Thank you, and I got further questions :(
>
> Object obj1 = namedElement1.getValue(stereotype1, property1.getName());
> sometime it returns an EcoreEList$Dynamic<E>
> [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@caf6e7 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@6014f7 (name: ErrorModel)
> (instanceClassName: null) (abstract: false, interface: false))]
I would expect this for a property that is multi-valued.
>
> if check the obj1.getClass().getCanonicalName() -->
> returns{org.eclipse.emf.ecore.util.EcoreEList.Dynamic}
> now the baseElement = UMLUtil.getBaseElement((EObject) obj1); get
> Exception in thread "main" java.lang.ClassCastException:
> org.eclipse.emf.ecore.util.EcoreEList$Dynamic
A list can't be an EObject. I think you need to cast to List and
iterate over the contents.
>
> sometimes it works and gives following expected results:
> DynamicEObjectImpl
> [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d
> (eClass:org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
> (instanceClassName: null) (abstract: false, interface: false))]. and
> org.eclipse.uml2.uml.internal.impl.ClassImpl@10e7c9e (name: Element2,
> visibility: <unset>) (isLeaf: false, visibility: public, isAbstract:
> false) (isActive: false, isAbstract: false)
In this case I assume you've access a property that is single valued is
that yields some type of EObject.
>
> Could you please explain what's the reason? Thank you!
I would assume the difference depends on the multiplicity of the property.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Help, please look at this issue [message #476015 is a reply to message #476012] |
Thu, 20 September 2007 13:13 |
Kenn Hussey Messages: 1620 Registered: July 2009 |
Senior Member |
|
|
Jerry,
The result would depend on the multiplicity of your stereotype property -
the value of a multivalued reference property will be a list (of dynamic
objects) whereas a the value of a scalar reference property (i.e. with an
upper bound of 1) will be a dynamic object. It only makes sense to pass the
value of a stereotype property to the UMLUtil#getBaseElement(EObject) method
if the value represents the application of another stereotype (i.e. if the
type of the property is another stereotype)...
Kenn
"Jerry" <jianlin@md.kth.se> wrote in message
news:04914e650e6d102bbe1bbe1499958a41$1@www.eclipse.org...
> Thank you, and I got further questions :(
>
> Object obj1 = namedElement1.getValue(stereotype1, property1.getName());
> sometime it returns an EcoreEList$Dynamic<E>
> [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@caf6e7 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@6014f7 (name: ErrorModel)
> (instanceClassName: null) (abstract: false, interface: false))]
>
> if check the obj1.getClass().getCanonicalName() -->
> returns{org.eclipse.emf.ecore.util.EcoreEList.Dynamic}
> now the baseElement = UMLUtil.getBaseElement((EObject) obj1); get
> Exception in thread "main" java.lang.ClassCastException:
> org.eclipse.emf.ecore.util.EcoreEList$Dynamic
>
> sometimes it works and gives following expected results:
> DynamicEObjectImpl [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d
> (eClass:org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
> (instanceClassName: null) (abstract: false, interface: false))]. and
> org.eclipse.uml2.uml.internal.impl.ClassImpl@10e7c9e (name: Element2,
> visibility: <unset>) (isLeaf: false, visibility: public, isAbstract:
> false) (isActive: false, isAbstract: false)
>
> Could you please explain what's the reason? Thank you!
>
|
|
|
Re: Help, please look at this issue [message #476862 is a reply to message #475923] |
Fri, 18 January 2008 14:34 |
Eclipse User |
|
|
|
Originally posted by: heiyuchuanxia.163.com
Thanks a lot, I think it solved my problem.
Stefanie
James Bruck 写道:
> ... that's UMLUtil::getBaseElement() ...
> ..there are other helpful functions like UMLUtil.getStereotype() that will
> return a UML stereotype if you pass in the stereotype application
> (DynamicEObject).
>
> Cheers,
>
> - James.
>
> "James Bruck" <jbruck@ca.ibm.com> wrote in message
> news:fcp2cn$7fa$2@build.eclipse.org...
>> Hi Jerry,
>>
>> Sorry about the delayed response...
>> You might want to use UML2Util.getBaseElement() to get the element that
> the
>> stereotype is applied to ( I believe that's what you are looking for )
>>
>> I hope that helps.
>>
>> - James.
>>
>> "Jerry" <jianlin@md.kth.se> wrote in message
>> news:fda13189341cc86449b1579f93ba73a8$1@www.eclipse.org...
>>> This question might be too easy or even stupid, but I could not find the
>>> solution. Please give me some hints. Thanks a lot!
>>>
>>> To get Stereotype Property values, I know I can use
>>> namedElement1.getValue(stereotype1, property1.getName()); if the type of
>>> property1 is primitive types, e.g., String, Boolean..or Enumeration,
> there
>>> is no problem. BUT when it is another Stereotype (let's say stereotype2)
>>> and the value of property1 is <<stereotype2>><Class>NamedElement2, the
>>> above method returns only the stereotype2! e.g., it looks like this:
>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d (eClass:
>>> org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
>>> (instanceClassName: null) (abstract: false, interface: false)).
>>> So how could I get the NamedElement2?
>>>
>>> Thank you very much for help!
>>>
>>
>
>
|
|
|
Re: Help, please look at this issue [message #624815 is a reply to message #475921] |
Tue, 18 September 2007 17:37 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Jerry,
Sorry about the delayed response...
You might want to use UML2Util.getBaseElement() to get the element that the
stereotype is applied to ( I believe that's what you are looking for )
I hope that helps.
- James.
"Jerry" <jianlin@md.kth.se> wrote in message
news:fda13189341cc86449b1579f93ba73a8$1@www.eclipse.org...
> This question might be too easy or even stupid, but I could not find the
> solution. Please give me some hints. Thanks a lot!
>
> To get Stereotype Property values, I know I can use
> namedElement1.getValue(stereotype1, property1.getName()); if the type of
> property1 is primitive types, e.g., String, Boolean..or Enumeration, there
> is no problem. BUT when it is another Stereotype (let's say stereotype2)
> and the value of property1 is <<stereotype2>><Class>NamedElement2, the
> above method returns only the stereotype2! e.g., it looks like this:
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
> (instanceClassName: null) (abstract: false, interface: false)).
> So how could I get the NamedElement2?
>
> Thank you very much for help!
>
|
|
|
Re: Help, please look at this issue [message #624816 is a reply to message #475922] |
Tue, 18 September 2007 17:39 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
.... that's UMLUtil::getBaseElement() ...
...there are other helpful functions like UMLUtil.getStereotype() that will
return a UML stereotype if you pass in the stereotype application
(DynamicEObject).
Cheers,
- James.
"James Bruck" <jbruck@ca.ibm.com> wrote in message
news:fcp2cn$7fa$2@build.eclipse.org...
> Hi Jerry,
>
> Sorry about the delayed response...
> You might want to use UML2Util.getBaseElement() to get the element that
the
> stereotype is applied to ( I believe that's what you are looking for )
>
> I hope that helps.
>
> - James.
>
> "Jerry" <jianlin@md.kth.se> wrote in message
> news:fda13189341cc86449b1579f93ba73a8$1@www.eclipse.org...
> > This question might be too easy or even stupid, but I could not find the
> > solution. Please give me some hints. Thanks a lot!
> >
> > To get Stereotype Property values, I know I can use
> > namedElement1.getValue(stereotype1, property1.getName()); if the type of
> > property1 is primitive types, e.g., String, Boolean..or Enumeration,
there
> > is no problem. BUT when it is another Stereotype (let's say stereotype2)
> > and the value of property1 is <<stereotype2>><Class>NamedElement2, the
> > above method returns only the stereotype2! e.g., it looks like this:
> > org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d (eClass:
> > org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
> > (instanceClassName: null) (abstract: false, interface: false)).
> > So how could I get the NamedElement2?
> >
> > Thank you very much for help!
> >
>
>
|
|
| |
Re: Help, please look at this issue [message #624912 is a reply to message #475923] |
Thu, 20 September 2007 12:21 |
Jerry Messages: 32 Registered: July 2009 |
Member |
|
|
Thank you, and I got further questions :(
Object obj1 = namedElement1.getValue(stereotype1, property1.getName());
sometime it returns an EcoreEList$Dynamic<E>
[org.eclipse.emf.ecore.impl.DynamicEObjectImpl@caf6e7 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@6014f7 (name: ErrorModel)
(instanceClassName: null) (abstract: false, interface: false))]
if check the obj1.getClass().getCanonicalName() -->
returns{org.eclipse.emf.ecore.util.EcoreEList.Dynamic}
now the baseElement = UMLUtil.getBaseElement((EObject) obj1); get
Exception in thread "main" java.lang.ClassCastException:
org.eclipse.emf.ecore.util.EcoreEList$Dynamic
sometimes it works and gives following expected results:
DynamicEObjectImpl [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d
(eClass:org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
(instanceClassName: null) (abstract: false, interface: false))].
and
org.eclipse.uml2.uml.internal.impl.ClassImpl@10e7c9e (name: Element2,
visibility: <unset>) (isLeaf: false, visibility: public, isAbstract:
false) (isActive: false, isAbstract: false)
Could you please explain what's the reason? Thank you!
|
|
|
Re: Help, please look at this issue [message #624914 is a reply to message #476012] |
Thu, 20 September 2007 12:36 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Jerry,
Comments below.
Jerry wrote:
> Thank you, and I got further questions :(
>
> Object obj1 = namedElement1.getValue(stereotype1, property1.getName());
> sometime it returns an EcoreEList$Dynamic<E>
> [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@caf6e7 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@6014f7 (name: ErrorModel)
> (instanceClassName: null) (abstract: false, interface: false))]
I would expect this for a property that is multi-valued.
>
> if check the obj1.getClass().getCanonicalName() -->
> returns{org.eclipse.emf.ecore.util.EcoreEList.Dynamic}
> now the baseElement = UMLUtil.getBaseElement((EObject) obj1); get
> Exception in thread "main" java.lang.ClassCastException:
> org.eclipse.emf.ecore.util.EcoreEList$Dynamic
A list can't be an EObject. I think you need to cast to List and
iterate over the contents.
>
> sometimes it works and gives following expected results:
> DynamicEObjectImpl
> [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d
> (eClass:org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
> (instanceClassName: null) (abstract: false, interface: false))]. and
> org.eclipse.uml2.uml.internal.impl.ClassImpl@10e7c9e (name: Element2,
> visibility: <unset>) (isLeaf: false, visibility: public, isAbstract:
> false) (isActive: false, isAbstract: false)
In this case I assume you've access a property that is single valued is
that yields some type of EObject.
>
> Could you please explain what's the reason? Thank you!
I would assume the difference depends on the multiplicity of the property.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Help, please look at this issue [message #624921 is a reply to message #476012] |
Thu, 20 September 2007 13:13 |
Kenn Hussey Messages: 1620 Registered: July 2009 |
Senior Member |
|
|
Jerry,
The result would depend on the multiplicity of your stereotype property -
the value of a multivalued reference property will be a list (of dynamic
objects) whereas a the value of a scalar reference property (i.e. with an
upper bound of 1) will be a dynamic object. It only makes sense to pass the
value of a stereotype property to the UMLUtil#getBaseElement(EObject) method
if the value represents the application of another stereotype (i.e. if the
type of the property is another stereotype)...
Kenn
"Jerry" <jianlin@md.kth.se> wrote in message
news:04914e650e6d102bbe1bbe1499958a41$1@www.eclipse.org...
> Thank you, and I got further questions :(
>
> Object obj1 = namedElement1.getValue(stereotype1, property1.getName());
> sometime it returns an EcoreEList$Dynamic<E>
> [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@caf6e7 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@6014f7 (name: ErrorModel)
> (instanceClassName: null) (abstract: false, interface: false))]
>
> if check the obj1.getClass().getCanonicalName() -->
> returns{org.eclipse.emf.ecore.util.EcoreEList.Dynamic}
> now the baseElement = UMLUtil.getBaseElement((EObject) obj1); get
> Exception in thread "main" java.lang.ClassCastException:
> org.eclipse.emf.ecore.util.EcoreEList$Dynamic
>
> sometimes it works and gives following expected results:
> DynamicEObjectImpl [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d
> (eClass:org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
> (instanceClassName: null) (abstract: false, interface: false))]. and
> org.eclipse.uml2.uml.internal.impl.ClassImpl@10e7c9e (name: Element2,
> visibility: <unset>) (isLeaf: false, visibility: public, isAbstract:
> false) (isActive: false, isAbstract: false)
>
> Could you please explain what's the reason? Thank you!
>
|
|
|
Re: Help, please look at this issue [message #625910 is a reply to message #475923] |
Fri, 18 January 2008 14:34 |
Eclipse User |
|
|
|
Originally posted by: heiyuchuanxia.163.com
Thanks a lot, I think it solved my problem.
Stefanie
James Bruck 写道:
> ... that's UMLUtil::getBaseElement() ...
> ..there are other helpful functions like UMLUtil.getStereotype() that will
> return a UML stereotype if you pass in the stereotype application
> (DynamicEObject).
>
> Cheers,
>
> - James.
>
> "James Bruck" <jbruck@ca.ibm.com> wrote in message
> news:fcp2cn$7fa$2@build.eclipse.org...
>> Hi Jerry,
>>
>> Sorry about the delayed response...
>> You might want to use UML2Util.getBaseElement() to get the element that
> the
>> stereotype is applied to ( I believe that's what you are looking for )
>>
>> I hope that helps.
>>
>> - James.
>>
>> "Jerry" <jianlin@md.kth.se> wrote in message
>> news:fda13189341cc86449b1579f93ba73a8$1@www.eclipse.org...
>>> This question might be too easy or even stupid, but I could not find the
>>> solution. Please give me some hints. Thanks a lot!
>>>
>>> To get Stereotype Property values, I know I can use
>>> namedElement1.getValue(stereotype1, property1.getName()); if the type of
>>> property1 is primitive types, e.g., String, Boolean..or Enumeration,
> there
>>> is no problem. BUT when it is another Stereotype (let's say stereotype2)
>>> and the value of property1 is <<stereotype2>><Class>NamedElement2, the
>>> above method returns only the stereotype2! e.g., it looks like this:
>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@30d83d (eClass:
>>> org.eclipse.emf.ecore.impl.EClassImpl@1406eb6 (name: stereotype2)
>>> (instanceClassName: null) (abstract: false, interface: false)).
>>> So how could I get the NamedElement2?
>>>
>>> Thank you very much for help!
>>>
>>
>
>
|
|
|
Goto Forum:
Current Time: Wed Sep 25 16:53:47 GMT 2024
Powered by FUDForum. Page generated in 0.05305 seconds
|