<s> package org . eclipse . jdt . internal . formatter . comment ; import java . io . IOException ; import java . io . Reader ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . jdt . internal . compiler . parser . * ; public class Java2HTMLEntityReader extends SubstitutionTextReader { private static final int BEGIN_LINE = 0x01 ; private static final Map fgEntityLookup ; private int bits = BEGIN_LINE ; static { fgEntityLookup = new HashMap ( 7 ) ; fgEntityLookup . put ( "<" , "&lt;" ) ; fgEntityLookup . put ( ">" , "&gt;" ) ; fgEntityLookup . put ( "&" , "&amp;" ) ; fgEntityLookup . put ( "^" , "&circ;" ) ; fgEntityLookup . put ( "~" , "&tilde;" ) ; fgEntityLookup . put ( "\"" , "&quot;" ) ; } public Java2HTMLEntityReader ( Reader reader ) { super ( reader ) ; setSkipWhitespace ( false ) ; } protected String computeSubstitution ( int c ) throws IOException { StringBuffer buf = new StringBuffer ( ) ; while ( c == '*' ) { this . bits &= ~ BEGIN_LINE ; c = nextChar ( ) ; buf . append ( '*' ) ; } if ( c == - 1 ) return buf . toString ( ) ; if ( c == '/' && buf . length ( ) > 0 ) { buf . setLength ( buf . length ( ) - 1 ) ; buf . append ( "&#42;/" ) ; } else if ( c == '@' && ( this . bits & BEGIN_LINE ) != 0 ) { buf . append ( "&#064;" ) ; } else { String entity = ( String ) fgEntityLookup . get ( String . valueOf ( ( char ) c ) ) ; if ( entity != null ) buf . append ( entity ) ; else buf . append ( ( char ) c ) ; } if ( c == '\n' || c == '\r' ) { this . bits |= BEGIN_LINE ; } else if ( ! ScannerHelper . isWhitespace ( ( char ) c ) ) { this . bits &= ~ BEGIN_LINE ; } return buf . toString ( ) ; } } </s>