Storing a FeaturePath [message #1252476] |
Fri, 21 February 2014 03:57  |
Eclipse User |
|
|
|
Hello,
I'm in need to save a FeaturePath to a file (to be able to load it again, with the same model - no need to check for this!)
how can i do this as the FeaturePath and its underlying objects do not implement Serializable interface.
i already 'googled' but did not find any solutions (if i missed it and you know a link, let me know)
thanks in advance
Ludwig
|
|
|
|
|
|
|
|
Re: Storing a FeaturePath [message #1255177 is a reply to message #1252838] |
Mon, 24 February 2014 01:52  |
Eclipse User |
|
|
|
if i need to serialize feature paths I simply remember the Eclass the
path starts with and the feature names this is enough if you know the
EClass you start from.
Tom
On 21.02.14 17:55, Ed Merks wrote:
> Felix,
>
> Indeed, ideally the thing would serialize in the same resource, and yes,
> ideally you'd model it as a multi-valued reference to
> EStructuralFeatures. A derived transient volatile attribute could be
> used to provide a "convenience" get/setter than provided/accepted the
> FeatureMap data structure. Then all would serialize as normal...
>
>
> On 21/02/2014 2:31 PM, Felix Dorner wrote:
>> I think Ed meant to let EMF handle the details of serialization, for
>> example by using dynamic EMF. You just create an EPackage with a
>> single EClass that has a reference many of type EStructuralFeature. Then:
>>
>> EObject root = EcoreUtil.create(myFeaturePathClass);
>> root.eGet(path).addAll(allFeaturesInTheFeaturePath);
>>
>> Resource res = ResourceSetImpl().getResource("toto.featurePath", false);
>> res.getContents().add(root);
>> res.save(System.out, Collections.EMPTY_MAP);
>>
>> Maybe you want to register EcoreResourceFactory against the file
>> extension.
>>
>> Felix
>
|
|
|
Powered by
FUDForum. Page generated in 0.27928 seconds