SDL_Android/SmartDeviceLinkAndroidProxy - added the correct version of the proxy
[profile/ivi/smartdevicelink.git] / SDL_Android / SmartDeviceLinkProxyAndroid / src / com / smartdevicelink / proxy / rpc / UnsubscribeButton.java
1 package com.smartdevicelink.proxy.rpc;\r
2 \r
3 import java.util.Hashtable;\r
4 \r
5 import com.smartdevicelink.proxy.RPCRequest;\r
6 import com.smartdevicelink.proxy.constants.Names;\r
7 import com.smartdevicelink.proxy.rpc.enums.ButtonName;\r
8 import com.smartdevicelink.util.DebugTool;\r
9 \r
10 /**\r
11  * Deletes a subscription to button notifications for the specified button. For\r
12  * more information about button subscriptions, see {@linkplain SubscribeButton}\r
13  * <p>\r
14  * Application can unsubscribe from a button that is currently being pressed\r
15  * (i.e. has not yet been released), but app will not get button event\r
16  * <p>\r
17  * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b>\r
18  * <p>\r
19  * \r
20  * @since SmartDeviceLink 1.0\r
21  * @see SubscribeButton\r
22  */\r
23 public class UnsubscribeButton extends RPCRequest {\r
24 \r
25         /**\r
26          * Constructs a new UnsubscribeButton object\r
27          */    \r
28         public UnsubscribeButton() {\r
29         super("UnsubscribeButton");\r
30     }\r
31         /**\r
32          * Constructs a new UnsubscribeButton object indicated by the Hashtable\r
33          * parameter\r
34          * <p>\r
35          * \r
36          * @param hash\r
37          *            The Hashtable to use\r
38          */     \r
39     public UnsubscribeButton(Hashtable hash) {\r
40         super(hash);\r
41     }\r
42         /**\r
43          * Gets a name of the button to unsubscribe from\r
44          * \r
45          * @return ButtonName -an Enumeration value, see <i>\r
46          *         {@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonName}</i>\r
47          */    \r
48     public ButtonName getButtonName() {\r
49         Object obj = parameters.get(Names.buttonName);\r
50         if (obj instanceof ButtonName) {\r
51             return (ButtonName) obj;\r
52         } else if (obj instanceof String) {\r
53             ButtonName theCode = null;\r
54             try {\r
55                 theCode = ButtonName.valueForString((String) obj);\r
56             } catch (Exception e) {\r
57                 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.buttonName, e);\r
58             }\r
59             return theCode;\r
60         }\r
61         return null;\r
62     }\r
63         /**\r
64          * Sets the name of the button to unsubscribe from\r
65          * \r
66          * @param buttonName\r
67          *            an enum value, see <i>\r
68          *            {@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonName}</i>\r
69          */    \r
70     public void setButtonName( ButtonName buttonName ) {\r
71         if (buttonName != null) {\r
72             parameters.put(Names.buttonName, buttonName );\r
73         }\r
74     }\r
75 }\r