[Simple-support] extends ArrayList<E> and simple xml
Brought to you by:
niallg
|
From: Leonardo S. <le...@ma...> - 2011-10-19 12:20:33
|
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
|