Revisions made to the Model Loader to use Babel
[aai/model-loader.git] / src / main / java / org / onap / aai / modelloader / util / JsonXmlConverter.java
index 29a4409..a5a7bc5 100644 (file)
@@ -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