SDL_Android/SmartDeviceLinkAndroidProxy - added the correct version of the proxy
[profile/ivi/smartdevicelink.git] / SDL_Android / SmartDeviceLinkProxyAndroid / src / com / smartdevicelink / proxy / rpc / OnCommand.java
1 package com.smartdevicelink.proxy.rpc;\r
2 \r
3 import java.util.Hashtable;\r
4 \r
5 import com.smartdevicelink.proxy.RPCNotification;\r
6 import com.smartdevicelink.proxy.constants.Names;\r
7 import com.smartdevicelink.proxy.rpc.enums.TriggerSource;\r
8 import com.smartdevicelink.util.DebugTool;\r
9 \r
10 /**\r
11  * This is called when a command was selected via VR after pressing the PTT button, or selected from the menu after \r
12  * pressing the MENU button. <p>\r
13  * <b>Note: </b>Sequence of OnHMIStatus and OnCommand notifications for user-initiated interactions is indeterminate.\r
14  * <p></p>\r
15  * <b>HMI Status Requirements:</b>\r
16  * <ul>\r
17  * HMILevel: \r
18  * <ul><li>FULL,LIMITED</li></ul>\r
19  * AudioStreamingState: \r
20  * <ul><li>Any</li></ul>\r
21  * SystemContext: \r
22  * <ul><li>Any</li></ul>\r
23  * </ul>\r
24  * <p>\r
25  * <b>Parameter List:</b>\r
26  * <table  border="1" rules="all">\r
27  * <tr>\r
28  * <th>Name</th>\r
29  * <th>Type</th>\r
30  * <th>Description</th>\r
31  * <th>Notes</th>\r
32  * <th>Applink Ver Available</th>\r
33  * </tr>\r
34  * <tr>\r
35  * <td>cmdID</td>\r
36  * <td>Int32</td>\r
37  * <td>The cmdID of the command the user selected. This is the cmdID value provided by the application in the AddCommand operation that created the command.</td>\r
38  * <td></td>\r
39  * <td>SmartDeviceLink 1.0</td>\r
40  * </tr>\r
41  * <tr>\r
42  * <td>triggerSource</td>\r
43  * <td>{@linkplain TriggerSource}</td>\r
44  * <td>Indicates whether command was selected via VR or via a menu selection (using the OKbutton).</td>\r
45  * <td></td>\r
46  * <td>SmartDeviceLink 1.0</td>\r
47  * </tr>\r
48  * </table>\r
49  * </p>\r
50  * @since SmartDeviceLink 1.0\r
51  * @see AddCommand\r
52  * @see DeleteCommand\r
53  * @see DeleteSubMenu\r
54  */\r
55 public class OnCommand extends RPCNotification {\r
56         /**\r
57         *Constructs a newly allocated OnCommand object\r
58         */    \r
59     public OnCommand() {\r
60         super("OnCommand");\r
61     }\r
62     /**\r
63     *<p>Constructs a newly allocated OnCommand object indicated by the Hashtable parameter</p>\r
64     *@param hash The Hashtable to use\r
65     */    \r
66     public OnCommand(Hashtable hash) {\r
67         super(hash);\r
68     }\r
69     /**\r
70      * <p>Returns an <i>Integer</i> object representing the Command ID</p>\r
71      * @return Integer an integer representation of this object\r
72      */    \r
73     public Integer getCmdID() {\r
74         return (Integer) parameters.get( Names.cmdID );\r
75     }\r
76     /**\r
77      * <p>Sets a Command ID</p>    \r
78      * @param cmdID an integer object representing a Command ID\r
79      */    \r
80     public void setCmdID( Integer cmdID ) {\r
81         if (cmdID != null) {\r
82             parameters.put(Names.cmdID, cmdID );\r
83         }\r
84     }\r
85     /**\r
86      * <p>Returns a <I>TriggerSource</I> object which will be shown in the HMI</p>    \r
87      * @return TriggerSource a TriggerSource object\r
88      */    \r
89     public TriggerSource getTriggerSource() {\r
90         Object obj = parameters.get(Names.triggerSource);\r
91         if (obj instanceof TriggerSource) {\r
92             return (TriggerSource) obj;\r
93         } else if (obj instanceof String) {\r
94             TriggerSource theCode = null;\r
95             try {\r
96                 theCode = TriggerSource.valueForString((String) obj);\r
97             } catch (Exception e) {\r
98                 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.triggerSource, e);\r
99             }\r
100             return theCode;\r
101         }\r
102         return null;\r
103     }\r
104     /**\r
105      * <p>Sets TriggerSource<br/>\r
106      * Indicates whether command was selected via VR or via a menu selection (using the OK button).</p>    \r
107      * @param triggerSource a TriggerSource object\r
108      */    \r
109     public void setTriggerSource( TriggerSource triggerSource ) {\r
110         if (triggerSource != null) {\r
111             parameters.put(Names.triggerSource, triggerSource );\r
112         }\r
113     }\r
114 }\r