com.nuecho.rivr.voicexml.turn.input.VoiceXmlInputTurn Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rivr-voicexml Show documentation
Show all versions of rivr-voicexml Show documentation
Rivr is a lightweight open-source dialogue engine enabling flexible VoiceXML web application development for the agile Java developer and enterprise.
/*
* Copyright (c) 2013 Nu Echo Inc. All rights reserved.
*/
package com.nuecho.rivr.voicexml.turn.input;
import static java.util.Collections.*;
import java.util.*;
import javax.json.*;
import com.nuecho.rivr.core.channel.*;
import com.nuecho.rivr.core.util.*;
import com.nuecho.rivr.voicexml.servlet.*;
import com.nuecho.rivr.voicexml.util.json.*;
/**
* The result of an interaction with the platform, it may contains one or many
* of the following: a recognition result, a recording, VoiceXml events, a
* transfer status, a script result, uploaded files.
*
* @author Nu Echo Inc.
* @see RecognitionInfo
* @see RecordingInfo
* @see TransferStatusInfo
* @see VoiceXmlEvent
* @see FileUpload
*/
public final class VoiceXmlInputTurn implements InputTurn, JsonSerializable {
private static final String TRANSFER_RESULT_PROPERTY = "transferResult";
private static final String RECORDING_INFO_PROPERTY = "recordingInfo";
private static final String RECOGNITION_INFO_PROPERTY = "recognitionInfo";
private static final String EVENTS_PROPERTY = "events";
private static final String VALUE_PROPERTY = "value";
private List mEvents = emptyList();
private JsonValue mJsonValue;
private RecognitionInfo mRecognitionInfo;
private RecordingInfo mRecordingInfo;
private TransferStatusInfo mTransferResult;
private Map mFiles;
public List getEvents() {
return Collections.unmodifiableList(mEvents);
}
public JsonValue getJsonValue() {
return mJsonValue;
}
public RecognitionInfo getRecognitionInfo() {
return mRecognitionInfo;
}
public RecordingInfo getRecordingInfo() {
return mRecordingInfo;
}
public TransferStatusInfo getTransferResult() {
return mTransferResult;
}
public void setEvents(List events) {
Assert.notNull(events, "events");
mEvents = new ArrayList(events);
}
public void setJsonValue(JsonValue jsonValue) {
mJsonValue = jsonValue;
}
public void setRecognitionInfo(RecognitionInfo recognitionInfo) {
mRecognitionInfo = recognitionInfo;
}
public void setRecordingInfo(RecordingInfo recordingInfo) {
mRecordingInfo = recordingInfo;
}
public void setTransferResult(TransferStatusInfo transferResult) {
mTransferResult = transferResult;
}
public void setFiles(Map files) {
mFiles = new HashMap(files);
}
public Map getFiles() {
return unmodifiableMap(mFiles);
}
@Override
public String toString() {
return asJson().toString();
}
@Override
public JsonValue asJson() {
JsonObjectBuilder builder = JsonUtils.createObjectBuilder();
JsonUtils.add(builder, VALUE_PROPERTY, mJsonValue);
JsonUtils.add(builder, EVENTS_PROPERTY, JsonUtils.toJson(mEvents));
JsonUtils.add(builder, RECOGNITION_INFO_PROPERTY, mRecognitionInfo);
JsonUtils.add(builder, RECORDING_INFO_PROPERTY, mRecordingInfo);
JsonUtils.add(builder, TRANSFER_RESULT_PROPERTY, mTransferResult);
return builder.build();
}
}