1 package com.smartdevicelink.proxy.rpc;
\r
3 import java.util.Hashtable;
\r
4 import java.util.Vector;
\r
6 import com.smartdevicelink.proxy.RPCRequest;
\r
7 import com.smartdevicelink.proxy.constants.Names;
\r
8 import com.smartdevicelink.proxy.rpc.enums.InteractionMode;
\r
9 import com.smartdevicelink.util.DebugTool;
\r
11 * Performs an application-initiated interaction in which the user can select a
\r
12 * {@linkplain Choice} from among the specified Choice Sets. For instance, an
\r
13 * application may use a PerformInteraction to ask a user to say the name of a
\r
14 * song to play. The user's response is only valid if it appears in the
\r
15 * specified Choice Sets and is recognized by SMARTDEVICELINK
\r
17 * Function Group: Base
\r
19 * <b>HMILevel needs to be FULL</b>
\r
22 * @since SmartDeviceLink 1.0
\r
23 * @see CreateInteractionChoiceSet
\r
24 * @see DeleteInteractionChoiceSet
\r
26 public class PerformInteraction extends RPCRequest {
\r
28 * Constructs a new PerformInteraction object
\r
30 public PerformInteraction() {
\r
31 super("PerformInteraction");
\r
34 * Constructs a new PerformInteraction object indicated by the Hashtable
\r
39 * The Hashtable to use
\r
41 public PerformInteraction(Hashtable hash) {
\r
45 * Gets the Text that Displayed when the interaction begins. This text may
\r
46 * be overlaid by the "Listening" prompt during the interaction. Text is
\r
47 * displayed on first line of multiline display, and is centered. If text
\r
48 * does not fit on line, it will be truncated
\r
50 * @return String -the text displayed when the interaction begins
\r
52 public String getInitialText() {
\r
53 return (String) parameters.get(Names.initialText);
\r
56 * Sets the Text that Displayed when the interaction begins. This text may
\r
57 * be overlaid by the "Listening" prompt during the interaction. Text is
\r
58 * displayed on first line of multiline display, and is centered. If text
\r
59 * does not fit on line, it will be truncated
\r
61 * @param initialText
\r
62 * a String value that Displayed when the interaction begins
\r
64 public void setInitialText(String initialText) {
\r
65 if (initialText != null) {
\r
66 parameters.put(Names.initialText, initialText);
\r
68 parameters.remove(Names.initialText);
\r
72 * Gets an An array of one or more TTSChunks that, taken together, specify
\r
73 * what is to be spoken to the user at the start of an interaction
\r
75 * @return Vector<TTSChunk> -a Vector<TTSChunk> value, specify what is to be
\r
76 * spoken to the user at the start of an interaction
\r
78 public Vector<TTSChunk> getInitialPrompt() {
\r
79 if (parameters.get(Names.initialPrompt) instanceof Vector<?>) {
\r
80 Vector<?> list = (Vector<?>)parameters.get(Names.initialPrompt);
\r
81 if (list != null && list.size() > 0) {
\r
82 Object obj = list.get(0);
\r
83 if (obj instanceof TTSChunk) {
\r
84 return (Vector<TTSChunk>) list;
\r
85 } else if (obj instanceof Hashtable) {
\r
86 Vector<TTSChunk> newList = new Vector<TTSChunk>();
\r
87 for (Object hashObj : list) {
\r
88 newList.add(new TTSChunk((Hashtable)hashObj));
\r
97 * Sets An array of one or more TTSChunks that, taken together, specify what
\r
98 * is to be spoken to the user at the start of an interaction
\r
100 * @param initialPrompt
\r
101 * a Vector<TTSChunk> value, specify what is to be spoken to the
\r
102 * user at the start of an interaction
\r
104 public void setInitialPrompt(Vector<TTSChunk> initialPrompt) {
\r
105 if (initialPrompt != null) {
\r
106 parameters.put(Names.initialPrompt, initialPrompt);
\r
108 parameters.remove(Names.initialPrompt);
\r
112 * Gets the Indicates mode that indicate how user selects interaction
\r
113 * choice. User can choose either by voice (VR_ONLY), by visual selection
\r
114 * from the menu (MANUAL_ONLY), or by either mode (BOTH)
\r
116 * @return InteractionMode -indicate how user selects interaction choice
\r
117 * (VR_ONLY, MANUAL_ONLY or BOTH)
\r
119 public InteractionMode getInteractionMode() {
\r
120 Object obj = parameters.get(Names.interactionMode);
\r
121 if (obj instanceof InteractionMode) {
\r
122 return (InteractionMode) obj;
\r
123 } else if (obj instanceof String) {
\r
124 InteractionMode theCode = null;
\r
126 theCode = InteractionMode.valueForString((String) obj);
\r
127 } catch (Exception e) {
\r
128 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.interactionMode, e);
\r
135 * Sets the Indicates mode that indicate how user selects interaction
\r
136 * choice. User can choose either by voice (VR_ONLY), by visual selection
\r
137 * from the menu (MANUAL_ONLY), or by either mode (BOTH)
\r
139 * @param interactionMode
\r
140 * indicate how user selects interaction choice (VR_ONLY,
\r
141 * MANUAL_ONLY or BOTH)
\r
143 public void setInteractionMode(InteractionMode interactionMode) {
\r
144 if (interactionMode != null) {
\r
145 parameters.put(Names.interactionMode, interactionMode);
\r
147 parameters.remove(Names.interactionMode);
\r
151 * Gets a Vector<Integer> value representing an Array of one or more Choice
\r
154 * @return Vector<Integer> -a Vector<Integer> value representing an Array of
\r
155 * one or more Choice Set IDs. User can select any choice from any
\r
156 * of the specified Choice Sets
\r
158 public Vector<Integer> getInteractionChoiceSetIDList() {
\r
159 if(parameters.get(Names.interactionChoiceSetIDList) instanceof Vector<?>){
\r
160 Vector<?> list = (Vector<?>)parameters.get(Names.interactionChoiceSetIDList);
\r
161 if(list != null && list.size()>0){
\r
162 Object obj = list.get(0);
\r
163 if(obj instanceof Integer){
\r
164 return (Vector<Integer>) list;
\r
171 * Sets a Vector<Integer> representing an Array of one or more Choice Set
\r
172 * IDs. User can select any choice from any of the specified Choice Sets
\r
174 * @param interactionChoiceSetIDList
\r
175 * -a Vector<Integer> representing an Array of one or more Choice
\r
176 * Set IDs. User can select any choice from any of the specified
\r
179 * <b>Notes: </b>Min Value: 0; Max Vlaue: 2000000000
\r
181 public void setInteractionChoiceSetIDList(Vector<Integer> interactionChoiceSetIDList) {
\r
182 if (interactionChoiceSetIDList != null) {
\r
183 parameters.put(Names.interactionChoiceSetIDList, interactionChoiceSetIDList);
\r
185 parameters.remove(Names.interactionChoiceSetIDList);
\r
189 * Gets a Vector<TTSChunk> which taken together, specify the help phrase to
\r
190 * be spoken when the user says "help" during the VR session
\r
192 * @return Vector<TTSChunk> -a Vector<TTSChunk> which taken together,
\r
193 * specify the help phrase to be spoken when the user says "help"
\r
194 * during the VR session
\r
196 public Vector<TTSChunk> getHelpPrompt() {
\r
197 if(parameters.get(Names.helpPrompt) instanceof Vector<?>){
\r
198 Vector<?> list = (Vector<?>)parameters.get(Names.helpPrompt);
\r
199 if (list != null && list.size() > 0) {
\r
200 Object obj = list.get(0);
\r
201 if (obj instanceof TTSChunk) {
\r
202 return (Vector<TTSChunk>) list;
\r
203 } else if (obj instanceof Hashtable) {
\r
204 Vector<TTSChunk> newList = new Vector<TTSChunk>();
\r
205 for (Object hashObj : list) {
\r
206 newList.add(new TTSChunk((Hashtable)hashObj));
\r
215 * Sets An array of TTSChunks which, taken together, specify the help phrase
\r
216 * to be spoken when the user says "help" during the VR session
\r
218 * If this parameter is omitted, the help prompt will be constructed by SMARTDEVICELINK
\r
219 * from the first vrCommand of each choice of all the Choice Sets specified
\r
220 * in the interactionChoiceSetIDList parameter
\r
222 * <b>Notes: </b>The helpPrompt specified in
\r
223 * {@linkplain SetGlobalProperties} is not used by PerformInteraction
\r
225 * @param helpPrompt
\r
226 * a Vector<TTSChunk> which taken together, specify the help
\r
227 * phrase to be spoken when the user says "help" during the VR
\r
230 public void setHelpPrompt(Vector<TTSChunk> helpPrompt) {
\r
231 if (helpPrompt != null) {
\r
232 parameters.put(Names.helpPrompt, helpPrompt);
\r
234 parameters.remove(Names.helpPrompt);
\r
238 * Gets An array of TTSChunks which, taken together, specify the phrase to
\r
239 * be spoken when the listen times out during the VR session
\r
241 * @return Vector<TTSChunk> -a Vector<TTSChunk> specify the phrase to be
\r
242 * spoken when the listen times out during the VR session
\r
244 public Vector<TTSChunk> getTimeoutPrompt() {
\r
245 if (parameters.get(Names.timeoutPrompt) instanceof Vector<?>) {
\r
246 Vector<?> list = (Vector<?>)parameters.get(Names.timeoutPrompt);
\r
247 if (list != null && list.size() > 0) {
\r
248 Object obj = list.get(0);
\r
249 if (obj instanceof TTSChunk) {
\r
250 return (Vector<TTSChunk>) list;
\r
251 } else if (obj instanceof Hashtable) {
\r
252 Vector<TTSChunk> newList = new Vector<TTSChunk>();
\r
253 for (Object hashObj : list) {
\r
254 newList.add(new TTSChunk((Hashtable)hashObj));
\r
263 * Sets An array of TTSChunks which, taken together, specify the phrase to
\r
264 * be spoken when the listen times out during the VR session
\r
266 * <b>Notes: </b>The timeoutPrompt specified in
\r
267 * {@linkplain SetGlobalProperties} is not used by PerformInteraction
\r
269 * @param timeoutPrompt
\r
270 * a Vector<TTSChunk> specify the phrase to be spoken when the
\r
271 * listen times out during the VR session
\r
273 public void setTimeoutPrompt(Vector<TTSChunk> timeoutPrompt) {
\r
274 if (timeoutPrompt != null) {
\r
275 parameters.put(Names.timeoutPrompt, timeoutPrompt);
\r
277 parameters.remove(Names.timeoutPrompt);
\r
281 * Gets a Integer value representing the amount of time, in milliseconds,
\r
282 * SMARTDEVICELINK will wait for the user to make a choice (VR or Menu)
\r
284 * @return Integer -a Integer representing the amount of time, in
\r
285 * milliseconds, SMARTDEVICELINK will wait for the user to make a choice (VR or
\r
288 public Integer getTimeout() {
\r
289 return (Integer) parameters.get(Names.timeout);
\r
292 * Sets the amount of time, in milliseconds, SMARTDEVICELINK will wait for the user to
\r
293 * make a choice (VR or Menu). If this time elapses without the user making
\r
294 * a choice, the timeoutPrompt will be spoken. After this timeout value has
\r
295 * been reached, the interaction will stop and a subsequent interaction will
\r
296 * take place after SMARTDEVICELINK speaks the timeout prompt. If that times out as
\r
297 * well, the interaction will end completely. If omitted, the default is
\r
301 * an Integer value representing the amount of time, in
\r
302 * milliseconds, SMARTDEVICELINK will wait for the user to make a choice (VR
\r
305 * <b>Notes: </b>Min Value: 5000; Max Value: 100000
\r
307 public void setTimeout(Integer timeout) {
\r
308 if (timeout != null) {
\r
309 parameters.put(Names.timeout, timeout);
\r
311 parameters.remove(Names.timeout);
\r
316 * Gets a Voice recognition Help, which is a suggested VR Help Items to
\r
317 * display on-screen during Perform Interaction
\r
319 * @return Vector<VrHelpItem> -a Vector value representing a suggested VR
\r
320 * Help Items to display on-screen during Perform Interaction
\r
321 * @since SmartDeviceLink 2.0
\r
323 public Vector<VrHelpItem> getVrHelp() {
\r
324 if (parameters.get(Names.vrHelp) instanceof Vector<?>) {
\r
325 Vector<?> list = (Vector<?>)parameters.get(Names.vrHelp);
\r
326 if (list != null && list.size() > 0) {
\r
327 Object obj = list.get(0);
\r
328 if (obj instanceof VrHelpItem) {
\r
329 return (Vector<VrHelpItem>) list;
\r
330 } else if (obj instanceof Hashtable) {
\r
331 Vector<VrHelpItem> newList = new Vector<VrHelpItem>();
\r
332 for (Object hashObj : list) {
\r
333 newList.add(new VrHelpItem((Hashtable)hashObj));
\r
345 * a Vector representing a suggested VR Help Items to display
\r
346 * on-screen during Perform Interaction<br/>
\r
347 * If omitted on supported displays, the default SMARTDEVICELINK generated
\r
348 * list of suggested choices will be displayed
\r
350 * <b>Notes: </b>Min=1; Max=100
\r
351 * @since SmartDeviceLink 2.0
\r
353 public void setVrHelp(Vector<VrHelpItem> vrHelp) {
\r
354 if (vrHelp != null) {
\r
355 parameters.put(Names.vrHelp, vrHelp);
\r
357 parameters.remove(Names.vrHelp);
\r