JAXB:XML-Object转换(复杂类型,对象包含对象)

本文深入探讨了游戏开发领域的核心技术,包括游戏引擎、动画、3D空间视频等,并分享了实际开发过程中的经验和技巧。

CupMobiles.Java

Java代码   收藏代码
  1. package com.sitech.echn.uupay.model;  
  2.   
  3. import javax.xml.bind.annotation.XmlRootElement;  
  4. /** 
  5.  * xml对应的java模型 
  6.  * @author wangyfc 
  7.  * 
  8.  */  
  9. @XmlRootElement  
  10. public class CupMobiles {  
  11.     private CupMobile cupMobile;  
  12.     private String msgResponseCode;  
  13.     public CupMobile getCupMobile() {  
  14.         return cupMobile;  
  15.     }  
  16.     public void setCupMobile(CupMobile cupMobile) {  
  17.         this.cupMobile = cupMobile;  
  18.     }  
  19.     public String getMsgResponseCode() {  
  20.         return msgResponseCode;  
  21.     }  
  22.     public void setMsgResponseCode(String msgResponseCode) {  
  23.         this.msgResponseCode = msgResponseCode;  
  24.     }  
  25.       
  26. }  

 

Java代码   收藏代码
  1. package com.sitech.echn.uupay.model;  
  2.   
  3. import javax.xml.bind.annotation.XmlAccessType;  
  4. import javax.xml.bind.annotation.XmlAccessorType;  
  5. import javax.xml.bind.annotation.XmlAttribute;  
  6. import javax.xml.bind.annotation.XmlRootElement;  
  7. @XmlAccessorType(XmlAccessType.FIELD)  
  8. @XmlRootElement  
  9. public class CupMobile {  
  10.  @XmlAttribute  
  11.  private String application="UPNoCard";  
  12.  @XmlAttribute  
  13.  private String version="1.01";  
  14.  private Transaction transaction;  
  15. public String getApplication() {  
  16.     return application;  
  17. }  
  18. public void setApplication(String application) {  
  19.     this.application = application;  
  20. }  
  21. public String getVersion() {  
  22.     return version;  
  23. }  
  24. public void setVersion(String version) {  
  25.     this.version = version;  
  26. }  
  27. public Transaction getTransaction() {  
  28.     return transaction;  
  29. }  
  30. public void setTransaction(Transaction transaction) {  
  31.     this.transaction = transaction;  
  32. }  
  33. }  

 

Java代码   收藏代码
  1. package com.sitech.echn.uupay.model;  
  2.   
  3. import javax.xml.bind.annotation.XmlAccessType;  
  4. import javax.xml.bind.annotation.XmlAccessorType;  
  5. import javax.xml.bind.annotation.XmlAttribute;  
  6. import javax.xml.bind.annotation.XmlRootElement;  
  7.   
  8. @XmlAccessorType(XmlAccessType.FIELD)  
  9. @XmlRootElement  
  10. public class Transaction {  
  11. @XmlAttribute  
  12. private String type="Purchase.PMReq";  
  13. private String submitTime;  
  14. private Order order;  
  15. private Merchant merchant;  
  16. private String accountNumber1;  
  17. private String transSerialNumber;  
  18. private String transResponseCode;  
  19. private String billAmount;  
  20. private String settleDate;  
  21. public String getType() {  
  22.     return type;  
  23. }  
  24. public void setType(String type) {  
  25.     this.type = type;  
  26. }  
  27. public String getSubmitTime() {  
  28.     return submitTime;  
  29. }  
  30. public void setSubmitTime(String submitTime) {  
  31.     this.submitTime = submitTime;  
  32. }  
  33. public Order getOrder() {  
  34.     return order;  
  35. }  
  36. public void setOrder(Order order) {  
  37.     this.order = order;  
  38. }  
  39. public Merchant getMerchant() {  
  40.     return merchant;  
  41. }  
  42. public void setMerchant(Merchant merchant) {  
  43.     this.merchant = merchant;  
  44. }  
  45. public String getAccountNumber1() {  
  46.     return accountNumber1;  
  47. }  
  48. public void setAccountNumber1(String accountNumber1) {  
  49.     this.accountNumber1 = accountNumber1;  
  50. }  
  51. public String getTransSerialNumber() {  
  52.     return transSerialNumber;  
  53. }  
  54. public void setTransSerialNumber(String transSerialNumber) {  
  55.     this.transSerialNumber = transSerialNumber;  
  56. }  
  57. public String getBillAmount() {  
  58.     return billAmount;  
  59. }  
  60. public void setBillAmount(String billAmount) {  
  61.     this.billAmount = billAmount;  
  62. }  
  63. public String getSettleDate() {  
  64.     return settleDate;  
  65. }  
  66. public void setSettleDate(String settleDate) {  
  67.     this.settleDate = settleDate;  
  68. }  
  69. public String getTransResponseCode() {  
  70.     return transResponseCode;  
  71. }  
  72. public void setTransResponseCode(String transResponseCode) {  
  73.     this.transResponseCode = transResponseCode;  
  74. }  
  75.   
  76. }  

 

Java代码   收藏代码
  1. package com.sitech.echn.uupay.model;  
  2.   
  3. import javax.xml.bind.annotation.XmlAccessType;  
  4. import javax.xml.bind.annotation.XmlAccessorType;  
  5. import javax.xml.bind.annotation.XmlAttribute;  
  6. import javax.xml.bind.annotation.XmlRootElement;  
  7.   
  8. @XmlAccessorType(XmlAccessType.FIELD)  
  9. @XmlRootElement  
  10. public class Merchant {  
  11.     @XmlAttribute  
  12.     private String id;  
  13.   
  14.     public String getId() {  
  15.         return id;  
  16.     }  
  17.   
  18.     public void setId(String id) {  
  19.         this.id = id;  
  20.     }  
  21.       
  22. }  

 

Java代码   收藏代码
  1. package com.sitech.echn.uupay.model;  
  2.   
  3. import javax.xml.bind.annotation.XmlAccessType;  
  4. import javax.xml.bind.annotation.XmlAccessorType;  
  5. import javax.xml.bind.annotation.XmlAttribute;  
  6. import javax.xml.bind.annotation.XmlRootElement;  
  7.   
  8. @XmlAccessorType(XmlAccessType.FIELD)  
  9. @XmlRootElement  
  10. public class Order {  
  11. @XmlAttribute  
  12. private String id;  
  13.   
  14. public String getId() {  
  15.     return id;  
  16. }  
  17.   
  18. public void setId(String id) {  
  19.     this.id = id;  
  20. }  
  21. }  

 

Xml代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <cupMobiles>  
  3.     <cupMobile application="UPNoCard" version="1.01">  
  4.         <transaction type="Purchase.MPRsp">  
  5.             <submitTime>20111207111641</submitTime>  
  6.             <order id="12347733"/>  
  7.             <merchant id="303290047228001"/>  
  8.             <accountNumber1>6224130665233518</accountNumber1>  
  9.             <transSerialNumber>201162</transSerialNumber>  
  10.             <transRresponseCode>00000</transRresponseCode>  
  11.             <billAmount currency="156">000000030231</billAmount>  
  12.             <settleDate>20111208</settleDate>  
  13.         </transaction>  
  14.     </cupMobile>  
  15.     <msgResponseCode>000000</msgResponseCode>  
  16. </cupMobiles>  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值