Package com.iizix.run.common
Class CodeModifier
java.lang.Object
com.iizix.run.common.CodeModifier
Class to help with JS code modification in order to match the app settings.
- Author:
- Christopher Mindus
Field Summary
Modifier and TypeFieldDescriptionstatic final String[]
The Dojo supported locales used for "extraLocales".The hash set with Dojo locales.Constructor Summary
Method Summary
Modifier and TypeMethodDescriptioncreateSource_Build_JSON
(RuntimeBuilderSettings settings, File appDir, boolean isVerbose) Creates the "build.json" file.getClassPath
(Class<?> clazz) Gets the classpath from a class.static String
getDojoLanguageCode
(String languageCode) Gets the locale that matches the Dojo locale if possible.Gets a file from the resources.getLanguageStringsMap
(RuntimeBuilderSettings settings) Gets the English language strings required in "msg.js" for internal build or "msg-customized.js" for customized iiziRun's.getZipFile
(String name) Gets a ZIP file from the resources.static List<com.iizix.run.common.CodeModifier.Texts>
loadTextFile
(File dir) Loads the localized text entries from the files.protected URL
Resolves the resources/dojo.zip from the URL.List<com.iizix.run.common.CodeModifier.Texts>
writeTextFile
(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.
Field Details
DOJO_LOCALES
The Dojo supported locales used for "extraLocales".dojoLocales
The hash set with Dojo locales.
Constructor Details
CodeModifier
Constructor with the settings.- Throws:
IOException
- If the resources directory cannot be found.
Method Details
getDojoLanguageCode
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
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
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
Gets a file from the resources.- Parameters:
name
- The name of the file.- Returns:
- The File.
- Throws:
IOException
- For I/O errors.
getZipFile
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.