Convert project from AJSC to Spring Boot
[aai/model-loader.git] / src / main / java / org / onap / aai / modelloader / util / JsonXmlConverter.java
index 29a4409..48a33b5 100644 (file)
@@ -1,22 +1,22 @@
 /**\r
- * ============LICENSE_START==========================================\r
+ * ============LICENSE_START=======================================================\r
  * org.onap.aai\r
- * ===================================================================\r
+ * ================================================================================\r
  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
- * Copyright © 2017-2018 Amdocs\r
- * ===================================================================\r
+ * Copyright © 2017-2018 European Software Marketing Ltd.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
  *\r
- *        http://www.apache.org/licenses/LICENSE-2.0\r
+ *       http://www.apache.org/licenses/LICENSE-2.0\r
  *\r
  * Unless required by applicable law or agreed to in writing, software\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * ============LICENSE_END============================================\r
+ * ============LICENSE_END=========================================================\r
  */\r
 package org.onap.aai.modelloader.util;\r
 \r
@@ -27,53 +27,48 @@ import org.json.XML;
 \r
 public class JsonXmlConverter {\r
 \r
-  /**\r
-   * Determines whether or not the supplied text string represents a valid\r
-   * JSON structure or not.\r
-   * \r
-   * @param text - The text to be evaluated.\r
-   * \r
-   * @return - true if the string represents a valid JSON object,\r
-   *           false, otherwise.\r
-   */\r
-  public static boolean isValidJson(String text) {\r
-    try {\r
-      new JSONObject(text);\r
-    } catch (JSONException ex) {\r
-      try {\r
-        new JSONArray(text);\r
-      } catch (JSONException ex1) {\r
-        return false;\r
-      }\r
+    private JsonXmlConverter() {\r
+        throw new AssertionError("Instantiating utility class.");\r
     }\r
 \r
-    return true;\r
-  }\r
+    /**\r
+     * Determines whether or not the supplied text string represents a valid JSON structure or not.\r
+     * \r
+     * @param text The text to be evaluated.\r
+     * @return - true if the string represents a valid JSON object, false, otherwise.\r
+     */\r
+    public static boolean isValidJson(String text) {\r
+        try {\r
+            new JSONObject(text);\r
+        } catch (JSONException ex) {\r
+            try {\r
+                new JSONArray(text);\r
+            } catch (JSONException ex1) {\r
+                return false;\r
+            }\r
+        }\r
 \r
-  /**\r
-   * Takes a text string representing a valid JSON structure and converts it to\r
-   * an equivalent XML string.\r
-   * \r
-   * @param jsonText - The JSON string to convert to XML.\r
-   * \r
-   * @return - An XML string representation of the supplied JSON string.\r
-   */\r
-  public static String convertJsonToXml(String jsonText) {\r
-    JSONObject jsonObj = new JSONObject(jsonText);\r
-    String xmlText = XML.toString(jsonObj);\r
-    return xmlText;\r
-  }\r
+        return true;\r
+    }\r
+\r
+    /**\r
+     * Takes a text string representing a valid JSON structure and converts it to an equivalent XML string.\r
+     * \r
+     * @param jsonText The JSON string to convert to XML.\r
+     * @return an XML string representation of the supplied JSON string.\r
+     */\r
+    public static String convertJsonToXml(String jsonText) {\r
+        return XML.toString(new JSONObject(jsonText));\r
+    }\r
 \r
-  /**\r
-   * Takes a text string representing a valid XML structure and converts it to\r
-   * an equivalent JSON string.\r
-   * \r
-   * @param xmlText - The XML string to convert to JSON.\r
-   * \r
-   * @return - A JSON string representation of the supplied XML string.\r
-   */\r
-  public static String convertXmlToJson(String xmlText) {\r
-    JSONObject jsonObj = XML.toJSONObject(xmlText);\r
-    return jsonObj.toString();\r
-  }\r
+    /**\r
+     * Takes a text string representing a valid XML structure and converts it to an equivalent JSON string.\r
+     * \r
+     * @param xmlText The XML string to convert to JSON.\r
+     * @return a JSON string representation of the supplied XML string.\r
+     */\r
+    public static String convertXmlToJson(String xmlText) {\r
+        JSONObject jsonObj = XML.toJSONObject(xmlText);\r
+        return jsonObj.toString();\r
+    }\r
 }\r