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

CupMobiles.java:

package com.sitech.echn.uupay.model;

import javax.xml.bind.annotation.XmlRootElement;
/**
 * xml对应的java模型
 * @author wangyfc
 *
 */
@XmlRootElement
public class CupMobiles {
	private CupMobile cupMobile;
	private String msgResponseCode;
	public CupMobile getCupMobile() {
		return cupMobile;
	}
	public void setCupMobile(CupMobile cupMobile) {
		this.cupMobile = cupMobile;
	}
	public String getMsgResponseCode() {
		return msgResponseCode;
	}
	public void setMsgResponseCode(String msgResponseCode) {
		this.msgResponseCode = msgResponseCode;
	}
	
}

 

package com.sitech.echn.uupay.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class CupMobile {
 @XmlAttribute
 private String application="UPNoCard";
 @XmlAttribute
 private String version="1.01";
 private Transaction transaction;
public String getApplication() {
	return application;
}
public void setApplication(String application) {
	this.application = application;
}
public String getVersion() {
	return version;
}
public void setVersion(String version) {
	this.version = version;
}
public Transaction getTransaction() {
	return transaction;
}
public void setTransaction(Transaction transaction) {
	this.transaction = transaction;
}
}

 

package com.sitech.echn.uupay.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Transaction {
@XmlAttribute
private String type="Purchase.PMReq";
private String submitTime;
private Order order;
private Merchant merchant;
private String accountNumber1;
private String transSerialNumber;
private String transResponseCode;
private String billAmount;
private String settleDate;
public String getType() {
	return type;
}
public void setType(String type) {
	this.type = type;
}
public String getSubmitTime() {
	return submitTime;
}
public void setSubmitTime(String submitTime) {
	this.submitTime = submitTime;
}
public Order getOrder() {
	return order;
}
public void setOrder(Order order) {
	this.order = order;
}
public Merchant getMerchant() {
	return merchant;
}
public void setMerchant(Merchant merchant) {
	this.merchant = merchant;
}
public String getAccountNumber1() {
	return accountNumber1;
}
public void setAccountNumber1(String accountNumber1) {
	this.accountNumber1 = accountNumber1;
}
public String getTransSerialNumber() {
	return transSerialNumber;
}
public void setTransSerialNumber(String transSerialNumber) {
	this.transSerialNumber = transSerialNumber;
}
public String getBillAmount() {
	return billAmount;
}
public void setBillAmount(String billAmount) {
	this.billAmount = billAmount;
}
public String getSettleDate() {
	return settleDate;
}
public void setSettleDate(String settleDate) {
	this.settleDate = settleDate;
}
public String getTransResponseCode() {
	return transResponseCode;
}
public void setTransResponseCode(String transResponseCode) {
	this.transResponseCode = transResponseCode;
}

}

 

package com.sitech.echn.uupay.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Merchant {
	@XmlAttribute
	private String id;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
}

 

package com.sitech.echn.uupay.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Order {
@XmlAttribute
private String id;

public String getId() {
	return id;
}

public void setId(String id) {
	this.id = id;
}
}

 

<?xml version="1.0" encoding="UTF-8"?>
<cupMobiles>
	<cupMobile application="UPNoCard" version="1.01">
		<transaction type="Purchase.MPRsp">
			<submitTime>20111207111641</submitTime>
			<order id="12347733"/>
			<merchant id="303290047228001"/>
			<accountNumber1>6224130665233518</accountNumber1>
			<transSerialNumber>201162</transSerialNumber>
			<transRresponseCode>00000</transRresponseCode>
			<billAmount currency="156">000000030231</billAmount>
			<settleDate>20111208</settleDate>
		</transaction>
	</cupMobile>
	<msgResponseCode>000000</msgResponseCode>
</cupMobiles>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值