java RMI轉換XML


 

import org.dom4j.Element;
import java.io.Serializable;
public class SelectionBody extends Body {

    /** serialVersionUID */
    private static final long serialVersionUID = -6826872985549264823L;

    /** CODE */
    private String code;
    /** 類型 */
    private String type;
    /** 等級 */
    private String level;

    /*
     * 將XML文檔對象轉換成業務對象
     */
    @Override
    public void fromXml(Element element) {
        if (element != null) {
            Element condition = element.element("Condition");
            if (condition != null) {
                code = condition.attributeValue("Code");
                type = condition.attributeValue("Type");
            }
        }
        super.fromXml(element);
    }

    /*
     * 將業務對象轉換成XML文檔對象
     */
    @Override
    public Element toXml(Element element) {
        if (element != null) {
            Element condition = element.addElement("Conditon");
            condition.addAttribute("Code", code != null ? code : "");
            condition.addAttribute("Type", type != null ? type : "");
        }
        return super.toXml(element);
    }
}

 

 

 

-----------------------------------------------------------------------------

 

 
        

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM