String (int index) { CharSequence text = getDocument().getCharsSequence(); if (!getSegments().isValid(index)) return ""; int start = getSegments().getSegmentStart(index); int end = getSegments().getSegmentEnd(index); return text.subSequence(start, end).toString(); }