public void newLineIfNotEmpty ( ) { for ( int i = segments . size ( ) - 1 ; i >= 0 ; i -- ) { String segment = segments . get ( i ) ; if ( lineDelimiter . equals ( segment ) ) { segments . subList ( i + 1 , segments . size ( ) ) . clear ( ) ; cachedToString = null ; return ; } for ( int j = 0 ; j < segment . length ( ) ; j ++ ) { if ( ! WhitespaceMatcher . isWhitespace ( segment . charAt ( j ) ) ) { newLine ( ) ; return ; } } } segments . clear ( ) ; cachedToString = null ; }
Add a newline to this sequence according to the configured lineDelimiter if the last line contains something besides whitespace .