private TitledUrl findFormattedUrl ( TextCursor cursor , int limit ) { start_loop : for ( int start = cursor . currentOffset ; start < limit ; start ++ ) { // Finding beginning of url if ( cursor . text . charAt ( start ) == ' ' ) { if ( ! isGoodAnchor ( cursor . text , start - 1 ) ) { continue start_loop ; } } else { continue start_loop ; } // Finding middle part of url middle_loop : for ( int middle = start + 1 ; middle < limit - 1 ; middle ++ ) { if ( cursor . text . charAt ( middle ) != ' ' || cursor . text . charAt ( middle + 1 ) != ' ' ) { continue middle_loop ; } end_loop : for ( int end = middle + 2 ; end < limit ; end ++ ) { if ( cursor . text . charAt ( end ) != ' ' ) { continue end_loop ; } return new TitledUrl ( start , middle , end ) ; } } } return null ; }
Searching for valid formatted url