Re: [Simple-support] PersistenceException: constructor not matched for class error when deserializi
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2011-01-25 10:38:46
|
You need to annotate the constuctor arguments.
--- On Mon, 24/1/11, Thalisson Da Rosa <tal...@gm...> wrote:
From: Thalisson Da Rosa <tal...@gm...>
Subject: [Simple-support] PersistenceException: constructor not matched for class error when deserializing XML file
To: sim...@li...
Received: Monday, 24 January, 2011, 10:32 AM
Hi,
I'm using Simple to create an XML file called BackupInfo.xml from this class:
@Root
public class BackupInfo {
@Attribute
private String backupName;
@Element
private int numberOfFiles;
@ElementList
private ArrayList<FileInfo> files;
@Element
private Date date;
}
@Root
class FileInfo{
@Attribute
public String fileName;
@Element
private String path;
@Element
private long fileSize;
public FileInfo(String name, String aPath, long size) {
fileName = name;
path = aPath;
fileSize = size;
}
public String getName(){
return fileName;
}
public String getPath(){
return path;
}
}
When I serialize it I get a XML file that looks like this:
- <backupInfo backupName="1">
<files>
<fileInfo>
<fileName>sms.xml</fileName>
<path>/sdcard/sms.xml</path>
<fileSize>2807</fileSize>
</fileInfo>
<fileInfo>
<fileName>calllog.xml</fileName>
<path>/sdcard/calllog.xml</path>
<fileSize>1611</fileSize>
</fileInfo>
<fileInfo>
<fileName>contacts.xml</fileName>
<path>/sdcard/contacts.xml</path>
<fileSize>1679</fileSize>
</fileInfo>
</files>
<date>2011-01-21 16:55:15.63 GMT+00:00</date>
<numberOfFiles>3</numberOfFiles>
</backupInfo>
Then I try to deserialize using:
serializer = new Persister();
File info = new File ("/sdcard/BackupInfo.xml");
BackupInfo bi = serializer.read(BackupInfo.class, info);
At this point, I get the PersistenceException: Constructor not matched for class com.data.FileInfo
How do I solve this error? I searched everywhere (tutorial, google, this mail list) but couldn't find an answer.
Thx,
Thalisson
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|