question: private void addToBuffer ( ) { if ( list != null && ! list . isEmpty ( ) ) { ChronoIndexData info ; Collections . sort ( list ) ; StringBuilder reverseMapping = new StringBuilder ( ) ; int size = list . size ( ) ; for ( int i = 1 ; i <= size ; i ++ ) { info = list . get ( i - 1 ) ; if ( info . getRevisionCounter ( ) != i ) { if ( reverseMapping . length ( ) > 0 ) { reverseMapping . append ( " " ) ; } reverseMapping . append ( i ) ; reverseMapping . append ( " " ) ; reverseMapping . append ( info . getRevisionCounter ( ) ) ; } info . setIndex ( i ) ; info . setSortFlag ( false ) ; } Collections . sort ( list ) ; StringBuilder mapping = new StringBuilder ( ) ; while ( ! list . isEmpty ( ) ) { info = list . remove ( 0 ) ; if ( info . getRevisionCounter ( ) != info . getIndex ( ) ) { if ( mapping . length ( ) > 0 ) { mapping . append ( " " ) ; } mapping . append ( info . getRevisionCounter ( ) ) ; mapping . append ( " " ) ; mapping . append ( info . getIndex ( ) ) ; } } if ( mapping . length ( ) > 0 ) { boolean sql = ! insertStatement . isEmpty ( ) ; String val = ( sql ? "(" : "" ) + articleID + ( sql ? ",'" : ",\"" ) + mapping . toString ( ) + ( sql ? "','" : "\",\"" ) + reverseMapping . toString ( ) + ( sql ? "')" : "\"" ) ; if ( buffer . length ( ) + val . length ( ) >= MAX_ALLOWED_PACKET ) { storeBuffer ( ) ; } if ( sql && buffer . length ( ) > insertStatement . length ( ) ) { buffer . append ( "," ) ; } buffer . append ( val ) ; if ( ! sql ) { buffer . append ( "\n" ) ; } } } }
target:  Creates the mapping and the reverse mapping. The generated information will be added to the query buffer. This list will be cleared afterwards.