Initial source code
[oam/tr069-adapter.git] / acs / cpe / src / main / java / org / commscope / tr069adapter / acs / cpe / rpc / GetParameterValuesResponse.java
1 /*\r
2  * ============LICENSE_START========================================================================\r
3  * ONAP : tr-069-adapter\r
4  * =================================================================================================\r
5  * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
6  * =================================================================================================\r
7  * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
8  * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
9  * may obtain a copy of the License at\r
10  *\r
11  * http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
14  * either express or implied. See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  * ===============LICENSE_END=======================================================================\r
17  */\r
18 \r
19 package org.commscope.tr069adapter.acs.cpe.rpc;\r
20 \r
21 import java.util.Map;\r
22 import java.util.Map.Entry;\r
23 \r
24 import javax.xml.soap.SOAPBodyElement;\r
25 import javax.xml.soap.SOAPException;\r
26 import javax.xml.soap.SOAPFactory;\r
27 \r
28 import org.commscope.tr069adapter.acs.cpe.TR069RPC;\r
29 \r
30 public class GetParameterValuesResponse extends TR069RPC {\r
31 \r
32   private static final long serialVersionUID = 6927206690856966492L;\r
33 \r
34   /** Creates a new instance of GetParameterValuesResponse */\r
35   public GetParameterValuesResponse() {\r
36     name = "GetParameterValuesResponse";\r
37   }\r
38 \r
39   protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {\r
40     logger.isDebugEnabled();\r
41   }\r
42 \r
43   protected void parseBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {\r
44     values = parseParamList(body, spf);\r
45   }\r
46 \r
47   private Map<String, String> values;\r
48 \r
49   public Integer getParamInt(String name) {\r
50     String v = values.get(name);\r
51     if (v != null) {\r
52       try {\r
53         return Integer.parseInt(v);\r
54       } catch (NumberFormatException e) {\r
55         logger.error("Exception while getParamInt detail {}", e.toString());\r
56       }\r
57     }\r
58     return null;\r
59   }\r
60 \r
61   public Integer getParamInt(String name, int defaultValue) {\r
62     Integer value = getParamInt(name);\r
63     return (value != null) ? value : defaultValue;\r
64   }\r
65 \r
66   public String getParam(String name) {\r
67     return values.get(name);\r
68   }\r
69 \r
70   public String getParam(String name, String defaultValue) {\r
71     String value = getParam(name);\r
72     return (value != null) ? value : defaultValue;\r
73   }\r
74 \r
75   public Map<String, String> getValues() {\r
76     return values;\r
77   }\r
78 \r
79   public void setValues(Map<String, String> values) {\r
80     this.values = values;\r
81   }\r
82 \r
83   @Override\r
84   public String toString() {\r
85     StringBuilder b = new StringBuilder(1024);\r
86     for (Entry<String, String> e : values.entrySet()) {\r
87       b.append(e.getKey());\r
88       b.append("=");\r
89       b.append(e.getValue());\r
90       b.append("\n");\r
91     }\r
92     return b.toString();\r
93   }\r
94 }\r