Class RuntimeBuilderUtilities

java.lang.Object
com.iizix.run.RuntimeBuilderUtilities

public class RuntimeBuilderUtilities extends Object
  • Constructor Details

    • RuntimeBuilderUtilities

      public RuntimeBuilderUtilities()
  • Method Details

    • getLanguageStringsMap

      public static LinkedHashMap<String,String> getLanguageStringsMap(File file) throws FileNotFoundException, IOException
      Gets the English language strings required in "msg.js".

      The file is a JavaScript object literal, NOT JSON: the keys are unquoted identifiers, the values are single-quoted strings, and // comments separate the groups. It used to be read by handing the whole file to a JavaScript engine, evaluating it and calling JSON.stringify on the result -- that is, the engine performed the JavaScript to JSON conversion and JSONObject only parsed the outcome. That coupled the runtime builder to Nashorn through GUnit.getScriptEngine(), a units class that has nothing to do with language strings, and it is parsed directly here instead.

      Non-string values are not represented. The result is a flat map of text ID to text, so a value that is not a string has nowhere to go. The only one that occurs is the nested a object that CodeModifier.createSource_JS_Msg writes into a GENERATED "msg.js", holding every non-default localisation: legitimate content that this consumer does not want. It is skipped. Any OTHER non-string shape throws rather than being dropped quietly, because a shape nobody has seen before is far more likely to be a mistake than an intended omission.

      That throw is deliberate. Do not soften it to a skip. Silently dropping an unrecognised value would lose a text ID with no signal anywhere -- no exception, no log line, and a text table that is quietly short of an entry. That is the exact failure class this method was rewritten to stop producing, so failing loudly on an unknown shape is the feature, not an oversight to be tidied away later.

      Note that skipping it is a widening: the previous implementation could not read a generated "msg.js" at all. Such a file is a single line, so the window.izRun.M= substitution the old code relied on never matched, and evaluating window.izRun.M=... in an engine with no browser globals failed on window before the nested object was ever reached.

      Parameters:
      file - The "msg.js" file.
      Returns:
      A new map of the strings, key is the text ID and the value is the text, in file order -- the order is observable, as it becomes the order of a generated text table.
      Throws:
      FileNotFoundException - If the file is not found.
      IOException - For file errors, or if the file is not the single window.izRun.M assignment the format requires.