private void parse ( Reader reader ) throws IOException { StringBuilder text = new StringBuilder ( ) ; int character ; while ( ( character = reader . read ( ) ) != - 1 ) { boolean introducedControlSequence = false ; if ( character == SINGLE_CSI ) { introducedControlSequence = true ; } else if ( character == MULTI_CSI [ 0 ] ) { int nextCharacter = reader . read ( ) ; if ( nextCharacter == - 1 ) { buffer . append ( ( char ) character ) ; break ; } else if ( nextCharacter == MULTI_CSI [ 1 ] ) { introducedControlSequence = true ; } else { text . append ( ( char ) character ) ; text . append ( ( char ) nextCharacter ) ; } } else { text . append ( ( char ) character ) ; } if ( introducedControlSequence ) { if ( text . length ( ) > 0 ) { listener . parsedString ( text . toString ( ) ) ; text = new StringBuilder ( ) ; } parseControlSequence ( reader ) ; } } if ( text . length ( ) > 0 ) { listener . parsedString ( text . toString ( ) ) ; } }
Parses characters from the specified character reader .