package com.netqin.fcm.response;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.Element;
/**
* 激活回复报文对象,并且生成激活回复报文
*
* @author jyin
* @version 1.0
*/
public class ResponseCommandError extends BaseResponse implements
ResponseHandler {
/**
*
*/
private static final long serialVersionUID = 8168231416886030622L;
private String trialDays;
private String password;
private String safePhoneNum;
private String errorCode;
private String errorType;
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorType() {
return errorType;
}
public void setErrorType(String errorType) {
this.errorType = errorType;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSafePhoneNum() {
return safePhoneNum;
}
public void setSafePhoneNum(String safePhoneNum) {
this.safePhoneNum = safePhoneNum;
}
public String getTrialDays() {
return trialDays;
}
public void setTrialDays(String trialDays) {
this.trialDays = trialDays;
}
/*
* (non-Javadoc)
*
* @see com.netqin.fcm.response.ResponseHandler#createXmlText()
*/
public String createXmlText() {
Document document = addCommonRespInfo();
addServiceInfo(document);
Element serviceElement = (Element) document
.selectSingleNode("/Reply/ServiceInfo");
serviceElement.addElement("TrialDays").addText(getTrialDays());
serviceElement.addElement("Password").addText(getPassword());
serviceElement.addElement("SafePhoneNum").addText(getSafePhoneNum());
Element rootElement = document.getRootElement();
Element errorInfoElement = rootElement.addElement("ErrorInfo");
errorInfoElement.addElement("ErrorCode").addText(getErrorCode());
errorInfoElement.addElement("ErrorType").addText(getErrorType());
addSystemMsg(document);
return document.asXML();
}
public static void main(String[] args) {
ResponseCommandError response = new ResponseCommandError();
response.setTransfer("transfer");
response.setProtocol("protocol");
response.setCommand("command");
response.setBalance("100");
response.setUid("46541631");
response.setUserType("userType");
response.setTypeName("typeName");
response.setNextPayDay("Friday");
response.setTrialDays("100");
response.setPassword("111111");
response.setSafePhoneNum("1234567877");
response.setErrorCode("1111111111");
response.setErrorType("Y");
List msgList = new ArrayList();
msgList.add("msg1");
msgList.add("msg2");
msgList.add("msg3");
response.setMsgList(msgList);
response.setMsgType("text");
String xml = response.createXmlText();
response.write2File(xml);
System.out.println(xml);
}
private void write2File(String xmlText) {
File file = new File("E:\\comm\\Error.xml");
try {
FileWriter writer = new FileWriter(file);
writer.write(xmlText);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
阅读(2292) | 评论(0) | 转发(0) |