SDL_Android/SmartDeviceLinkAndroidProxy - added the correct version of the proxy
[profile/ivi/smartdevicelink.git] / SDL_Android / SmartDeviceLinkProxyAndroid / src / com / smartdevicelink / proxy / rpc / ResetGlobalProperties.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.RPCRequest;\r
7 import com.smartdevicelink.proxy.constants.Names;\r
8 import com.smartdevicelink.proxy.rpc.enums.GlobalProperty;\r
9 import com.smartdevicelink.util.DebugTool;\r
10 /**\r
11  * Resets the passed global properties to their default values as defined by\r
12  * SMARTDEVICELINK\r
13  * <p>\r
14  * The HELPPROMPT global property default value is generated by SMARTDEVICELINK consists of\r
15  * the first vrCommand of each Command Menu item defined at the moment PTT is\r
16  * pressed<br/>\r
17  * The TIMEOUTPROMPT global property default value is the same as the HELPPROMPT\r
18  * global property default value\r
19  * <p>\r
20  * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b>\r
21  * </p>\r
22  * \r
23  * @since SmartDeviceLink 1.0\r
24  * @see SetGlobalProperties\r
25  */\r
26 public class ResetGlobalProperties extends RPCRequest {\r
27         /**\r
28          * Constructs a new ResetGlobalProperties object\r
29          */\r
30     public ResetGlobalProperties() {\r
31         super("ResetGlobalProperties");\r
32     }\r
33         /**\r
34          * Constructs a new ResetGlobalProperties object indicated by the Hashtable\r
35          * parameter\r
36          * <p>\r
37          * \r
38          * @param hash\r
39          *            The Hashtable to use\r
40          */    \r
41     public ResetGlobalProperties(Hashtable hash) {\r
42         super(hash);\r
43     }\r
44         /**\r
45          * Gets an array of one or more GlobalProperty enumeration elements\r
46          * indicating which global properties to reset to their default value\r
47          * \r
48          * @return Vector<GlobalProperty> -an array of one or more GlobalProperty\r
49          *         enumeration elements\r
50          */    \r
51     public Vector<GlobalProperty> getProperties() {\r
52         if (parameters.get(Names.properties) instanceof Vector<?>) {\r
53                 Vector<?> list = (Vector<?>)parameters.get(Names.properties);\r
54                 if (list != null && list.size() > 0) {\r
55                     Object obj = list.get(0);\r
56                     if (obj instanceof GlobalProperty) {\r
57                         return (Vector<GlobalProperty>) list;\r
58                     } else if (obj instanceof String) {\r
59                         Vector<GlobalProperty> newList = new Vector<GlobalProperty>();\r
60                         for (Object hashObj : list) {\r
61                             String strFormat = (String)hashObj;\r
62                             GlobalProperty toAdd = null;\r
63                             try {\r
64                                 toAdd = GlobalProperty.valueForString(strFormat);\r
65                             } catch (Exception e) {\r
66                                 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.properties, e);\r
67                             }\r
68                             if (toAdd != null) {\r
69                                 newList.add(toAdd);\r
70                             }\r
71                         }\r
72                         return newList;\r
73                     }\r
74                 }\r
75         }\r
76         return null;\r
77     }\r
78         /**\r
79          * Sets an array of one or more GlobalProperty enumeration elements\r
80          * indicating which global properties to reset to their default value\r
81          * \r
82          * @param properties\r
83          *            a Vector<GlobalProperty> An array of one or more\r
84          *            GlobalProperty enumeration elements indicating which global\r
85          *            properties to reset to their default value\r
86          *            <p>\r
87          *            <b>Notes: </b>Array must have at least one element\r
88          */    \r
89     public void setProperties( Vector<GlobalProperty> properties ) {\r
90         if (properties != null) {\r
91             parameters.put(Names.properties, properties );\r
92         }\r
93     }\r
94 }\r