简体   繁体   English

如何以编程方式创建ecore文件的实例

[英]How to create an instance of an ecore file programmatically

I am trying to create an instance of an ecore file so I can store data in it. 我正在尝试创建ecore文件的实例,以便可以在其中存储数据。 I will serialize it and store it as XMI (and then load it if it exist). 我将对其进行序列化并将其存储为XMI(如果存在,则将其加载)。 In my case I cannot use genmodel and "create dynamic instance". 就我而言,我不能使用genmodel和“创建动态实例”。 I found this tutorial which create the ecore model itself programmatically, but I want to load an ecore file and then create an instance of it using some general factory. 我找到了本教程该教程以编程方式本身创建了ecore模型,但是我想加载一个ecore文件,然后使用一些常规工厂创建它的实例。

How can I achieve this? 我该如何实现?

Thank you for your time and help 谢谢您的时间和帮助

you may have a look at http://www.ibm.com/developerworks/library/os-eclipse-dynamicemf/index.html 您可以看看http://www.ibm.com/developerworks/library/os-eclipse-dynamicemf/index.html

(with the difference of getting the eclasses and estructural features by reading the ecore) (通过阅读ecore获得eclass和结构特征的区别)

In the tutorial they use ResourceSet.createResource() to create a new resource. 在本教程中,他们使用ResourceSet.createResource()创建新资源。

If you want to load an existing resource, you should try ResourceSet.getResource() . 如果要加载现有资源,则应尝试ResourceSet.getResource()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM