Support for polymorphism/inheritance

View: New views
2 Messages — Rating Filter:   Alert me  

Support for polymorphism/inheritance

by Andy Barlow [Deftex] :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
I read with interest the following message in the archive:

https://sourceforge.net/mailarchive/message.php?msg_name=4ABD3696.9080107%40mail.usask.ca

I am encountering a similar issue and wondered if there was a task on the Simple XML roadmap to tackle polymorphism/inheritance.

Simply put:

i) Say you have a parent class or interface called Task
ii) You have two classes ThisTask and ThatTask that either extent the class or implement the interface
iii) In another class I have a ListofTasks which is a List<Task>, and that list can (of course) contain any number of ThisTask's and ThatTask's in any order (not too bothered about the order, as I understand XML parsers cannot guarantee node ordering)

What I'd LIKE to see in the XML when serialised is something like:

<ListofTasks>
<ThisTask/>
<ThatTask/>
<ThisTask/>
<ThisTask/>
<ThatTask/>
<ThatTask/>
<ThatTask/>
</ListofTasks>

What I actually get is 

<ListofTasks>
<Task class="ThisTask"/>
<Task class="ThatTask"/>
<Task class="ThisTask"/>
<Task class="ThisTask"/>
<Task class="ThatTask"/>
<Task class="ThatTask"/>
<Task class="ThatTask"/>
</ListofTasks>

Since I'm working from the XML as a master (the actual XML is more complicated than this, but I've simplified to illustrate the issue), I currently have no choice but to change the structure of the top-level class, so instead of:

List<Task> tasks = ArrayList<Task>();

I have to have a member variable for each type of task:

List<ThisTask> thisTasks = ArrayList<ThisTask>();
List<ThatTask> thatTasks = ArrayList<ThatTask>();

so I when I deserialise and then serialise the XML is the same.

I saw a reply from Niall mentioning how this could be resolved.

Is this on the roadmap and is there a timeline?

Regards,
Andy Barlow


The information in this email or facsimile is confidential and is intended solely for the addressee(s) and access to this email or facsimile by anyone else is unauthorised. If you are not the intended recipient then any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Information expressed in this email or facsimile is not given or endorsed by my firm or employer unless otherwise indicated by an authorised representative independent of this message.

Deftex LimitedComputer Consultancy
 
Andy Barlow MBCS CENG EURING CITPDeftex Limited
ConsultantHigh Riding
Richmond
North Yorkshire
DL10 5BN
Skype Meª!
skype: andybarlow285
 
andy.barlow@...tel: +44 (0)208 123 6285
http://www.deftex.co.ukmobile: +44 (0)7830 302 268
 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support

Re: Support for polymorphism/inheritance

by Niall Gallagher-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
 
I think this can be done, in fact I took a look at this recently. I hope I can release a version that makes this easy to do shortly. Perhaps in the next release, which should be a couple of weeks.
 
Niall

--- On Sat, 10/17/09, Andy Barlow [Deftex] <andy.barlow@...> wrote:

From: Andy Barlow [Deftex] <andy.barlow@...>
Subject: [Simple-support] Support for polymorphism/inheritance
To: simple-support@...
Date: Saturday, October 17, 2009, 2:19 AM

I read with interest the following message in the archive:

https://sourceforge.net/mailarchive/message.php?msg_name=4ABD3696.9080107%40mail.usask.ca

I am encountering a similar issue and wondered if there was a task on the Simple XML roadmap to tackle polymorphism/inheritance.

Simply put:

i) Say you have a parent class or interface called Task
ii) You have two classes ThisTask and ThatTask that either extent the class or implement the interface
iii) In another class I have a ListofTasks which is a List<Task>, and that list can (of course) contain any number of ThisTask's and ThatTask's in any order (not too bothered about the order, as I understand XML parsers cannot guarantee node ordering)

What I'd LIKE to see in the XML when serialised is something like:

<ListofTasks>
<ThisTask/>
<ThatTask/>
<ThisTask/>
<ThisTask/>
<ThatTask/>
<ThatTask/>
<ThatTask/>
</ListofTasks>

What I actually get is 

<ListofTasks>
<Task class="ThisTask"/>
<Task class="ThatTask"/>
<Task class="ThisTask"/>
<Task class="ThisTask"/>
<Task class="ThatTask"/>
<Task class="ThatTask"/>
<Task class="ThatTask"/>
</ListofTasks>

Since I'm working from the XML as a master (the actual XML is more complicated than this, but I've simplified to illustrate the issue), I currently have no choice but to change the structure of the top-level class, so instead of:

List<Task> tasks = ArrayList<Task>();

I have to have a member variable for each type of task:

List<ThisTask> thisTasks = ArrayList<ThisTask>();
List<ThatTask> thatTasks = ArrayList<ThatTask>();

so I when I deserialise and then serialise the XML is the same.

I saw a reply from Niall mentioning how this could be resolved.

Is this on the roadmap and is there a timeline?

Regards,
Andy Barlow


The information in this email or facsimile is confidential and is intended solely for the addressee(s) and access to this email or facsimile by anyone else is unauthorised. If you are not the intended recipient then any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Information expressed in this email or facsimile is not given or endorsed by my firm or employer unless otherwise indicated by an authorised representative independent of this message.

Deftex Limited Computer Consultancy
 
Andy Barlow MBCS CENG EURING CITP Deftex Limited
Consultant High Riding
Richmond
North Yorkshire
DL10 5BN
Skype Meª!
skype: andybarlow285
 
andy.barlow@... tel: +44 (0)208 123 6285
http://www.deftex.co.uk mobile: +44 (0)7830 302 268
 


-----Inline Attachment Follows-----

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference

-----Inline Attachment Follows-----

_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support