Class CodeModifier


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

      Fields 
      Modifier and Type Field Description
      static java.lang.String[] DOJO_LOCALES
      The Dojo supported locales used for "extraLocales".
      static java.util.Set<java.lang.String> dojoLocales
      The hash set with Dojo locales.
    • Constructor Summary

      Constructors 
      Constructor Description
      CodeModifier()
      Constructor with the settings.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String createSource_Build_JSON​(RuntimeBuilderSettings settings, java.io.File appDir, boolean isVerbose)
      Creates the "build.json" file.
      java.io.File getClassPath​(java.lang.Class<?> clazz)
      Gets the classpath from a class.
      static java.lang.String getDojoLanguageCode​(java.lang.String languageCode)
      Gets the locale that matches the Dojo locale if possible.
      java.io.File getFile​(java.lang.String name)
      Gets a file from the resources.
      java.util.Map<java.lang.String,​java.lang.String> getLanguageStringsMap​(RuntimeBuilderSettings settings)
      Gets the English language strings required in "msg.js" for internal build or "msg-customized.js" for customized iiziRun's.
      java.util.zip.ZipFile getZipFile​(java.lang.String name)
      Gets a ZIP file from the resources.
      static java.util.List<com.iizix.run.common.CodeModifier.Texts> loadTextFile​(java.io.File dir)
      Loads the localized text entries from the files.
      protected java.net.URL resolve​(java.net.URL url)
      Resolves the resources/dojo.zip from the URL.
      java.util.List<com.iizix.run.common.CodeModifier.Texts> writeTextFile​(java.io.File dir, RuntimeBuilderSettings settings)
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DOJO_LOCALES

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

        public static final java.util.Set<java.lang.String> dojoLocales
        The hash set with Dojo locales.
    • Constructor Detail

      • CodeModifier

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

      • getDojoLanguageCode

        public static java.lang.String getDojoLanguageCode​(java.lang.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 java.net.URL resolve​(java.net.URL url)
                                throws java.io.IOException
        Resolves the resources/dojo.zip from the URL.
        Parameters:
        url - to the file "dojo.zip" in resources directory.
        Returns:
        The resolved URL.
        Throws:
        java.io.IOException - For I/O errors.
      • getClassPath

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

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

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

        public java.util.Map<java.lang.String,​java.lang.String> getLanguageStringsMap​(RuntimeBuilderSettings settings)
                                                                                     throws java.io.FileNotFoundException,
                                                                                            java.io.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:
        java.io.IOException - For file errors.
        java.io.FileNotFoundException
      • writeTextFile

        public java.util.List<com.iizix.run.common.CodeModifier.Texts> writeTextFile​(java.io.File dir,
                                                                                     RuntimeBuilderSettings settings)
                                                                              throws java.io.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:
        java.io.IOException - For file errors.
      • loadTextFile

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

        public java.lang.String createSource_Build_JSON​(RuntimeBuilderSettings settings,
                                                        java.io.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.