如何使用Java XML包装类创建对象

如何使用Java XML包装类创建对象,java,xml,Java,Xml,我试图创建包装器类中列出的XML对象。包装器称为LogType,您可以使用它指定要创建的对象类型,但我不知道如何创建。基本上,我想要的东西是 LogType X = new <QuoteServerType>LogType(); * * * *列表中允许以下类型的对象 *{@link UserCommandType} *{@link QuoteServerType} *{@link AccountTransactionType} *{@link SystemEventType}

我试图创建包装器类中列出的XML对象。包装器称为LogType,您可以使用它指定要创建的对象类型,但我不知道如何创建。基本上,我想要的东西是

LogType X = new <QuoteServerType>LogType();
* * * *列表中允许以下类型的对象 *{@link UserCommandType} *{@link QuoteServerType} *{@link AccountTransactionType} *{@link SystemEventType} *{@link ErrorEventType} *{@link DebugType} * * */ 公共列表getUserCommandOrQuoteServerOrAccountTransaction{ 如果userCommandOrQuoteServerOrAccountTransaction==null{ userCommandOrQuoteServerOrAccountTransaction=新建ArrayList; } 返回此.userCommandOrQuoteServerOrAccountTransaction; } }
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "LogType", propOrder = {
"userCommandOrQuoteServerOrAccountTransaction"
})
public class LogType {

@XmlElements({
    @XmlElement(name = "userCommand", type = UserCommandType.class),
    @XmlElement(name = "quoteServer", type = QuoteServerType.class),
    @XmlElement(name = "accountTransaction", type = AccountTransactionType.class),
    @XmlElement(name = "systemEvent", type = SystemEventType.class),
    @XmlElement(name = "errorEvent", type = ErrorEventType.class),
    @XmlElement(name = "debugEvent", type = DebugType.class)
})
protected List<Object> userCommandOrQuoteServerOrAccountTransaction;

/**
 * Gets the value of the userCommandOrQuoteServerOrAccountTransaction property.
 * 
 * <p>
 * This accessor method returns a reference to the live list,
 * not a snapshot. Therefore any modification you make to the
 * returned list will be present inside the JAXB object.
 * This is why there is not a <CODE>set</CODE> method for the userCommandOrQuoteServerOrAccountTransaction property.
 * 
 * <p>
 * For example, to add a new item, do as follows:
 * <pre>
 *    getUserCommandOrQuoteServerOrAccountTransaction().add(newItem);
 * </pre>
 * 
 * 
 * <p>
 * Objects of the following type(s) are allowed in the list
 * {@link UserCommandType }
 * {@link QuoteServerType }
 * {@link AccountTransactionType }
 * {@link SystemEventType }
 * {@link ErrorEventType }
 * {@link DebugType }
 * 
 * 
 */
public List<Object> getUserCommandOrQuoteServerOrAccountTransaction() {
    if (userCommandOrQuoteServerOrAccountTransaction == null) {
        userCommandOrQuoteServerOrAccountTransaction = new ArrayList<Object>();
    }
    return this.userCommandOrQuoteServerOrAccountTransaction;
}

}