public void processSource ( String [ ] filenames ) { for ( int i = 0 ; i != filenames . length ; ++ i ) { String filename = filenames [ i ] ; if ( ! filename . endsWith ( ".js" ) ) { addError ( "msg.extension.not.js" , filename ) ; return ; } File f = new File ( filename ) ; String source = readSource ( f ) ; if ( source == null ) return ; String mainClassName = targetName ; if ( mainClassName == null ) { String name = f . getName ( ) ; String nojs = name . substring ( 0 , name . length ( ) - 3 ) ; mainClassName = getClassName ( nojs ) ; } if ( targetPackage . length ( ) != 0 ) { mainClassName = targetPackage + "." + mainClassName ; } Object [ ] compiled = compiler . compileToClassFiles ( source , filename , 1 , mainClassName ) ; if ( compiled == null || compiled . length == 0 ) { return ; } File targetTopDir = null ; if ( destinationDir != null ) { targetTopDir = new File ( destinationDir ) ; } else { String parent = f . getParent ( ) ; if ( parent != null ) { targetTopDir = new File ( parent ) ; } } for ( int j = 0 ; j != compiled . length ; j += 2 ) { String className = ( String ) compiled [ j ] ; byte [ ] bytes = ( byte [ ] ) compiled [ j + 1 ] ; File outfile = getOutputFile ( targetTopDir , className ) ; try { FileOutputStream os = new FileOutputStream ( outfile ) ; try { os . write ( bytes ) ; } finally { os . close ( ) ; } } catch ( IOException ioe ) { addFormatedError ( ioe . toString ( ) ) ; } } } }
Compile JavaScript source .