void generateClassCode ( Definition def , String className , String subDir ) { if ( className == null || className . equals ( "" ) ) return ; try { String clazzName = this . getClass ( ) . getPackage ( ) . getName ( ) + ".code." + className + "CodeGen" ; String javaFile = Definition . class . getMethod ( "get" + className + "Class" ) . invoke ( def , ( Object [ ] ) null ) + ".java" ; FileWriter fw ; if ( subDir == null ) fw = Utils . createSrcFile ( javaFile , def . getRaPackage ( ) , def . getOutputDir ( ) ) ; else fw = Utils . createSrcFile ( javaFile , def . getRaPackage ( ) + "." + subDir , def . getOutputDir ( ) ) ; Class < ? > clazz = Class . forName ( clazzName , true , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; AbstractCodeGen codeGen = ( AbstractCodeGen ) clazz . newInstance ( ) ; codeGen . generate ( def , fw ) ; fw . flush ( ) ; fw . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } }
generate class code