के साथ अपवाद मुझे एक XML फ़ाइल deserialize करने के लिए एक समस्या का सामना कर रहा है जिसे सफलतापूर्वक Simple XML Serialization ढांचे (simpleframework.org) के साथ क्रमबद्ध किया गया है।सरल एक्सएमएल फ्रेमवर्क deserialization
वहाँ an exception फेंक दिया जाता है:
Serializer serializer = new Persister();
File xmlFile = new File(path);
ContactList contactList = serializer.read(ContactList.class, xmlFile); <== Error
मेरे ContactList.java
@Root(strict=false, name="ContacList")
public class ContactList {
@ElementArray (name = "Contacts")
Contact [] contact;
}
मेरे Note.java
public class Note {
@Element(required=false)
private String note;
public Note(String note) {
super();
this.note = note;
}
public String getNote() {
return note;
}
}
:
org.simpleframework.xml.core.PersistenceException: Constructor not matched for class projet.sarelo.Note
इस कॉल है
मेरे Contact.java
@Root
public class Contact {
@Attribute(name = "id")
public String id;
@Element(name="Nom", required=false)
String name;
@ElementArray(name="Phones", required=false)
Phone [] phone;
@ElementArray(name = "Emails", required=false)
Email [] email;
@ElementArray(name = "Adresses", required=false)
Adresses [] adresses;
@ElementArray(name = "Notes", required=false)
Note [] note;
public Contact(String id, String name) {
super();
this.id = id;
this.name = name;
}
public String getName() {
return name;
}
public String getId(){
return id;
}
}
और यह मैं deserialize करने के लिए कोशिश कर रहा हूँ एक्सएमएल फ़ाइल है।
<ContactList>
<Contacts length="5">
<contact id="1">
<Adresses length="0"/>
<Emails length="0"/>
<Notes length="1">
<note>
<note>dgfdg</note>
</note>
</Notes>
</contact>
<contact id="2">
<Adresses length="1">
<adresses>
<city>Paris </city>
<postcode>751234 </postcode>
<state>France</state>
<street>Pignon</street>
</adresses>
</Adresses>
<Emails length="1">
<email type="home">
<home>[email protected]</home>
</email>
</Emails>
<Nom>Nicolas Sarkozy </Nom>
<Notes length="1">
<note>
<note>Je suis le president de toute la france. Le grand president</note>
</note>
</Notes>
<Phones length="2">
<phone>
<home>+33 1234</home>
</phone>
<phone>
<mobile>+33 0612</mobile>
</phone>
</Phones>
</contact>
...
</Contacts>
</ContactList>
FYI करें, बहुत इसी तरह के सवाल [यहां] (http://stackoverflow.com/q/5894320/642706) और [ यहां] (http://stackoverflow.com/q/16135304/642706) –