Re: [Simple-support] error while deserializing
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2012-05-31 08:43:34
|
You are using @ElementList when you need to use @Element, take a look at the tutorial or the examples page on the web site, it will explain how to use the framework.
--- On Wed, 30/5/12, Shobhit Sharda <sho...@gm...> wrote:
From: Shobhit Sharda <sho...@gm...>
Subject: [Simple-support] error while deserializing
To: sim...@li...
Received: Wednesday, 30 May, 2012, 5:56 AM
Hello everyone,
I am trying to deserialize the following xml
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<datadef>
<maxversion class="Action3" v.="3"/>
<maxversion class="Action4" v.="4"/>
<maxversion class="Action5" v.="5"/>
</datadef>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Using the following code :
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
@Root
public class maxversion {
@Attribute(name="class", required=false)
public String[] class1;
@Attribute(name="v.", required=false)
public int[] version;
}
import java.io.File;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
public class deserialize {
@ElementList(name="maxversion", required=false)
public maxversion max_version = new maxversion();
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Serializer serializer = new Persister();
File source = new File("file.xml");
deserialize deserialize = serializer.read(deserialize.class, source);
int count_max_version = deserialize.max_version.class1.length;
int i=0;
while(i<count_max_version)
{
System.out.println(deserialize.max_version.class1[i]);
System.out.println(deserialize.max_version.version[i]);
}
}
}
While executing class deserialize, I am getting following error :
Exception in thread "main"
org.simpleframework.xml.core.ElementException: Unable to determine
generic type for field 'max_version' public maxversion
deserialize.max_version
//followed by someother logs
I am not able to resolve the error. Can anyone help me out.
thanks in advance.
--
Shobhit Sharda
MSc in SSE
RWTH Aachen University
Aachen
Germany
blog: http://shobhitsharda.wordpress.com
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|