Schlagwort: EMF

EMF: Setting an empty string as default value

If you create a string in an EMF model, its null by default: If you want to have an empty string, instead of null, you have to enter a “Default Value Literal”. For an empty string, just click on the value and hit enter (very obvious): To get the null value back, just click on …

weiterlesen »

EMF: Object is not contained in a resource

I had a small problem saving my EMF model to XML. I got the error message “The object … is not contained in a resource”. The solution is simple. In the EMF editor just set containment to true for the reference: Done! After that, the object was saved correctly in the XML file.

weiterlesen »

Save and load an EMF model to an XML file

Here are two code snippets which give you an example how to save and load an EMF model to an XML file. Note that "Data" is my EMF model object. Save EMF to XML file: public void saveData(String fileName, Data data) throws IOException { Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE; Map<String, Object> m = reg.getExtensionToFactoryMap(); m.put("daform", new …

weiterlesen »