0
我目前正在研究自我使用的項目,並在理解JAXB中的解組過程時遇到了一些問題。JAXB Unmarshaling - 列表
我有我的對象,我想保存到一個XML文件,我用編組做什麼。現在我需要在ArrayList中加載解組的對象,所以我可以查看所有這些對象,而我正在尋找某些東西。
我的代碼如下所示:
@XmlRootElement()
public class Customer {
private int id;
private String name;
private String adress;
private String telephone;
private String firm = null;
// getters and Setters and Constructor
....
}
而且我JAXB的Unmarshaller:
public void loadCustomers() throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(Customer.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
jaxbUnmarshaller.unmarshal(file);
}
我在哪裏設置,以便插入創建的對象到一個列表? 有沒有可能像做
ArrayList customerList = jaxbUnmarshaller.unmarshal(file);
還是有隻與創建Sub和超類的方法是什麼?