public static ParseRecallResults parseRecallStatement ( String statement , int lineMax ) { Matcher matcher = RecallToken . matcher ( statement ) ; if ( matcher . matches ( ) ) { String commandWordTerminator = matcher . group ( 1 ) ; String lineNumberText = matcher . group ( 2 ) ; String error ; if ( OneWhitespace . matcher ( commandWordTerminator ) . matches ( ) ) { String trailings = matcher . group ( 3 ) + ";" + matcher . group ( 4 ) ; // In a valid command, both "trailings" groups should be empty. if ( trailings . equals ( ";" ) ) { try { int line = Integer . parseInt ( lineNumberText ) - 1 ; if ( line < 0 || line > lineMax ) { throw new NumberFormatException ( ) ; } // Return the recall line number. return new ParseRecallResults ( line ) ; } catch ( NumberFormatException e ) { error = "Invalid RECALL line number argument: '" + lineNumberText + "'" ; } } // For an invalid form of the command, // return an approximation of the garbage input. else { error = "Invalid RECALL line number argument: '" + lineNumberText + " " + trailings + "'" ; } } else if ( commandWordTerminator . equals ( "" ) || commandWordTerminator . equals ( ";" ) ) { error = "Incomplete RECALL command. RECALL expects a line number argument." ; } else { error = "Invalid RECALL command: a space and line number are required after 'recall'" ; } return new ParseRecallResults ( error ) ; } return null ; }
Parse RECALL statement for sqlcmd .