Class CodeModifier

java.lang.Object
com.iizix.run.common.CodeModifier

public class CodeModifier extends Object
Class to help with JS code modification in order to match the app settings.
Author:
Christopher Mindus
  • Field Details

    • DOJO_LOCALES

      public static final String[] DOJO_LOCALES
      The Dojo supported locales used for "extraLocales".
    • dojoLocales

      public static final Set<String> dojoLocales
      The hash set with Dojo locales.
  • Constructor Details

    • CodeModifier

      public CodeModifier() throws IOException
      Constructor with the settings.
      Throws:
      IOException - If the resources directory cannot be found.
  • Method Details

    • getDojoLanguageCode

      public static String getDojoLanguageCode(String languageCode)
      Gets the locale that matches the Dojo locale if possible.
      Parameters:
      languageCode - The language code.
      Returns:
      The Dojo language code, or null for none.
    • resolve

      protected URL resolve(URL url) throws IOException
      Resolves the resources/dojo.zip from the URL.
      Parameters:
      url - to the file "dojo.zip" in resources directory.
      Returns:
      The resolved URL.
      Throws:
      IOException - For I/O errors.
    • getClassPath

      public File getClassPath(Class<?> clazz) throws IOException
      Gets the classpath from a class.
      Parameters:
      clazz - The class to check.
      Returns:
      The File for the classpath.
      Throws:
      IOException - For I/O errors.
    • getFile

      public File getFile(String name) throws IOException
      Gets a file from the resources.
      Parameters:
      name - The name of the file.
      Returns:
      The File.
      Throws:
      IOException - For I/O errors.
    • getZipFile

      public ZipFile getZipFile(String name) throws IOException
      Gets a ZIP file from the resources.
      Parameters:
      name - The name of the ZIP file.
      Returns:
      The ZipFile.
      Throws:
      IOException - For I/O errors.
    • getLanguageStringsMap

      public Map<String,String> getLanguageStringsMap(RuntimeBuilderSettings settings) throws FileNotFoundException, IOException
      Gets the English language strings required in "msg.js" for internal build or "msg-customized.js" for customized iiziRun's.
      Parameters:
      settings - The settings, null if normal customized iiziRun's.
      Returns:
      A new map of the strings, key is the text ID and the value is the text.
      Throws:
      IOException - For file errors.
      FileNotFoundException
    • writeTextFile

      public List<com.iizix.run.common.CodeModifier.Texts> writeTextFile(File dir, RuntimeBuilderSettings settings) throws IOException
      Writes all the text's used in the app, for all text tables into an UTF-8 encoded file that is read later on by the pre-build processor to Android, iOS or Android.
      Parameters:
      dir - The root directory where "config.xml" is located.
      settings - The settings.
      Throws:
      IOException - For file errors.
    • loadTextFile

      public static List<com.iizix.run.common.CodeModifier.Texts> loadTextFile(File dir) throws IOException
      Loads the localized text entries from the files.
      Parameters:
      dir - The app's root directory where "config.xml" is located.
      Throws:
      IOException - For file errors.
    • createSource_Build_JSON

      public String createSource_Build_JSON(RuntimeBuilderSettings settings, File appDir, boolean isVerbose)
      Creates the "build.json" file.
      Parameters:
      settings - The settings.
      appDir - The root of the Cordova app dir.
      Returns:
      null for success, otherwise an error message that has been logged already.