private static File codegenResourceModule(File resourceModuleFile,String[] locales,List bundleNames){
  String fileName=resourceModuleFile.getName();
  String className=fileName.substring(0,fileName.length() - 3);
  StandardDefs standardDefs=ThreadLocalToolkit.getStandardDefs();
  String lineSep=System.getProperty("line.separator");
  String[] codePieces=new String[]{"package ",lineSep,"{",lineSep,lineSep,"import flash.utils.getDefinitionByName",lineSep,"import ",standardDefs.getModulesPackage(),".ModuleBase;",lineSep,"import ",standardDefs.getResourcesPackage(),".IResourceModule;",lineSep,"import ",standardDefs.getResourcesPackage(),".ResourceBundle;",lineSep,lineSep,"[ExcludeClass]",lineSep,lineSep,codegenResourceBundleMetadata(bundleNames),lineSep,"public class ",className," extends ModuleBase",lineSep,"    implements IResourceModule",lineSep,"{",lineSep,"    private static var resourceBundleClassNames:Array /* of String */ =",lineSep,"    [",lineSep,codegenResourceBundleClassNames(locales,bundleNames),lineSep,"    ];",lineSep,lineSep,"    public function ",className,"()",lineSep,"    {",lineSep,"        super();",lineSep,"    }",lineSep,lineSep,"    private var _resourceBundles:Array /* of ResourceBundle */;",lineSep,lineSep,"    public function get resourceBundles():Array /* of ResourceBundle */",lineSep,"    {",lineSep,"        if (!_resourceBundles)",lineSep,"        {",lineSep,"            _resourceBundles = [];",lineSep,"            var n:int = resourceBundleClassNames.length;",lineSep,"            for (var i:int = 0; i < n; i++)",lineSep,"            {",lineSep,"                var resourceBundleClass:Class =",lineSep,"                    Class(getDefinitionByName(resourceBundleClassNames[i]));",lineSep,"                var resourceBundle:ResourceBundle = new resourceBundleClass();",lineSep,"                _resourceBundles.push(resourceBundle);",lineSep,"            }",lineSep,"        }",lineSep,lineSep,"        return _resourceBundles;",lineSep,"    }",lineSep,"}",lineSep,lineSep,"}",lineSep};
  String code=StringJoiner.join(codePieces,null);
  try {
    BufferedWriter bufferedWriter=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(resourceModuleFile),"UTF8"));
    bufferedWriter.write(code);
    bufferedWriter.close();
  }
 catch (  Exception e) {
  }
  return resourceModuleFile;
}

private static File codegenResourceModule ( File resourceModuleFile , String [ ] locales , List bundleNames ) { String fileName = resourceModuleFile . getName ( ) ; String className = fileName . substring ( 0 , fileName . length ( ) - 3 ) ; StandardDefs standardDefs = ThreadLocalToolkit . getStandardDefs ( ) ; String lineSep = System . getProperty ( "line.separator" ) ; String [ ] codePieces = new String [ ] { "package " , lineSep , "{" , lineSep , lineSep , "import flash.utils.getDefinitionByName" , lineSep , "import " , standardDefs . getModulesPackage ( ) , ".ModuleBase;" , lineSep , "import " , standardDefs . getResourcesPackage ( ) , ".IResourceModule;" , lineSep , "import " , standardDefs . getResourcesPackage ( ) , ".ResourceBundle;" , lineSep , lineSep , "[ExcludeClass]" , lineSep , lineSep , codegenResourceBundleMetadata ( bundleNames ) , lineSep , "public class " , className , " extends ModuleBase" , lineSep , "    implements IResourceModule" , lineSep , "{" , lineSep , "    private static var resourceBundleClassNames:Array /* of String */ =" , lineSep , "    [" , lineSep , codegenResourceBundleClassNames ( locales , bundleNames ) , lineSep , "    ];" , lineSep , lineSep , "    public function " , className , "()" , lineSep , "    {" , lineSep , "        super();" , lineSep , "    }" , lineSep , lineSep , "    private var _resourceBundles:Array /* of ResourceBundle */;" , lineSep , lineSep , "    public function get resourceBundles():Array /* of ResourceBundle */" , lineSep , "    {" , lineSep , "        if (!_resourceBundles)" , lineSep , "        {" , lineSep , "            _resourceBundles = [];" , lineSep , "            var n:int = resourceBundleClassNames.length;" , lineSep , "            for (var i:int = 0; i < n; i++)" , lineSep , "            {" , lineSep , "                var resourceBundleClass:Class =" , lineSep , "                    Class(getDefinitionByName(resourceBundleClassNames[i]));" , lineSep , "                var resourceBundle:ResourceBundle = new resourceBundleClass();" , lineSep , "                _resourceBundles.push(resourceBundle);" , lineSep , "            }" , lineSep , "        }" , lineSep , lineSep , "        return _resourceBundles;" , lineSep , "    }" , lineSep , "}" , lineSep , lineSep , "}" , lineSep } ; String code = StringJoiner . join ( codePieces , null ) ; try { BufferedWriter bufferedWriter = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( resourceModuleFile ) , "UTF8" ) ) ; bufferedWriter . write ( code ) ; bufferedWriter . close ( ) ; } catch ( Exception e ) { } return resourceModuleFile ; }
generate the as resource module for the given locales and bundle names .
