Update License text
[vnfsdk/compliance.git] / veslibrary / ves_javalibrary / evel_javalib2 / src / evel_javalibrary / att / com / EvelOptionInt.java
1 package evel_javalibrary.att.com;\r
2 /**************************************************************************//**\r
3  * @file\r
4  * Evel Option Int class\r
5  *\r
6  * This file implements the Evel Option class to handle optional ont fields.\r
7  *\r
8  * License\r
9  * -------\r
10  * Unless otherwise specified, all software contained herein is\r
11   * Licensed under the Apache License, Version 2.0 (the "License");\r
12  * you may not use this file except in compliance with the License.\r
13  * You may obtain a copy of the License at\r
14  *        http://www.apache.org/licenses/LICENSE-2.0\r
15  *\r
16  * Unless required by applicable law or agreed to in writing, software\r
17  * distributed under the License is distributed on an "AS IS" BASIS,\r
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
19  * See the License for the specific language governing permissions and\r
20  * limitations under the License.\r
21  *****************************************************************************/\r
22 \r
23 import javax.json.JsonObjectBuilder;\r
24 \r
25 import org.apache.log4j.Logger;\r
26 /*\r
27  * Handles Optional Integer fields\r
28  */\r
29 public class EvelOptionInt extends EvelOption {\r
30 \r
31         /**************************************************************************//**\r
32          * Optional parameter holder for string.\r
33          *****************************************************************************/\r
34      int value;\r
35      \r
36      private static final Logger LOGGER = Logger.getLogger( EvelOptionInt.class.getName() );\r
37      \r
38          public EvelOptionInt()\r
39          {\r
40                  super(false);\r
41                  value = 0;\r
42          }\r
43          \r
44          public EvelOptionInt(boolean val, int str)\r
45          {\r
46                  super(val);\r
47                  value = str;\r
48          }\r
49          \r
50          public void InitValue()\r
51          {\r
52                  is_set = false;\r
53                  value = 0;\r
54          }\r
55          //Sets int value\r
56          public void SetValue(int str)\r
57          {\r
58                  is_set = true;\r
59                  value = str;\r
60          }\r
61          //Sets Integer value outputting debugging message\r
62          public void SetValuePr(int str, String mstr)\r
63          {\r
64                  \r
65                  is_set = true;\r
66                  value = str;   \r
67                  LOGGER.debug("Setting "+mstr+" to "+str);\r
68          }\r
69          \r
70          public int GetValue()\r
71          {\r
72                  return value;\r
73          }\r
74          /*\r
75           * Encoding JSON function\r
76           * @retval boolean returns option true if object is encoded\r
77           * with Integer value\r
78           */     \r
79          public boolean encJsonValue(JsonObjectBuilder obj, String name)\r
80          {\r
81                  //If option is set encodes int value into JSON object\r
82                  // with name tag\r
83                  if( is_set ) obj.add(name, value);\r
84                  return is_set;\r
85          }\r
86 \r
87 }\r
88 \r