|
|
|
Re: Custom serialization of my model [message #419008 is a reply to message #419006] |
Wed, 07 May 2008 21:07 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------000404010003030902060602
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Vincent,
If you change a generated XyzExample.java in a *.tests project you get
when you invoke Generate Test Code, you could register a resource
factory that creates a binary resource in order to test it.
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put
(Resource.Factory.Registry.DEFAULT_EXTENSION,
new ResourceFactoryImpl()
{
@Override
public Resource createResource(URI uri)
{
return new BinaryResourceImpl(uri);
}
});
Vincent L. wrote:
> Thanks Ed,
>
> It helps a lot... Do you have any example that show how to use this
> class?
>
> It will help me to figure out how can I integrate this class in my
> futur plugin.
>
> Thanks a lot.
>
> Vincent
>
>
>
>
> Ed Merks wrote:
>> Vincent,
>>
>> Comments below.
>>
>>
>> Vincent L. wrote:
>>>
>>> Hi all,
>>>
>>> I'm looking for a method to serialize my model in a different format
>>> than the default XMI format. For example, it could be a .txt file.
>>>
>>> Example:
>>>
>>> Currently the output file is something like this.
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <seqeditor:TestFile xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:seqeditor="http://www.opalrt.com/tm.ui.seqeditor"
>>> name="myName1" myAttr="myAttrib1">
>>> <children xsi:type="seqeditor:Variable" name="myVariable"
>>> myAttr="myAttrib2"/>
>>> <children xsi:type="seqeditor:Test" name="myTest" myAttr="myAttrib3">
>>> <children xsi:type="seqeditor:Loop" name="myLoop"
>>> myAttr="myAttrib4">
>>> <children xsi:type="seqeditor:StepCompile" name="myName2"
>>> myAttr="myAttrib5"/>
>>> </children>
>>> </children>
>>> </seqeditor:TestFile>
>>>
>>>
>>> I would like to have something like this instead:
>>>
>>> TestFile
>>> name=myName1
>>> myAttr=myAttrib1
>>> Variable
>>> name=myVariable
>>> myAttr=myAttrib2
>>> Test
>>> name=myTest
>>> myAttr=myAttrib3
>>> Loop
>>> name=myLoop
>>> myAttr=myAttrib4
>>> StepCompile
>>> name=myName2
>>> myAttr=myAttrib5
>>> To be honnest, I don't know where to start...
>>>
>>> Can I override some method of my Eclass to change the default way
>>> the object serialize? Or should I write complety new code to iterate
>>> my model children?
>> You'd need to implement your own ResourceImpl and specialize the
>> doLoad and doSave methods. You might want to look at the
>> BinaryResourceImpl.java in our 2.4M7 build as an example of how to
>> traverse a structure and convert it to a serialized form; in this
>> case to a compact binary serialized form.
>>>
>>> Any help will be appreciate.
>>>
>>> Thanks.
>>>
>>> Vincent
>>>
--------------000404010003030902060602
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Vincent,<br>
<br>
If you change a generated XyzExample.java in a *.tests project you get
when you invoke Generate Test Code, you could register a resource
factory that creates a binary resource in order to test it.<br>
<br>
<small>
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put <br>
(Resource.Factory.Registry.DEFAULT_EXTENSION, <br>
new ResourceFactoryImpl()<br>
{<br>
@Override<br>
public Resource createResource(URI uri)<br>
{<br>
return new BinaryResourceImpl(uri);<br>
}<br>
});</small><br>
<br>
<br>
Vincent L. wrote:
<blockquote cite="mid:fvt417$t6s$1@build.eclipse.org" type="cite">Thanks
Ed,
<br>
<br>
It helps a lot... Do you have any example that show how to use this
class?
<br>
<br>
It will help me to figure out how can I integrate this class in my
futur plugin.
<br>
<br>
Thanks a lot.
<br>
<br>
Vincent
<br>
<br>
<br>
<br>
<br>
Ed Merks wrote:
<br>
<blockquote type="cite">Vincent,
<br>
<br>
Comments below.
<br>
<br>
<br>
Vincent L. wrote:
<br>
<blockquote type="cite"><br>
Hi all,
<br>
<br>
I'm looking for a method to serialize my model in a different format
than the default XMI format. For example, it could be a .txt file.
<br>
<br>
Example:
<br>
<br>
Currently the output file is something like this.
<br>
<br>
<?xml version="1.0" encoding="UTF-8"?>
<br>
<seqeditor:TestFile xmi:version="2.0"
xmlns:xmi=<a class="moz-txt-link-rfc2396E" href="http://www.omg.org/XMI">"http://www.omg.org/XMI"</a>
xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>
xmlns:seqeditor=<a class="moz-txt-link-rfc2396E" href="http://www.opalrt.com/tm.ui.seqeditor">"http://www.opalrt.com/tm.ui.seqeditor"</a> name="myName1"
myAttr="myAttrib1">
<br>
<children xsi:type="seqeditor:Variable" name="myVariable"
myAttr="myAttrib2"/>
<br>
<children xsi:type="seqeditor:Test" name="myTest"
myAttr="myAttrib3">
<br>
<children xsi:type="seqeditor:Loop" name="myLoop"
myAttr="myAttrib4">
<br>
<children xsi:type="seqeditor:StepCompile" name="myName2"
myAttr="myAttrib5"/>
<br>
</children>
<br>
</children>
<br>
</seqeditor:TestFile>
<br>
<br>
<br>
I would like to have something like this instead:
<br>
<br>
TestFile
<br>
name=myName1
<br>
myAttr=myAttrib1
<br>
Variable
<br>
name=myVariable
<br>
myAttr=myAttrib2
<br>
Test
<br>
name=myTest
<br>
myAttr=myAttrib3
<br>
Loop
<br>
name=myLoop
<br>
myAttr=myAttrib4
<br>
StepCompile
<br>
name=myName2
<br>
myAttr=myAttrib5
<br>
To be honnest, I don't know where to start...
<br>
<br>
Can I override some method of my Eclass to change the default way the
object serialize? Or should I write complety new code to iterate my
model children?
<br>
</blockquote>
You'd need to implement your own ResourceImpl and specialize the doLoad
and doSave methods. You might want to look at the
BinaryResourceImpl.java in our 2.4M7 build as an example of how to
traverse a structure and convert it to a serialized form; in this case
to a compact binary serialized form.
<br>
<blockquote type="cite"><br>
Any help will be appreciate.
<br>
<br>
Thanks.
<br>
<br>
Vincent
<br>
<br>
</blockquote>
</blockquote>
</blockquote>
<br>
</body>
</html>
--------------000404010003030902060602--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04127 seconds