Example for serialization to plain text file [message #418047] |
Thu, 03 April 2008 13:56  |
Eclipse User |
|
|
|
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 14:15  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.06123 seconds