public static void main ( String [ ] args ) { String modelFile = "" ; String outputFile = "" ; int numberOfRows = 0 ; try { modelFile = args [ 0 ] ; outputFile = args [ 1 ] ; numberOfRows = Integer . valueOf ( args [ 2 ] ) ; } catch ( IndexOutOfBoundsException | NumberFormatException e ) { System . out . println ( "ERROR! Invalid command line arguments, expecting: <scxml model file> " + "<desired csv output file> <desired number of output rows>" ) ; return ; } FileInputStream model = null ; try { model = new FileInputStream ( modelFile ) ; } catch ( FileNotFoundException e ) { System . out . println ( "ERROR! Model file not found" ) ; return ; } SCXMLEngine engine = new SCXMLEngine ( ) ; engine . setModelByInputFileStream ( model ) ; engine . setBootstrapMin ( 5 ) ; DataConsumer consumer = new DataConsumer ( ) ; CSVFileWriter writer ; try { writer = new CSVFileWriter ( outputFile ) ; } catch ( IOException e ) { System . out . println ( "ERROR! Can not write to output csv file" ) ; return ; } consumer . addDataWriter ( writer ) ; DefaultDistributor dist = new DefaultDistributor ( ) ; dist . setThreadCount ( 5 ) ; dist . setMaxNumberOfLines ( numberOfRows ) ; dist . setDataConsumer ( consumer ) ; engine . process ( dist ) ; writer . closeCSVFile ( ) ; System . out . println ( "COMPLETE!" ) ; }
Main method handles all the setup tasks for DataGenerator a user would normally do themselves