1 package com.smartdevicelink.proxy.rpc;
\r
3 import java.util.Hashtable;
\r
4 import java.util.Vector;
\r
6 import com.smartdevicelink.proxy.RPCStruct;
\r
7 import com.smartdevicelink.proxy.constants.Names;
\r
8 import com.smartdevicelink.util.DebugTool;
\r
11 * A choice is an option which a user can select either via the menu or via voice recognition (VR) during an application initiated interaction.
\r
12 * <p><b> Parameter List
\r
13 * <table border="1" rules="all">
\r
17 * <th>Description</th>
\r
18 * <th>SmartDeviceLink Ver. Available</th>
\r
23 * <td>Application-scoped identifier that uniquely identifies this choice.
\r
27 * <td>SmartDeviceLink 1.0</td>
\r
32 * <td>Text which appears in menu, representing this choice.
\r
36 * <td>SmartDeviceLink 1.0</td>
\r
39 * <td>vrCommands</td>
\r
41 * <td>An array of strings to be used as VR synonyms for this choice. If this array is provided, it must have at least one non-empty element</td>
\r
42 * <td>SmartDeviceLink 1.0</td>
\r
47 * <td>Either a static hex icon value or a binary image file name identifier (sent by PutFile).</td>
\r
48 * <td>SmartDeviceLink 2.0</td>
\r
52 * @since SmartDeviceLink 1.0
\r
54 public class Choice extends RPCStruct {
\r
56 * Constructs a newly allocated Choice object
\r
60 * Constructs a newly allocated Choice object indicated by the Hashtable parameter
\r
61 * @param hash The Hashtable to use
\r
63 public Choice(Hashtable hash) {
\r
67 * Get the application-scoped identifier that uniquely identifies this choice.
\r
68 * @return choiceID Min: 0 Max: 65535
\r
70 public Integer getChoiceID() {
\r
71 return (Integer) store.get(Names.choiceID);
\r
74 * Set the application-scoped identifier that uniquely identifies this choice.
\r
75 * @param choiceID Min: 0 Max: 65535
\r
77 public void setChoiceID(Integer choiceID) {
\r
78 if (choiceID != null) {
\r
79 store.put(Names.choiceID, choiceID);
\r
83 * Text which appears in menu, representing this choice.
\r
86 * @return menuName the menu name
\r
88 public String getMenuName() {
\r
89 return (String) store.get(Names.menuName);
\r
92 * Text which appears in menu, representing this choice.
\r
95 * @param menuName the menu name
\r
97 public void setMenuName(String menuName) {
\r
98 if (menuName != null) {
\r
99 store.put(Names.menuName, menuName);
\r
103 * Get an array of strings to be used as VR synonyms for this choice. If this array is provided, it must have at least one non-empty element
\r
104 * @return vrCommands Vector
\r
105 * @since SmartDeviceLink 2.0
\r
107 public Vector<String> getVrCommands() {
\r
108 if (store.get(Names.vrCommands) instanceof Vector<?>) {
\r
109 Vector<?> list = (Vector<?>)store.get( Names.vrCommands);
\r
110 if (list != null && list.size() > 0) {
\r
111 Object obj = list.get(0);
\r
112 if (obj instanceof String) {
\r
113 return (Vector<String>) list;
\r
120 * Set an array of strings to be used as VR synonyms for this choice. If this array is provided, it must have at least one non-empty element
\r
121 * @param vrCommands the Vector of vrCommands
\r
122 * @since SmartDeviceLink 2.0
\r
124 public void setVrCommands(Vector<String> vrCommands) {
\r
125 if (vrCommands != null) {
\r
126 store.put(Names.vrCommands, vrCommands);
\r
131 * @param image the image of the choice
\r
133 public void setImage(Image image) {
\r
134 if (image != null) {
\r
135 store.put(Names.image, image);
\r
137 store.remove(Names.image);
\r
142 * @return the image of the choice
\r
144 public Image getImage() {
\r
145 Object obj = store.get(Names.image);
\r
146 if (obj instanceof Image) {
\r
147 return (Image) obj;
\r
148 } else if (obj instanceof Hashtable) {
\r
150 return new Image((Hashtable) obj);
\r
151 } catch (Exception e) {
\r
152 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.image, e);
\r