Creating EClass by EClass [message #1705576] |
Mon, 17 August 2015 15:11 |
|
Colleagues
Could you please help me to find out good solution for the following problem?
I have a meta model that was build from XML description. I need to create a clone of a eclass, I cannot modify XML file for mentioned purpose because XML file is created by third party system and can be changed without notification. In C++ world this technique is named copy constructor.
Thank for advance
Alex
|
|
|
|
Re: Creating EClass by EClass [message #1705600 is a reply to message #1705597] |
Mon, 17 August 2015 17:24 |
|
I saw org.eclipse.emf.ecore.util.EcoreUtil.copy. (public static EObject copy(EObject eObject)). This method copies instance of eclass. I load meta model from XML description. I should have two EClasses that are very similar. I thought that I can create one then make copy and add couple of attributes to new eclass. I cannot change original XML because is is generated by third party system.
|
|
|
|
|
|
Re: Creating EClass by EClass [message #1705675 is a reply to message #1705666] |
Tue, 18 August 2015 09:43 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
I think you need to start again expressing your requirement without any
ambiguity. At present you seem confused and so we are even more so.
It is obvious to Ed M and me that EcoreUtil.copy does what you need.
However your original question was:
"I have a meta model that was build from XML description. I need to
create a clone of a eclass"
EcoreUtil.copy normally creates copies/clones of EClass instances. Not
of EClasses, although at a different meta-level an ECLass is an EObject
so it can also be cloned.
Why/how is your metamodel build from XML? We normally load a metamodel
and also load models. Do you mean that load an XML model and infer the
metamodel automatically?
What "eclass" do you want to clone? Do you really want to modify the
metamodel?
Whatever the answers, EcoreUtil.copy and friends does it; you just need
to understand what metalevel you are thinking about.
Regards
Ed Willink
On 18/08/2015 10:01, Ed Merks wrote:
> Alex,
>
> I'm having a hard time parsing your commentary, but seeing no question
> mark, I assume there is no question in this commentary. Is there still
> a question?
>
>
> On 18/08/2015 10:10 AM, Alex Gor wrote:
>> Thanks
>> But in Java I work with reference to object, so if I get created from
>> XML instance of eClass and modify, I will have the modified copy.
>> Actually I need to have two instances of the same eClass, one of them
>> will be modified and used with particular way.
>
|
|
|
Powered by
FUDForum. Page generated in 0.04171 seconds