Class JoltCliUtilities


  • public class JoltCliUtilities
    extends java.lang.Object
    A utility class for the Jolt CLI tool.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object createJsonObjectFromFile​(java.io.File file, boolean suppressOutput)
      Uses the File to build a Map containing JSON data found in the file.
      static boolean printJsonObject​(java.lang.Object output, java.lang.Boolean uglyPrint, boolean suppressOutput)
      Prints the given json object to standard out, accounting for pretty printing and suppressed output.
      static void printToStandardOut​(java.lang.String output, boolean suppressOutput)
      Prints the given string to standard out, or doesn't, based on the suppressOutput flag
      static java.lang.Object readJsonInput​(java.io.File file, boolean suppressOutput)
      This method will read in JSON, either from the given file or from standard in if the file is null.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DIFFY_COMMAND_IDENTIFIER

        public static final java.lang.String DIFFY_COMMAND_IDENTIFIER
        See Also:
        Constant Field Values
      • SORT_COMMAND_IDENTIFIER

        public static final java.lang.String SORT_COMMAND_IDENTIFIER
        See Also:
        Constant Field Values
      • TRANSFORM_COMMAND_IDENTIFIER

        public static final java.lang.String TRANSFORM_COMMAND_IDENTIFIER
        See Also:
        Constant Field Values
    • Constructor Detail

      • JoltCliUtilities

        public JoltCliUtilities()
    • Method Detail

      • printToStandardOut

        public static void printToStandardOut​(java.lang.String output,
                                              boolean suppressOutput)
        Prints the given string to standard out, or doesn't, based on the suppressOutput flag
      • createJsonObjectFromFile

        public static java.lang.Object createJsonObjectFromFile​(java.io.File file,
                                                                boolean suppressOutput)
        Uses the File to build a Map containing JSON data found in the file. This method will System exit with an error code of 1 if has any trouble opening the file or the file did not contain properly formatted JSON (i.e. the JSON parser was unable to parse its contents)
        Returns:
        the Map containing the JSON data
      • printJsonObject

        public static boolean printJsonObject​(java.lang.Object output,
                                              java.lang.Boolean uglyPrint,
                                              boolean suppressOutput)
        Prints the given json object to standard out, accounting for pretty printing and suppressed output.
        Parameters:
        output - The object to print. This method will fail if this object is not well formed JSON.
        uglyPrint - ignore pretty print
        suppressOutput - suppress output to standard out
        Returns:
        true if printing operation was successful
      • readJsonInput

        public static java.lang.Object readJsonInput​(java.io.File file,
                                                     boolean suppressOutput)
        This method will read in JSON, either from the given file or from standard in if the file is null. An object contain the ingested input is returned.
        Parameters:
        file - the file to read the input from, or null to use standard in
        suppressOutput - suppress output of error messages to standard out
        Returns:
        Object containing input if successful or null if an error occured