Initial source code
[oam/tr069-adapter.git] / acs / cpe / src / main / java / org / commscope / tr069adapter / acs / cpe / rpc / GetParameterValuesResponse.java
diff --git a/acs/cpe/src/main/java/org/commscope/tr069adapter/acs/cpe/rpc/GetParameterValuesResponse.java b/acs/cpe/src/main/java/org/commscope/tr069adapter/acs/cpe/rpc/GetParameterValuesResponse.java
new file mode 100644 (file)
index 0000000..ddf3bc2
--- /dev/null
@@ -0,0 +1,94 @@
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+package org.commscope.tr069adapter.acs.cpe.rpc;\r
+\r
+import java.util.Map;\r
+import java.util.Map.Entry;\r
+\r
+import javax.xml.soap.SOAPBodyElement;\r
+import javax.xml.soap.SOAPException;\r
+import javax.xml.soap.SOAPFactory;\r
+\r
+import org.commscope.tr069adapter.acs.cpe.TR069RPC;\r
+\r
+public class GetParameterValuesResponse extends TR069RPC {\r
+\r
+  private static final long serialVersionUID = 6927206690856966492L;\r
+\r
+  /** Creates a new instance of GetParameterValuesResponse */\r
+  public GetParameterValuesResponse() {\r
+    name = "GetParameterValuesResponse";\r
+  }\r
+\r
+  protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {\r
+    logger.isDebugEnabled();\r
+  }\r
+\r
+  protected void parseBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException {\r
+    values = parseParamList(body, spf);\r
+  }\r
+\r
+  private Map<String, String> values;\r
+\r
+  public Integer getParamInt(String name) {\r
+    String v = values.get(name);\r
+    if (v != null) {\r
+      try {\r
+        return Integer.parseInt(v);\r
+      } catch (NumberFormatException e) {\r
+        logger.error("Exception while getParamInt detail {}", e.toString());\r
+      }\r
+    }\r
+    return null;\r
+  }\r
+\r
+  public Integer getParamInt(String name, int defaultValue) {\r
+    Integer value = getParamInt(name);\r
+    return (value != null) ? value : defaultValue;\r
+  }\r
+\r
+  public String getParam(String name) {\r
+    return values.get(name);\r
+  }\r
+\r
+  public String getParam(String name, String defaultValue) {\r
+    String value = getParam(name);\r
+    return (value != null) ? value : defaultValue;\r
+  }\r
+\r
+  public Map<String, String> getValues() {\r
+    return values;\r
+  }\r
+\r
+  public void setValues(Map<String, String> values) {\r
+    this.values = values;\r
+  }\r
+\r
+  @Override\r
+  public String toString() {\r
+    StringBuilder b = new StringBuilder(1024);\r
+    for (Entry<String, String> e : values.entrySet()) {\r
+      b.append(e.getKey());\r
+      b.append("=");\r
+      b.append(e.getValue());\r
+      b.append("\n");\r
+    }\r
+    return b.toString();\r
+  }\r
+}\r