private static String replaceNthArgWithCharsetString ( String sig , int stackOffset ) { List < String > arguments = SignatureUtils . getParameterSignatures ( sig ) ; StringBuilder sb = new StringBuilder ( "(" ) ; int argumentIndexToReplace = ( arguments . size ( ) - stackOffset ) - 1 ; for ( int i = 0 ; i < arguments . size ( ) ; i ++ ) { if ( i == argumentIndexToReplace ) { sb . append ( CHARSET_SIG ) ; } else { sb . append ( arguments . get ( i ) ) ; } } sb . append ( sig . substring ( sig . lastIndexOf ( ' ' ) , sig . length ( ) ) ) ; return sb . toString ( ) ; }
rebuilds a signature replacing a String argument at a specified spot with a Charset parameter .