private static void createCode ( String packageName , String className , ObjectSchema schema , Set < SyntaxToJavaClass . ClassInfo > imports , File outputFile ) throws IOException , TemplateException { Configuration freeMarkerConfiguration = new Configuration ( ) ; freeMarkerConfiguration . setClassForTemplateLoading ( DEFAULT_LOADER_CLASS , "" ) ; freeMarkerConfiguration . setObjectWrapper ( new DefaultObjectWrapper ( ) ) ; // Build the model for FreeMarker Map < String , Object > model = new HashMap < String , Object > ( ) ; model . put ( "package" , packageName ) ; model . put ( "class" , className ) ; model . put ( "schema" , schema ) ; model . put ( "imports" , imports ) ; // Have FreeMarker process the model with the template Template template = freeMarkerConfiguration . getTemplate ( TEMPLATE_FILE ) ; if ( LOG . isDebugEnabled ( ) ) { Writer out = new OutputStreamWriter ( System . out ) ; template . process ( model , out ) ; out . flush ( ) ; } LOG . debug ( String . format ( "Writing java to: %1$s" , outputFile . getAbsolutePath ( ) ) ) ; FileOutputStream outputStream = new FileOutputStream ( outputFile ) ; Writer out = new OutputStreamWriter ( outputStream ) ; template . process ( model , out ) ; out . flush ( ) ; out . close ( ) ; }
Create the Java