SDL_Android/SmartDeviceLinkAndroidProxy - added the correct version of the proxy
[profile/ivi/smartdevicelink.git] / SDL_Android / SmartDeviceLinkProxyAndroid / src / com / smartdevicelink / proxy / rpc / Choice.java
1 package com.smartdevicelink.proxy.rpc;\r
2 \r
3 import java.util.Hashtable;\r
4 import java.util.Vector;\r
5 \r
6 import com.smartdevicelink.proxy.RPCStruct;\r
7 import com.smartdevicelink.proxy.constants.Names;\r
8 import com.smartdevicelink.util.DebugTool;\r
9 \r
10 /**\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
14  *              <tr>\r
15  *                      <th>Name</th>\r
16  *                      <th>Type</th>\r
17  *                      <th>Description</th>\r
18  *                      <th>SmartDeviceLink Ver. Available</th>\r
19  *              </tr>\r
20  *              <tr>\r
21  *                      <td>choiceID</td>\r
22  *                      <td>Int16</td>\r
23  *                      <td>Application-scoped identifier that uniquely identifies this choice.\r
24  *             <br/>Min: 0\r
25  *                              <br/>Max: 65535\r
26  *                      </td>\r
27  *                      <td>SmartDeviceLink 1.0</td>\r
28  *              </tr>\r
29  *              <tr>\r
30  *                      <td>menuName</td>\r
31  *                      <td>String</td>\r
32  *                      <td>Text which appears in menu, representing this choice.\r
33  *                              <br/>Min: 1\r
34  *                              <br/>Max: 100\r
35  *                      </td>\r
36  *                      <td>SmartDeviceLink 1.0</td>\r
37  *              </tr>\r
38  *     <tr>\r
39  *                      <td>vrCommands</td>\r
40  *                      <td>String[]</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
43  *              </tr>\r
44  *     <tr>\r
45  *                      <td>image</td>\r
46  *                      <td>Image</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
49  *              </tr>\r
50  * </table>\r
51  * \r
52   * @since SmartDeviceLink 1.0\r
53  */\r
54 public class Choice extends RPCStruct {\r
55         /**\r
56          * Constructs a newly allocated Choice object\r
57          */\r
58     public Choice() { }\r
59     /**\r
60      * Constructs a newly allocated Choice object indicated by the Hashtable parameter\r
61      * @param hash The Hashtable to use\r
62      */    \r
63     public Choice(Hashtable hash) {\r
64         super(hash);\r
65     }\r
66     /**\r
67      * Get the application-scoped identifier that uniquely identifies this choice.\r
68      * @return choiceID Min: 0  Max: 65535\r
69      */    \r
70     public Integer getChoiceID() {\r
71         return (Integer) store.get(Names.choiceID);\r
72     }\r
73     /**\r
74      * Set the application-scoped identifier that uniquely identifies this choice.\r
75      * @param choiceID Min: 0  Max: 65535\r
76      */    \r
77     public void setChoiceID(Integer choiceID) {\r
78         if (choiceID != null) {\r
79             store.put(Names.choiceID, choiceID);\r
80         }\r
81     }\r
82     /**\r
83      * Text which appears in menu, representing this choice.\r
84      *                          <br/>Min: 1\r
85      *                          <br/>Max: 100\r
86      * @return menuName the menu name\r
87      */    \r
88     public String getMenuName() {\r
89         return (String) store.get(Names.menuName);\r
90     }\r
91     /**\r
92      * Text which appears in menu, representing this choice.\r
93      *                          <br/>Min: 1\r
94      *                          <br/>Max: 100\r
95      * @param menuName the menu name\r
96      */    \r
97     public void setMenuName(String menuName) {\r
98         if (menuName != null) {\r
99             store.put(Names.menuName, menuName);\r
100         }\r
101     }\r
102     /**\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
106      */    \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
114                         }\r
115                 }\r
116         }\r
117         return null;\r
118     }\r
119     /**\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
123      */    \r
124     public void setVrCommands(Vector<String> vrCommands) {\r
125         if (vrCommands != null) {\r
126             store.put(Names.vrCommands, vrCommands);\r
127         }\r
128     }\r
129     /**\r
130      * Set the image\r
131      * @param image the image of the choice\r
132      */    \r
133     public void setImage(Image image) {\r
134         if (image != null) {\r
135             store.put(Names.image, image);\r
136         } else {\r
137                 store.remove(Names.image);\r
138         }\r
139     }\r
140     /**\r
141      * Get the image\r
142      * @return the image of the choice\r
143      */    \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
149                 try {\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
153             }\r
154         }\r
155         return null;\r
156     }\r
157 }\r