[GitHub] [commons-io] garydgregory commented on a change in pull request #91: Support sub sequences in CharSequenceReader

2020-04-27 Thread GitBox


garydgregory commented on a change in pull request #91:
URL: https://github.com/apache/commons-io/pull/91#discussion_r416058527



##
File path: src/main/java/org/apache/commons/io/input/CharSequenceReader.java
##
@@ -37,22 +37,111 @@
 private int idx;
 private int mark;
 
+/*
+ * end is an Integer instead of int because of backwards compatibility.
+ * When de-serializing a CharSequenceReader that was serialized before
+ * these two fields were added, they will be initialized to 0 and null
+ * respectively. If end was an int, it would be initialized to 0 as well.
+ * That would cause all de-serialized CharSequenceReaders to be empty.
+ */
+private final int start;

Review comment:
   Give #start its own Javadoc and add @since 2.7.

##
File path: src/main/java/org/apache/commons/io/input/CharSequenceReader.java
##
@@ -37,22 +37,111 @@
 private int idx;
 private int mark;
 
+/*

Review comment:
   Move this Javadoc to#end and add @since 2.7

##
File path: src/main/java/org/apache/commons/io/input/CharSequenceReader.java
##
@@ -37,22 +37,111 @@
 private int idx;
 private int mark;
 
+/*
+ * end is an Integer instead of int because of backwards compatibility.
+ * When de-serializing a CharSequenceReader that was serialized before
+ * these two fields were added, they will be initialized to 0 and null
+ * respectively. If end was an int, it would be initialized to 0 as well.
+ * That would cause all de-serialized CharSequenceReaders to be empty.
+ */
+private final int start;
+private final Integer end;
+
 /**
  * Construct a new instance with the specified character sequence.
  *
  * @param charSequence The character sequence, may be {@code null}
  */
 public CharSequenceReader(final CharSequence charSequence) {
+this(charSequence, 0);
+}
+
+/**
+ * Construct a new instance with a portion of the specified character 
sequence.
+ * 
+ * The start index is not strictly enforced to be within the bounds of the
+ * character sequence. This allows the character sequence to grow or shrink
+ * in size without risking any {@link IndexOutOfBoundsException} to be 
thrown.
+ * Instead, if the character sequence grows smaller than the start index, 
this
+ * instance will act as if all characters have been read.
+ * 
+ *
+ * @param charSequence The character sequence, may be {@code null}
+ * @param start The start index in the character sequence, inclusive
+ * @throws IllegalArgumentException if the start index is negative
+ * @since 2.7
+ */
+public CharSequenceReader(final CharSequence charSequence, final int 
start) {
+this(charSequence, start, Integer.MAX_VALUE);
+}
+
+/**
+ * Construct a new instance with a portion of the specified character 
sequence.

Review comment:
   "Construct" -> "Constructs"

##
File path: src/main/java/org/apache/commons/io/input/CharSequenceReader.java
##
@@ -37,22 +37,111 @@
 private int idx;
 private int mark;
 
+/*
+ * end is an Integer instead of int because of backwards compatibility.
+ * When de-serializing a CharSequenceReader that was serialized before
+ * these two fields were added, they will be initialized to 0 and null
+ * respectively. If end was an int, it would be initialized to 0 as well.
+ * That would cause all de-serialized CharSequenceReaders to be empty.
+ */
+private final int start;
+private final Integer end;
+
 /**
  * Construct a new instance with the specified character sequence.
  *
  * @param charSequence The character sequence, may be {@code null}
  */
 public CharSequenceReader(final CharSequence charSequence) {
+this(charSequence, 0);
+}
+
+/**
+ * Construct a new instance with a portion of the specified character 
sequence.

Review comment:
   "Construct" -> "Constructs"





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-io] garydgregory commented on a change in pull request #91: Support sub sequences in CharSequenceReader

2020-04-26 Thread GitBox


garydgregory commented on a change in pull request #91:
URL: https://github.com/apache/commons-io/pull/91#discussion_r415337219



##
File path: src/main/java/org/apache/commons/io/input/CharSequenceReader.java
##
@@ -37,22 +37,107 @@
 private int idx;
 private int mark;
 
+/*
+ * end is an Integer instead of int because of backwards compatibility.
+ * When de-serializing a CharSequenceReader that was serialized before
+ * these two fields were added, they will be initialized to 0 and null
+ * respectively. If end was an int, it would be initialized to 0 as well.
+ * That would cause all de-serialized CharSequenceReaders to be empty.
+ */
+private final int start;
+private final Integer end;
+
 /**
  * Construct a new instance with the specified character sequence.
  *
  * @param charSequence The character sequence, may be {@code null}
  */
 public CharSequenceReader(final CharSequence charSequence) {
+this(charSequence, 0);
+}
+
+/**
+ * Construct a new instance with a portion of the specified character 
sequence.
+ * 
+ * The start index is not strictly enforced to be within the bounds of the
+ * character sequence. This allows the character sequence to grow or shrink
+ * in size without risking any {@link IndexOutOfBoundsException} to be 
thrown.
+ * Instead, if the character sequence grows smaller than the start index, 
this
+ * instance will act as if all characters have been read.
+ * 
+ *
+ * @param charSequence The character sequence, may be {@code null}
+ * @param start The start index in the character sequence, inclusive
+ * @throws IllegalArgumentException if the start index is negative
+ * @since 2.7
+ */
+public CharSequenceReader(final CharSequence charSequence, int start) {
+this(charSequence, start, Integer.MAX_VALUE);
+}
+
+/**
+ * Construct a new instance with a portion of the specified character 
sequence.
+ * 
+ * The start and end indexes are not strictly enforced to be within the 
bounds
+ * of the character sequence. This allows the character sequence to grow 
or shrink
+ * in size without risking any {@link IndexOutOfBoundsException} to be 
thrown.
+ * Instead, if the character sequence grows smaller than the start index, 
this
+ * instance will act as if all characters have been read; if the character 
sequence
+ * grows smaller than the end, this instance will use the actual character 
sequence
+ * length.
+ * 
+ *
+ * @param charSequence The character sequence, may be {@code null}
+ * @param start The start index in the character sequence, inclusive
+ * @param end The start index in the character sequence, exclusive
+ * @throws IllegalArgumentException if the start index is negative, or if 
the end index is smaller than the start index
+ * @since 2.7
+ */
+public CharSequenceReader(final CharSequence charSequence, int start, int 
end) {

Review comment:
   Missing `final`

##
File path: src/main/java/org/apache/commons/io/input/CharSequenceReader.java
##
@@ -37,22 +37,107 @@
 private int idx;
 private int mark;
 
+/*
+ * end is an Integer instead of int because of backwards compatibility.
+ * When de-serializing a CharSequenceReader that was serialized before
+ * these two fields were added, they will be initialized to 0 and null
+ * respectively. If end was an int, it would be initialized to 0 as well.
+ * That would cause all de-serialized CharSequenceReaders to be empty.
+ */
+private final int start;
+private final Integer end;
+
 /**
  * Construct a new instance with the specified character sequence.
  *
  * @param charSequence The character sequence, may be {@code null}
  */
 public CharSequenceReader(final CharSequence charSequence) {
+this(charSequence, 0);
+}
+
+/**
+ * Construct a new instance with a portion of the specified character 
sequence.
+ * 
+ * The start index is not strictly enforced to be within the bounds of the
+ * character sequence. This allows the character sequence to grow or shrink
+ * in size without risking any {@link IndexOutOfBoundsException} to be 
thrown.
+ * Instead, if the character sequence grows smaller than the start index, 
this
+ * instance will act as if all characters have been read.
+ * 
+ *
+ * @param charSequence The character sequence, may be {@code null}
+ * @param start The start index in the character sequence, inclusive
+ * @throws IllegalArgumentException if the start index is negative
+ * @since 2.7
+ */
+public CharSequenceReader(final CharSequence charSequence, int start) {

Review comment:
   `int start` -> `final int start`

##
File path: src/main/java/org/apache/commons/io/input/CharSequenceReader.java

[GitHub] [commons-io] garydgregory commented on a change in pull request #91: Support sub sequences in CharSequenceReader

2019-08-10 Thread GitBox
garydgregory commented on a change in pull request #91: Support sub sequences 
in CharSequenceReader
URL: https://github.com/apache/commons-io/pull/91#discussion_r312715184
 
 

 ##
 File path: src/main/java/org/apache/commons/io/input/CharSequenceReader.java
 ##
 @@ -36,22 +36,105 @@
 private int idx;
 private int mark;
 
+/*
+ * end is an Integer instead of int because of backwards compatibility.
+ * When de-serializing a CharSequenceReader that was serialized before
+ * these two fields were added, they will be initialized to 0 and null
+ * respectively. If end was an int, it would be initialized to 0 as well.
+ * That would cause all de-serialized CharSequenceReaders to be empty.
+ */
+private final int start;
+private final Integer end;
+
 /**
  * Construct a new instance with the specified character sequence.
  *
  * @param charSequence The character sequence, may be {@code null}
  */
 public CharSequenceReader(final CharSequence charSequence) {
+this(charSequence, 0);
+}
+
+/**
+ * Construct a new instance with a portion of the specified character 
sequence.
+ * 
+ * The start index is not strictly enforced to be within the bounds of the
+ * character sequence. This allows the character sequence to grow or shrink
+ * in size without risking any {@link IndexOutOfBoundsException} to be 
thrown.
+ * Instead, if the character sequence grows smaller than the start index, 
this
+ * instance will act as if all characters have been read.
+ * 
+ *
 
 Review comment:
   Please add `@since` tags for new `public` and `protected` methods.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services