void (int startOffset, int endOffset) { if (startOffset < 0 || startOffset > getTextLength()) { throw new IndexOutOfBoundsException("Wrong startOffset: " + startOffset + "; documentLength: " + getTextLength()); } if (endOffset < 0 || endOffset > getTextLength()) { throw new IndexOutOfBoundsException("Wrong endOffset: " + endOffset + "; documentLength: " + getTextLength()); } if (endOffset < startOffset) { throw new IllegalArgumentException("endOffset < startOffset: " + endOffset + " < " + startOffset + "; documentLength: " + getTextLength()); } }