Class JSONUtils

java.lang.Object
co.ecg.alpaca.core.framework.JSONUtils

@Component public class JSONUtils extends Object
A utility class for JSON handling
Version:
$Id: $Id
Author:
Matthew Keathley on 4/4/16.
  • Constructor Details

    • JSONUtils

      @Autowired public JSONUtils(AlpacaProperties alpacaProperties)

      Constructor for JSONUtils.

      Parameters:
      alpacaProperties - a AlpacaProperties object.
  • Method Details

    • getSerializerGSON

      public static com.google.gson.Gson getSerializerGSON()
      Retrieves a serializer GSON object for standard creation of JSON from Alpaca Objects
      Returns:
      The GSON object
    • getDeserializerGSON

      public static com.google.gson.Gson getDeserializerGSON() throws HelperException
      Throws:
      HelperException
    • getDeserializerGSON

      public static com.google.gson.Gson getDeserializerGSON(boolean prettyPrint) throws HelperException
      Throws:
      HelperException
    • getDeserializerGSON

      public static com.google.gson.Gson getDeserializerGSON(BroadWorksServer broadWorksServer, String sourceDefaultDomain, boolean isAdoptDestinationDefaultDomain) throws HelperException
      Retrieves a deserializer GSON object for standard deserialization of JSON to Alpaca Objects
      Parameters:
      broadWorksServer - The BroadWorksServer to deserialize into.
      sourceDefaultDomain - The SourceDefault domain if conversion is not expected
      isAdoptDestinationDefaultDomain - Flag to adopt the deserialized information to the new default domain of the provided BroadWorksServer
      Returns:
      The GSON object
      Throws:
      HelperException - Thrown if the BroadWorksServer or SourceDefaultDomain is null
    • getDeserializerGSON

      public static com.google.gson.Gson getDeserializerGSON(BroadWorksServer broadWorksServer) throws HelperException
      Retrieves a deserializer GSON object for standard deserialization of JSON to Alpaca Objects
      Parameters:
      broadWorksServer - The BroadWorksServer to deserialize into.
      Returns:
      The GSON object
      Throws:
      HelperException - if any.
    • outputBroadWorksInformation

      public static <T extends BroadWorksObjectInformation> void outputBroadWorksInformation(T information, FileWriter fileWriter) throws HelperException
      Outputs a BroadWorksObjectInformation class as JSON to the specified FileOutputStream
      Parameters:
      information - The input information
      fileWriter - The output stream for the generated JSON
      Throws:
      HelperException - Throw if an error occurs while outputting the information.
    • inputBroadWorksInformation

      public static <T extends BroadWorksObjectInformation> T inputBroadWorksInformation(Type type, FileReader fileReader, BroadWorksServer broadWorksServer) throws HelperException
      Imports a BroadWorksObjectInformation class from the specified File
      Parameters:
      type - The Information type
      fileReader - The file reader for the JSON object
      broadWorksServer - The BroadWorksServer to deserialize into.
      Returns:
      Returns a BroadWorksObjectInformation from the reader.
      Throws:
      HelperException - Throw if an error occurs on input.