ReaderCharSequence implements CharSequence { public CharSequence subSequence(int start, int end) { if (start < 0 || end < 0 || end > length || start > end) { throw new IndexOutOfBoundsException("Subsequence " + "<" + start + ", " + end + ") not in " + "<0, " + length + ")."); } else { fillBuffer(end - 1); if (end > length) { end = length; } if (start > end) { throw new IndexOutOfBoundsException("Subsequence " + "<" + start + ", " + end + ") not in " + "<0, " + length + ")."); } if (end - start > buffer.length() || start < getMinIndex()) { throw new IllegalStateException("Cannot retrieve subsequence " + "<" + start + ", " + end + "). " + "Characters lost, buffer too small."); } int relativeStart = getRelativeIndex(start); int relativeEnd = getRelativeIndex(end); CharSequence subSequence = buffer.subSequence(relativeStart, relativeEnd); return subSequence; } } ReaderCharSequence(Reader reader, int bufferLength, int length, 
			int lookahead);  ReaderCharSequence(Reader reader, int bufferLength, int length);  ReaderCharSequence(Reader reader, int bufferLength);  ReaderCharSequence(Reader reader); int length(); char charAt(int index); CharSequence subSequence(int start, int end); static final int DEFAULT_BUFFER_LENGTH; static final int DEFAULT_LOOKAHEAD; static final int INFINITE_LENGTH; }
@Test(expected = IllegalStateException.class) public void testSubsequenceLongerThanBuffer() { assertEquals("abcde", sequence.subSequence(0, 5).toString()); }
@Test(expected = IllegalStateException.class) public void testWindowTooNarrow() { sequence.subSequence(0, 5); }
@Test(expected = IndexOutOfBoundsException.class) public void testEndBeforeStart() { sequence.subSequence(2, 1); }
@Test(expected = IndexOutOfBoundsException.class) public void testStartNegative() { sequence.subSequence(-1, 1); }
@Test(expected = IndexOutOfBoundsException.class) public void testEndPastEnd() { sequence.subSequence(1, 6); }