public String process ( SnippetProcessorContext ctx , String snippet ) { checkNotNull ( ctx ) ; StringBuilder sb = ctx . builder ( ) ; sb . setLength ( 0 ) ; String currSnippet = snippet ; boolean processedMacros = false ; int snippetPos = 0 ; int macroPos = currSnippet . indexOf ( "${" ) ; while ( macroPos != - 1 ) { sb . append ( currSnippet . substring ( snippetPos , macroPos ) ) ; int macroEnd = processMacroAt ( ctx , currSnippet , macroPos ) ; if ( macroEnd == - 1 ) { sb . append ( "${" ) ; snippetPos = macroPos + 2 ; } else { snippetPos = macroEnd ; processedMacros = true ; } macroPos = currSnippet . indexOf ( "${" , snippetPos ) ; } if ( processedMacros ) { sb . append ( currSnippet , snippetPos , currSnippet . length ( ) ) ; currSnippet = sb . toString ( ) ; } sb . setLength ( 0 ) ; String ret = urlEncode ( ctx , currSnippet ) ; sb . setLength ( 0 ) ; return ret ; }
Processes the raw snippet that was set by the bid making any transformations necessary .