Skip to content

Commit d46919d

Browse files
authored
Merge pull request apache#270 from pedro-w/csv-274-documentation
[CSV-274] Add comments to iterator() and stream()
2 parents 221f5c4 + 5fbd353 commit d46919d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/main/java/org/apache/commons/csv/CSVParser.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,16 @@ private boolean isStrictQuoteMode() {
734734
* {@link IllegalStateException}.
735735
* </p>
736736
* <p>
737-
* If the parser is closed a call to {@link Iterator#next()} will throw a
737+
* If the parser is closed, the iterator will not yield any more records.
738+
* A call to {@link Iterator#hasNext()} will return {@code false} and
739+
* a call to {@link Iterator#next()} will throw a
738740
* {@link NoSuchElementException}.
739741
* </p>
742+
* <p>
743+
* If it is necessary to construct an iterator which is usable after the
744+
* parser is closed, one option is to extract all records as a list with
745+
* {@link getRecords()}, and return an iterator to that list.
746+
* </p>
740747
*/
741748
@Override
742749
public Iterator<CSVRecord> iterator() {
@@ -799,7 +806,10 @@ CSVRecord nextRecord() throws IOException {
799806

800807
/**
801808
* Returns a sequential {@code Stream} with this collection as its source.
802-
*
809+
* <p>
810+
* If the parser is closed, the stream will not produce any more values.
811+
* See the comments in {@link iterator()}.
812+
* </p>
803813
* @return a sequential {@code Stream} with this collection as its source.
804814
* @since 1.9.0
805815
*/

0 commit comments

Comments
 (0)