Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Example for serialization to plain text file
Example for serialization to plain text file [message #418047] Thu, 03 April 2008 17:56 Go to next message
Bernd Mühlböck is currently offline Bernd MühlböckFriend
Messages: 46
Registered: July 2009
Member
Are there any (good) examples for customizing the serialization of the
editor to produce plain text?
All I know so far is that I have to override the save() and load()
methods, but didn't quite get how to.

The target is to make the syntax as simple as possible, e.g.:
A->B
B->C
D->C
....


Thanks,
Bernd
Re: Example for serialization to plain text file [message #418048 is a reply to message #418047] Thu, 03 April 2008 18:15 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Bernd,

ResourceImpl's doSave and doLoad methods throw exceptions. You'd
literally just have to override those two methods. You might look at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206267 as an example;
though it does the opposite, i.e., makes it as unreadable as possible
(short of encryption). The doSave method will be responsible for
walking your containment tree and converting it to text. The doLoad
method must do the inverse. The TMF project is starting up to support
Xtext, which lets you define a grammar for your model's serialization
and generates parsers, printers for it, and other cool stuff for it.
I'll bet that would be really useful for what you're trying to do.


Bernd Mühlböck wrote:
> Are there any (good) examples for customizing the serialization of the
> editor to produce plain text?
> All I know so far is that I have to override the save() and load()
> methods, but didn't quite get how to.
>
> The target is to make the syntax as simple as possible, e.g.:
> A->B
> B->C
> D->C
> ....
>
>
> Thanks,
> Bernd


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Question about ItemPropertyDescriptor#getId(Object)
Next Topic:cross-resource containment
Goto Forum:
  


Current Time: Thu Mar 28 12:52:08 GMT 2024

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

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

Back to the top