public int next()
        {

            if (_bufferedEnd != -1) {
                _start = _end;
                _end = _bufferedEnd;
                _bufferedEnd = -1;
                return _end;
            }

            _start = _end;
            _end = _iterator.next();

            if (_end == BreakIterator.DONE) {
                return _end;
            }

            final String string = _string.substring(_start, _end);

            // whitespace
            if (string.trim().length() == 0) {
                return _end;
            }

            final String word = string.trim();
            if (word.length() == string.length()) {
                return _end;
            }

            // suspected whitespace
            _bufferedEnd = _end;
            return _start + word.length();
        }
Line break iterator to handle whitespaces as first class citizens.
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/indent/SQLCommentAutoIndentStrategy.java