public static Appendable render ( final String input , Appendable target ) throws IOException { int i = 0 ; int j , k ; while ( true ) { j = input . indexOf ( BEGIN_TOKEN , i ) ; if ( j == - 1 ) { if ( i == 0 ) { target . append ( input ) ; return target ; } target . append ( input . substring ( i , input . length ( ) ) ) ; return target ; } target . append ( input . substring ( i , j ) ) ; k = input . indexOf ( END_TOKEN , j ) ; if ( k == - 1 ) { target . append ( input ) ; return target ; } j += BEGIN_TOKEN_LEN ; String spec = input . substring ( j , k ) ; String [ ] items = spec . split ( CODE_TEXT_SEPARATOR , 2 ) ; if ( items . length == 1 ) { target . append ( input ) ; return target ; } String replacement = render ( items [ 1 ] , items [ 0 ] . split ( CODE_LIST_SEPARATOR ) ) ; target . append ( replacement ) ; i = k + END_TOKEN_LEN ; } }
Renders the given input to the target Appendable .