Class RuntimeBuilderUtilities
Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionstatic LinkedHashMap<String, String> getLanguageStringsMap(File file) Gets the English language strings required in "msg.js".
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 callingJSON.stringifyon the result -- that is, the engine performed the JavaScript to JSON conversion andJSONObjectonly parsed the outcome. That coupled the runtime builder to Nashorn throughGUnit.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
aobject thatCodeModifier.createSource_JS_Msgwrites 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 evaluatingwindow.izRun.M=...in an engine with no browser globals failed onwindowbefore 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 thefileis not found.IOException- For file errors, or if the file is not the singlewindow.izRun.Massignment the format requires.