private void doLines ( int levelC , LineReader lineReader , boolean batch ) throws IOException { if ( levelC > 20 ) { System . out . print ( "Ignoring possible recursion after including 20 times" ) ; return ; } while ( true ) { String line = lineReader . getNextLine ( DEFAULT_PROMPT ) ; if ( line == null ) { break ; } // skip blank lines and comments if ( line . length ( ) == 0 || line . startsWith ( "#" ) || line . startsWith ( "//" ) ) { continue ; } if ( batch ) { // if we are in batch mode, spit out the line we just read System . out . println ( "> " + line ) ; } String [ ] lineParts = line . split ( " " ) ; String command = lineParts [ 0 ] ; if ( command . startsWith ( HELP_COMMAND ) ) { helpOutput ( ) ; } else if ( command . startsWith ( "objects" ) ) { listBeans ( lineParts ) ; } else if ( command . startsWith ( "run" ) ) { if ( lineParts . length == 2 ) { runScript ( lineParts [ 1 ] , levelC ) ; } else { System . out . println ( "Error. Usage: run script" ) ; } } else if ( command . startsWith ( "attrs" ) ) { listAttributes ( lineParts ) ; } else if ( command . startsWith ( "get" ) ) { if ( lineParts . length == 2 ) { getAttributes ( lineParts ) ; } else { getAttribute ( lineParts ) ; } } else if ( command . startsWith ( "set" ) ) { setAttribute ( lineParts ) ; } else if ( command . startsWith ( "opers" ) || command . startsWith ( "ops" ) ) { listOperations ( lineParts ) ; } else if ( command . startsWith ( "dolines" ) ) { invokeOperationLines ( lineReader , lineParts , batch ) ; } else if ( command . startsWith ( "do" ) ) { invokeOperation ( lineParts ) ; } else if ( command . startsWith ( "sleep" ) ) { if ( lineParts . length == 2 ) { try { Thread . sleep ( Long . parseLong ( lineParts [ 1 ] ) ) ; } catch ( NumberFormatException e ) { System . out . println ( "Error. Usage: sleep millis, invalid millis number '" + lineParts [ 1 ] + "'" ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; return ; } } else { System . out . println ( "Error. Usage: sleep millis" ) ; } } else if ( command . startsWith ( "examples" ) ) { exampleOutput ( ) ; } else if ( command . startsWith ( "quit" ) ) { break ; } else { System . out . println ( "Error. Unknown command. Type '" + HELP_COMMAND + "' for help: " + command ) ; } } }
Do the lines from the reader . This might go recursive if we run a script .