public String build ( ) { StringBuilder scriptBuilder = new StringBuilder ( ) ; StringBuilder scriptBody = new StringBuilder ( ) ; String importStmt = "import " ; try { if ( scriptCode . contains ( importStmt ) ) { BufferedReader reader = new BufferedReader ( new StringReader ( scriptCode ) ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { if ( line . trim ( ) . startsWith ( importStmt ) ) { scriptBuilder . append ( line ) ; scriptBuilder . append ( "\n" ) ; } else { scriptBody . append ( ( scriptBody . length ( ) == 0 ? "" : "\n" ) ) ; scriptBody . append ( line ) ; } } } else { scriptBody . append ( scriptCode ) ; } } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to construct script from template" , e ) ; } scriptBuilder . append ( scriptHead ) ; scriptBuilder . append ( scriptBody . toString ( ) ) ; scriptBuilder . append ( scriptTail ) ; return scriptBuilder . toString ( ) ; }
Builds the final script .