Re: [Simple-support] Deserializing polymorphic types.
Brought to you by:
niallg
|
From: Niall G. - Y. <Nia...@yi...> - 2015-02-17 06:57:42
|
It would look something like this, check out the test cases I have done this very thing several times there.
class MyStrategy extends AnnotationStrategy{
@Override
read(InputNode n, …) {
String className = n.getAttribute(“class”).getValue();
if(className.equals(“x”)) {
className = “y”;
}
// etc…
}
}
From: adev dev [mailto:and...@gm...]
Sent: 17 February 2015 17:52
To: Niall Gallagher
Cc: sim...@li...
Subject: Re: [Simple-support] Deserializing polymorphic types.
Niall, thank you for response. To be more specific, I create serializer with AnnotationStrategy:
Strategy strategy = new AnnotationStrategy();
mSerializer = new Persister(strategy);
Than, I am using it to read slide:
mSerializer.read(Slide.class, bis);
Class Slide has list of elements of polimorphic type:
@ElementList(name = "mList")
private PrsArrayList<Element> mElementList = null;
"Element" is base class of the things which are serialized.
Could you please provide some pseudo code how to achieve the goal?? How to do this mapping? Thank you!
On 16 February 2015 at 23:12, Niall Gallagher <gal...@ya...<mailto:gal...@ya...>> wrote:
Ya, you can use a Strategy or a Visitor to do this. Another alternative is to open a text editor and do a search an replace on the XML.
--------------------------------------------
On Tue, 17/2/15, adev dev <and...@gm...<mailto:and...@gm...>> wrote:
Subject: [Simple-support] Deserializing polymorphic types.
To: sim...@li...<mailto:sim...@li...>
Received: Tuesday, 17 February, 2015, 2:03 AM
I am using SimpleXML
to serialize classes. I am serializing polymorphic types as
well.
Due to this I came across a problem. I would like
to do code refactoring and move some classes between
packages. After I did it old XML files created before
refactoring cannot be read. Simple framwork is throwing
exception that class is not found. In XML full path to class
is stored so after I changed class package class cannot not
be found. What is the solution to this problem? Is there any
way to apply kind of mapping between old and new class
location???
Thank you,
BR, M
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT
Server
from Actuate! Instantly Supercharge Your Business Reports
and Dashboards
with Interactivity, Sharing, Native Excel Exports, App
Integration & more
Get technology previously reserved for billion-dollar
corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...<mailto:Sim...@li...>
https://lists.sourceforge.net/lists/listinfo/simple-support
|