@Override public SubSequence subSequence(int start, int end) { if (start >= 0 && end <= endOffset - startOffset) { return baseSubSequence(startOffset + start, startOffset + end); } if (start < 0 || startOffset + start > endOffset) { throw new StringIndexOutOfBoundsException("SubCharSequence index: " + start + " out of range: 0, " + length()); } throw new StringIndexOutOfBoundsException("SubCharSequence index: " + end + " out of range: 0, " + length()); }
@Override public SubSequence baseSubSequence(int start, int end) { if (start >= 0 && end <= base.length()) { return start == startOffset && end == endOffset ? this : base != this ? base.baseSubSequence(start, end) : new SubSequence(this, start, end); } if (start < 0 || start > base.length()) { throw new StringIndexOutOfBoundsException("SubCharSequence index: " + start + " out of range: 0, " + length()); } throw new StringIndexOutOfBoundsException("SubCharSequence index: " + end + " out of range: 0, " + length()); }
@Override public SubSequence subSequence(int start, int end) { if (start >= 0 && end <= endOffset - startOffset) { return baseSubSequence(startOffset + start, startOffset + end); } if (start < 0 || startOffset + start > endOffset) { throw new StringIndexOutOfBoundsException("SubCharSequence index: " + start + " out of range: 0, " + length()); } throw new StringIndexOutOfBoundsException("SubCharSequence index: " + end + " out of range: 0, " + length()); }
@Override public SubSequence baseSubSequence(int start, int end) { if (start >= 0 && end <= base.length()) { return start == startOffset && end == endOffset ? this : base != this ? base.baseSubSequence(start, end) : new SubSequence(this, start, end); } if (start < 0 || start > base.length()) { throw new StringIndexOutOfBoundsException("SubCharSequence index: " + start + " out of range: 0, " + length()); } throw new StringIndexOutOfBoundsException("SubCharSequence index: " + end + " out of range: 0, " + length()); }