SDL_Android/SmartDeviceLinkAndroidProxy - added the correct version of the proxy
[profile/ivi/smartdevicelink.git] / SDL_Android / SmartDeviceLinkProxyAndroid / src / com / smartdevicelink / proxy / rpc / TextField.java
1 package com.smartdevicelink.proxy.rpc;\r
2 \r
3 import java.util.Hashtable;\r
4 \r
5 import com.smartdevicelink.proxy.RPCStruct;\r
6 import com.smartdevicelink.proxy.constants.Names;\r
7 import com.smartdevicelink.proxy.rpc.enums.CharacterSet;\r
8 import com.smartdevicelink.proxy.rpc.enums.TextFieldName;\r
9 import com.smartdevicelink.util.DebugTool;\r
10 \r
11 /**\r
12  * Struct defining the characteristics of a displayed field on the HMI.\r
13  * <p><b> Parameter List\r
14  * <table border="1" rules="all">\r
15  *              <tr>\r
16  *                      <th>Name</th>\r
17  *                      <th>Type</th>\r
18  *                      <th>Description</th>\r
19  *                      <th>SmartDeviceLink Ver. Available</th>\r
20  *              </tr>\r
21  *              <tr>\r
22  *                      <td>name</td>\r
23  *                      <td>TextFieldName</td>\r
24  *                      <td>Enumeration identifying the field.  </td>\r
25  *                      <td>SmartDeviceLink 1.0</td>\r
26  *              </tr>\r
27  *              <tr>\r
28  *                      <td>characterSet</td>\r
29  *                      <td>CharacterSet</td>\r
30  *                      <td>The character set that is supported in this field.  </td>\r
31  *                      <td>SmartDeviceLink 1.0</td>\r
32  *              </tr>\r
33  *              <tr>\r
34  *                      <td>width</td>\r
35  *                      <td>Int16</td>\r
36  *                      <td>The number of characters in one row of this field.\r
37  *                                      <ul>\r
38  *                                      <li>Minvalue="1"</li>\r
39  *                                      <li>maxvalue="500"</li>\r
40  *                                      </ul>\r
41  *                      </td>\r
42  *                      <td>SmartDeviceLink 1.0</td>\r
43  *              </tr>\r
44  *              <tr>\r
45  *                      <td>rows</td>\r
46  *                      <td>Int16</td>\r
47  *                      <td>The number of rows for this text field.\r
48  *                                      <ul>\r
49  *                                      <li>Minvalue="1"</li>\r
50  *                                      <li>maxvalue="3"</li>\r
51  *                                      </ul>\r
52  *                      </td>\r
53  *                      <td>SmartDeviceLink 1.0</td>\r
54  *              </tr>\r
55  *  </table>\r
56  * @since SmartDeviceLink 1.0\r
57  */\r
58 public class TextField extends RPCStruct {\r
59         /**\r
60          * Constructs a newly allocated TextField object\r
61          */\r
62     public TextField() { }\r
63     /**\r
64      * Constructs a newly allocated TextField object indicated by the Hashtable parameter\r
65      * @param hash The Hashtable to use\r
66      */    \r
67     public TextField(Hashtable hash) {\r
68         super(hash);\r
69     }\r
70     /**\r
71      * Get the enumeration identifying the field.       \r
72      * @return the name of TextField\r
73      */    \r
74     public TextFieldName getName() {\r
75         Object obj = store.get(Names.name);\r
76         if (obj instanceof TextFieldName) {\r
77             return (TextFieldName) obj;\r
78         } else if (obj instanceof String) {\r
79             TextFieldName theCode = null;\r
80             try {\r
81                 theCode = TextFieldName.valueForString((String) obj);\r
82             } catch (Exception e) {\r
83                 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.name, e);\r
84             }\r
85             return theCode;\r
86         }\r
87         return null;\r
88     }\r
89     /**\r
90      * Set the enumeration identifying the field.       \r
91      * @param name the name of TextField\r
92      */    \r
93     public void setName( TextFieldName name ) {\r
94         if (name != null) {\r
95             store.put(Names.name, name );\r
96         }\r
97     }\r
98     /**\r
99      * Get the character set that is supported in this field.\r
100      * @return the character set\r
101      */    \r
102     public CharacterSet getCharacterSet() {\r
103         Object obj = store.get(Names.characterSet);\r
104         if (obj instanceof CharacterSet) {\r
105             return (CharacterSet) obj;\r
106         } else if (obj instanceof String) {\r
107             CharacterSet theCode = null;\r
108             try {\r
109                 theCode = CharacterSet.valueForString((String) obj);\r
110             } catch (Exception e) {\r
111                 DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + Names.characterSet, e);\r
112             }\r
113             return theCode;\r
114         }\r
115         return null;\r
116     }\r
117     /**\r
118      * Set the character set that is supported in this field.\r
119      * @param characterSet - the character set\r
120      */    \r
121     public void setCharacterSet( CharacterSet characterSet ) {\r
122         if (characterSet != null) {\r
123             store.put(Names.characterSet, characterSet );\r
124         }\r
125     }\r
126     /**\r
127      * Get the number of characters in one row of this field.\r
128      *                                  <ul>\r
129      *                                  <li>Minvalue="1"</li>\r
130      *                                  <li>maxvalue="500"</li>\r
131      *                                  </ul>\r
132      * @return the number of characters in one row of this field\r
133      */    \r
134     public Integer getWidth() {\r
135         return (Integer) store.get( Names.width );\r
136     }\r
137     /**\r
138      * Set the number of characters in one row of this field.\r
139      *                                  <ul>\r
140      *                                  <li>Minvalue="1"</li>\r
141      *                                  <li>maxvalue="500"</li>\r
142      *                                  </ul>\r
143      * @param width  the number of characters in one row of this field\r
144      */    \r
145     public void setWidth( Integer width ) {\r
146         if (width != null) {\r
147             store.put(Names.width, width );\r
148         }\r
149     }\r
150     /**\r
151      *Get the number of rows for this text field.\r
152      *                                  <ul>\r
153      *                                  <li>Minvalue="1"</li>\r
154      *                                  <li>maxvalue="3"</li>\r
155      *                                  </ul>\r
156      * @return  the number of rows for this text field\r
157      */    \r
158     public Integer getRows() {\r
159         return (Integer) store.get( Names.rows );\r
160     }\r
161     public void setRows( Integer rows ) {\r
162         if (rows != null) {\r
163             store.put(Names.rows, rows );\r
164         }\r
165     }\r
166 }\r