Skip to content

Commit 176c17e

Browse files
committed
[IO-619] Fixed issues reported in merge request #91
1 parent 72fd594 commit 176c17e

1 file changed

Lines changed: 30 additions & 9 deletions

File tree

src/main/java/org/apache/commons/io/input/CharSequenceReader.java

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* StringBuilder or CharBuffer.
2828
* <p>
2929
* <strong>Note:</strong> Supports {@link #mark(int)} and {@link #reset()}.
30+
* </p>
3031
*
3132
* @since 1.4
3233
*/
@@ -37,18 +38,38 @@ public class CharSequenceReader extends Reader implements Serializable {
3738
private int idx;
3839
private int mark;
3940

40-
/*
41-
* end is an Integer instead of int because of backwards compatibility.
41+
/**
42+
* The start index in the character sequence, inclusive.
43+
* <p>
4244
* When de-serializing a CharSequenceReader that was serialized before
43-
* these two fields were added, they will be initialized to 0 and null
44-
* respectively. If end was an int, it would be initialized to 0 as well.
45-
* That would cause all de-serialized CharSequenceReaders to be empty.
45+
* this fields was added, this field will be initialized to 0, which
46+
* gives the same behavior as before: start reading from the start.
47+
* </p>
48+
*
49+
* @see #start()
50+
* @since 2.7
4651
*/
4752
private final int start;
53+
54+
/**
55+
* The end index in the character sequence, exclusive.
56+
* <p>
57+
* When de-serializing a CharSequenceReader that was serialized before
58+
* this fields was added, this field will be initialized to {@code null},
59+
* which gives the same behavior as before: stop reading at the
60+
* CharSequence's length.
61+
* If this field was an int instead, it would be initialized to 0 when the
62+
* CharSequenceReader is de-serialized, causing it to not return any
63+
* characters at all.
64+
* </p>
65+
*
66+
* @see #end()
67+
* @since 2.7
68+
*/
4869
private final Integer end;
4970

5071
/**
51-
* Construct a new instance with the specified character sequence.
72+
* Constructs a new instance with the specified character sequence.
5273
*
5374
* @param charSequence The character sequence, may be {@code null}
5475
*/
@@ -57,7 +78,7 @@ public CharSequenceReader(final CharSequence charSequence) {
5778
}
5879

5980
/**
60-
* Construct a new instance with a portion of the specified character sequence.
81+
* Constructs a new instance with a portion of the specified character sequence.
6182
* <p>
6283
* The start index is not strictly enforced to be within the bounds of the
6384
* character sequence. This allows the character sequence to grow or shrink
@@ -76,7 +97,7 @@ public CharSequenceReader(final CharSequence charSequence, final int start) {
7697
}
7798

7899
/**
79-
* Construct a new instance with a portion of the specified character sequence.
100+
* Constructs a new instance with a portion of the specified character sequence.
80101
* <p>
81102
* The start and end indexes are not strictly enforced to be within the bounds
82103
* of the character sequence. This allows the character sequence to grow or shrink
@@ -89,7 +110,7 @@ public CharSequenceReader(final CharSequence charSequence, final int start) {
89110
*
90111
* @param charSequence The character sequence, may be {@code null}
91112
* @param start The start index in the character sequence, inclusive
92-
* @param end The start index in the character sequence, exclusive
113+
* @param end The end index in the character sequence, exclusive
93114
* @throws IllegalArgumentException if the start index is negative, or if the end index is smaller than the start index
94115
* @since 2.7
95116
*/

0 commit comments

Comments
 (0)