protected final Event processEvent ( ) throws IOException { while ( true ) { String line ; try { line = readLine ( ) ; } catch ( final EOFException ex ) { if ( doneOnce ) { throw ex ; } doneOnce = true ; line = "" ; } // If the line is empty (a blank line), Dispatch the event, as defined below. if ( line . isEmpty ( ) ) { // If the data buffer is an empty string, set the data buffer and the event name buffer to // the empty string and abort these steps. if ( dataBuffer . length ( ) == 0 ) { eventName = "" ; continue ; } // If the event name buffer is not the empty string but is also not a valid NCName, // set the data buffer and the event name buffer to the empty string and abort these steps. // NOT IMPLEMENTED final Event . Builder eventBuilder = new Event . Builder ( ) ; eventBuilder . withEventName ( eventName . isEmpty ( ) ? Event . MESSAGE_EVENT : eventName ) ; eventBuilder . withData ( dataBuffer . toString ( ) ) ; // Set the data buffer and the event name buffer to the empty string. dataBuffer = new StringBuilder ( ) ; eventName = "" ; return eventBuilder . build ( ) ; // If the line starts with a U+003A COLON character (':') } else if ( line . startsWith ( ":" ) ) { // ignore the line // If the line contains a U+003A COLON character (':') character } else if ( line . contains ( ":" ) ) { // Collect the characters on the line before the first U+003A COLON character (':'), // and let field be that string. final int colonIdx = line . indexOf ( ":" ) ; final String field = line . substring ( 0 , colonIdx ) ; // Collect the characters on the line after the first U+003A COLON character (':'), // and let value be that string. // If value starts with a single U+0020 SPACE character, remove it from value. String value = line . substring ( colonIdx + 1 ) ; value = value . startsWith ( " " ) ? value . substring ( 1 ) : value ; processField ( field , value ) ; // Otherwise, the string is not empty but does not contain a U+003A COLON character (':') // character } else { processField ( line , "" ) ; } } }
Process the next event in a given stream .