Re: [Simple-support] extends ArrayList<E> and simple xml
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2011-10-22 00:45:21
|
You are annotating an ArrayList<E>, this does not make much sense. Collections should not be annotated.
________________________________
From: Leonardo Seccia <le...@ma...>
To: sim...@li...
Sent: Wednesday, 19 October 2011 12:50 PM
Subject: [Simple-support] extends ArrayList<E> and simple xml
Hi all,
I am new to java development and to the simple xml library.
Here are my classes (some code has been removed to make it more concise):
@Root
@ElementList
public class MyArrayList<E> extends ArrayList<E>{
public void ToXml() throws Exception{
Serializer serializer = new Persister();
File file = new File("somewhere in my file system");
serializer.write(this, file);
}
}
@Root
public abstract class MediaEntry implements Serializable {
private static final long serialVersionUID = 1L;
@Element
public String Title;
@Element
public String Description;
@Element
public String Url;
@Element
public String LocalPath;
public MediaEntry(String title, String description, String url, String localPath) {
Title= title;
Description= description;
Url= url;
LocalPath= localPath;
}
}
public class VideoEntry extends MediaEntry {
private static final long serialVersionUID = 1L;
public VideoEntry(String title, String description, String url, String localPath) {
super(title, description, url, localPath);
}
}
When I instantiate MyArrayList<MediaEntry> add some VideoEntries and call ToXml, I only get an empty root ie. <MyArrayList />
How to I solve this? Is it something to do with the fact that MyArrayList is generic?
Thanks in advance,
Leo
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support |