Re: [Simple-support] Deserializing polymorphic types.
Brought to you by:
niallg
|
From: adev d. <and...@gm...> - 2015-02-18 11:17:59
|
Ok, it is simple:
nodeMap.remove("class");
node.put("class", "newClassPath");
Thanks for support!
On 17 February 2015 at 12:26, adev dev <and...@gm...> wrote:
> Great! One more question. How to modify this InputNode in order to apply
> this new name "y". I assume after changing node I have to call
> super.read(). Thank you!
>
>
>
> On 17 February 2015 at 07:57, Niall Gallagher - Yieldbroker <
> Nia...@yi...> wrote:
>
>> 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...>
>> 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...> wrote:
>>
>> Subject: [Simple-support] Deserializing polymorphic types.
>> To: 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...
>> https://lists.sourceforge.net/lists/listinfo/simple-support
>>
>>
>>
>
>
|