question: public String transform ( String html , URL url , boolean setBaseTag ) throws PageException { StringBuffer target = new StringBuffer ( ) ; SourceCode cfml = new SourceCode ( html , false , CFMLEngine . DIALECT_CFML ) ; while ( ! cfml . isAfterLast ( ) ) { if ( cfml . forwardIfCurrent ( '<' ) ) { target . append ( '<' ) ; try { for ( int i = 0 ; i < tags . length ; i ++ ) { if ( cfml . forwardIfCurrent ( tags [ i ] . tag + " " ) ) { target . append ( tags [ i ] . tag + " " ) ; transformTag ( target , cfml , tags [ i ] , url ) ; } } } catch ( MalformedURLException me ) { throw Caster . toPageException ( me ) ; } } else { target . append ( cfml . getCurrent ( ) ) ; cfml . next ( ) ; } } if ( ! setBaseTag ) return target . toString ( ) ; html = target . toString ( ) ; String prefix = "" , postfix = "" ; int index = StringUtil . indexOfIgnoreCase ( html , "</head>" ) ; if ( index == - 1 ) { prefix = "<head>" ; postfix = "</head>" ; index = StringUtil . indexOfIgnoreCase ( html , "</html>" ) ; } if ( index != - 1 ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( html . substring ( 0 , index ) ) ; String port = url . getPort ( ) == - 1 ? "" : ":" + url . getPort ( ) ; sb . append ( prefix + "<base href=\"" + ( url . getProtocol ( ) + "://" + url . getHost ( ) + port ) + "\">" + postfix ) ; sb . append ( html . substring ( index ) ) ; html = sb . toString ( ) ; } return html ; }
target:  transform the HTML String