Class JSONScriptUtil


  • public class JSONScriptUtil
    extends Object
    Writes a set of scripts to a configuration object. So this gets a QDLScript and converts it to JSON, then places it in a JSON scripts object.

    Created by Jeff Gaynor
    on 2/12/20 at 2:01 PM

    • Field Detail

      • SCRIPTS_TAG

        public static String SCRIPTS_TAG
    • Constructor Detail

      • JSONScriptUtil

        public JSONScriptUtil()
    • Method Detail

      • createConfig

        public static net.sf.json.JSONObject createConfig()
        Creates a brand new, empty scripts entry for the QDL configuration.
        Returns:
      • addScript

        public static net.sf.json.JSONObject addScript​(net.sf.json.JSONObject scripts,
                                                       QDLScript script)
        Add a single QDLScript to the set of JSON object of scripts. This gets (minimally)
              {"scripts":[script,script,...]}
          
        (so if there are other tags, it ignores them and only works with this one tag) Note that it will replace the same named script.
        Parameters:
        scripts -
        script -
      • addScript

        public static net.sf.json.JSONObject addScript​(net.sf.json.JSONObject scripts,
                                                       net.sf.json.JSONObject j)
        Adds the already serialized script to the configuration object So first arg input is
             {"key0":"value0","key1":"value1",...,"scripts":[ array of scripts ]}
         
        and the second argument is just a script to go the array
             {"script":{"id":..., ... }}
         
        This should only update the scripts' array
        Parameters:
        scripts -
        j -
        Returns:
        updated first argument
      • removeScript

        public net.sf.json.JSONObject removeScript​(net.sf.json.JSONObject scripts,
                                                   String id)
        removes a script from a set with a given id. So input is
             {"scripts":{[
               {"script":{"id0":...}},
               {"script":{"id1":...}},
               {"script":{"id2":...}},...
               ]}}
         
        And if e.g. "id1" is passed in, it is removed.
        Parameters:
        scripts -
        id -
      • main

        public static void main​(String[] args)