接口:
public String audioFile(AudioFile audioFile) throws ParseException;
接口实现:
@Override
public String audioFile(AudioFile audioFile) throws ParseException {
Document document = this.createFile();
Element root = document.getRootElement();
Element paramSetElement = root.addElement("task").addAttribute("id", "");
Element file = paramSetElement.addElement("file");
file.setText(audioFile.getFileName());
Element fileStartTime = paramSetElement.addElement("fileStartTime");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = format.format(audioFile.getStartDateTime());
fileStartTime.setText(startTime);
Element fileEndTime = paramSetElement.addElement("fileEndTime");
String endTime = format.format(audioFile.getEndDateTime());
fileEndTime.setText(endTime);
Element taskStartTime = paramSetElement.addElement("taskStartTime");
taskStartTime.setText("");
Element taskEndTime = paramSetElement.addElement("taskEndTime");
taskEndTime.setText("");
Element freq = paramSetElement.addElement("freq");
freq.setText(String.valueOf(audioFile.getFreq()));
Element language = paramSetElement.addElement("language");
language.setText(audioFile.getLanguage());
Element collectMethod = paramSetElement.addElement("collectMethod");
collectMethod.setText("");
Element collectChannel = paramSetElement.addElement("collectChannel");
collectChannel.setText("");
Element receiverType = paramSetElement.addElement("receiverType");
receiverType.setText(audioFile.getReceiverType());
Element taskId = paramSetElement.addElement("taskId");
taskId.setText(audioFile.getId());
return document.asXML();
}
test测试: