private void runQuery ( String queryString , boolean getPatchSets , boolean getCurrentPatchSet , boolean getFiles , boolean getCommitMessage , boolean getComments , LineVisitor visitor ) throws GerritQueryException , SshException , IOException { StringBuilder str = new StringBuilder ( QUERY_COMMAND ) ; str . append ( " --format=JSON" ) ; if ( getPatchSets ) { str . append ( " --patch-sets" ) ; } if ( getCurrentPatchSet ) { str . append ( " --current-patch-set" ) ; } if ( getFiles ) { str . append ( " --files" ) ; } if ( getComments ) { str . append ( " --comments" ) ; } if ( getCommitMessage ) { str . append ( " --commit-message" ) ; } str . append ( " \"" ) . append ( queryString . replace ( ( CharSequence ) "\"" , ( CharSequence ) "\\\"" ) ) . append ( "\"" ) ; SshConnection ssh = null ; try { ssh = getConnection ( ) ; BufferedReader reader = new BufferedReader ( ssh . executeCommandReader ( str . toString ( ) ) ) ; String incomingLine = null ; while ( ( incomingLine = reader . readLine ( ) ) != null ) { logger . trace ( "Incoming line: {}" , incomingLine ) ; visitor . visit ( incomingLine ) ; } logger . trace ( "Closing reader." ) ; reader . close ( ) ; } finally { cleanupConnection ( ssh ) ; } }
Runs the query on the Gerrit server and lets the provided visitor handle each line in the result .