question: public String escapeElementEntities ( String str ) { if ( escapeOutput == false ) return str ; StringBuffer buffer ; char ch ; String entity ; buffer = null ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { ch = str . charAt ( i ) ; switch ( ch ) { case '<' : entity = "&lt;" ; break ; case '>' : entity = "&gt;" ; break ; case '&' : entity = "&amp;" ; break ; case '\r' : entity = "&#xD;" ; break ; case '\n' : entity = lineSeparator ; break ; default : entity = null ; break ; } if ( buffer == null ) { if ( entity != null ) { buffer = new StringBuffer ( str . length ( ) + 20 ) ; buffer . append ( str . substring ( 0 , i ) ) ; buffer . append ( entity ) ; } } else { if ( entity == null ) { buffer . append ( ch ) ; } else { buffer . append ( entity ) ; } } } return ( buffer == null ) ? str : buffer . toString ( ) ; }
target:  This will take the three pre-defined entities in XML 1.0 (used specifically in XML elements) and convert their character representation to the appropriate entity reference, suitable for XML element content.