Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Commit 156f1f5

Browse files
authored
Merge branch 'apache:master' into CSV-147
2 parents e60b8ac + 7104598 commit 156f1f5

11 files changed

Lines changed: 109 additions & 108 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<groupId>org.apache.commons</groupId>
2222
<artifactId>commons-parent</artifactId>
23-
<version>60</version>
23+
<version>61</version>
2424
</parent>
2525
<artifactId>commons-csv</artifactId>
2626
<version>1.10.1-SNAPSHOT</version>

src/changes/changes.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@
5050
<action type="fix" dev="ggregory" due-to="step-security-bot">[StepSecurity] CI: Harden GitHub Actions #329, #330.</action>
5151
<!-- UPDATE -->
5252
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-io:commons-io: from 2.11.0 to 2.13.0.</action>
53-
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-parent from 57 to 60.</action>
53+
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-parent from 57 to 61.</action>
5454
<action type="update" dev="ggregory" due-to="Dependabot">Bump h2 from 2.1.214 to 2.2.220 #333.</action>
5555
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-lang3 from 3.12.0 to 3.13.0.</action>
56+
<action type="update" dev="ggregory" due-to="Buddhi De Silva, Michael Osipov, Gary Gregory">Update exception message in CSVRecord#getNextRecord() #348.</action>
5657
</release>
5758
<release version="1.10.0" date="2023-01-28" description="Feature and bug fix release (Java 8)">
5859
<!-- FIX -->

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

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public Builder setEscape(final Character escapeCharacter) {
477477
* The header is also used by the {@link CSVPrinter}.
478478
* </p>
479479
*
480-
* @param headerEnum the enum defining the header, {@code null} if disabled, empty if parsed automatically, user specified otherwise.
480+
* @param headerEnum the enum defining the header, {@code null} if disabled, empty if parsed automatically, user-specified otherwise.
481481
* @return This instance.
482482
*/
483483
public Builder setHeader(final Class<? extends Enum<?>> headerEnum) {
@@ -491,7 +491,7 @@ public Builder setHeader(final Class<? extends Enum<?>> headerEnum) {
491491
}
492492

493493
/**
494-
* Sets the header from the result set metadata. The header can either be parsed automatically from the input file with:
494+
* Sets the header from the result set metadata. The header can be parsed automatically from the input file with:
495495
*
496496
* <pre>
497497
* builder.setHeader();
@@ -506,7 +506,7 @@ public Builder setHeader(final Class<? extends Enum<?>> headerEnum) {
506506
* The header is also used by the {@link CSVPrinter}.
507507
* </p>
508508
*
509-
* @param resultSet the resultSet for the header, {@code null} if disabled, empty if parsed automatically, user specified otherwise.
509+
* @param resultSet the resultSet for the header, {@code null} if disabled, empty if parsed automatically, user-specified otherwise.
510510
* @return This instance.
511511
* @throws SQLException SQLException if a database access error occurs or this method is called on a closed result set.
512512
*/
@@ -515,7 +515,7 @@ public Builder setHeader(final ResultSet resultSet) throws SQLException {
515515
}
516516

517517
/**
518-
* Sets the header from the result set metadata. The header can either be parsed automatically from the input file with:
518+
* Sets the header from the result set metadata. The header can be parsed automatically from the input file with:
519519
*
520520
* <pre>
521521
* builder.setHeader();
@@ -530,7 +530,7 @@ public Builder setHeader(final ResultSet resultSet) throws SQLException {
530530
* The header is also used by the {@link CSVPrinter}.
531531
* </p>
532532
*
533-
* @param resultSetMetaData the metaData for the header, {@code null} if disabled, empty if parsed automatically, user specified otherwise.
533+
* @param resultSetMetaData the metaData for the header, {@code null} if disabled, empty if parsed automatically, user-specified otherwise.
534534
* @return This instance.
535535
* @throws SQLException SQLException if a database access error occurs or this method is called on a closed result set.
536536
*/
@@ -547,7 +547,7 @@ public Builder setHeader(final ResultSetMetaData resultSetMetaData) throws SQLEx
547547
}
548548

549549
/**
550-
* Sets the header to the given values. The header can either be parsed automatically from the input file with:
550+
* Sets the header to the given values. The header can be parsed automatically from the input file with:
551551
*
552552
* <pre>
553553
* builder.setHeader();
@@ -562,7 +562,7 @@ public Builder setHeader(final ResultSetMetaData resultSetMetaData) throws SQLEx
562562
* The header is also used by the {@link CSVPrinter}.
563563
* </p>
564564
*
565-
* @param header the header, {@code null} if disabled, empty if parsed automatically, user specified otherwise.
565+
* @param header the header, {@code null} if disabled, empty if parsed automatically, user-specified otherwise.
566566
* @return This instance.
567567
*/
568568
public Builder setHeader(final String... header) {
@@ -909,8 +909,8 @@ public CSVFormat getFormat() {
909909
false, false, false, DuplicateHeaderMode.ALLOW_ALL);
910910

911911
/**
912-
* Excel file format (using a comma as the value delimiter). Note that the actual value delimiter used by Excel is locale dependent, it might be necessary
913-
* to customize this format to accommodate to your regional settings.
912+
* Excel file format (using a comma as the value delimiter). Note that the actual value delimiter used by Excel is locale-dependent, it might be necessary
913+
* to customize this format to accommodate your regional settings.
914914
*
915915
* <p>
916916
* For example for parsing or generating a CSV file on a French system the following format will be used:
@@ -949,7 +949,7 @@ public CSVFormat getFormat() {
949949
* Default Informix CSV UNLOAD format used by the {@code UNLOAD TO file_name} operation.
950950
*
951951
* <p>
952-
* This is a comma-delimited format with a LF character as the line separator. Values are not quoted and special characters are escaped with {@code '\'}.
952+
* This is a comma-delimited format with an LF character as the line separator. Values are not quoted and special characters are escaped with {@code '\'}.
953953
* The default NULL string is {@code "\\N"}.
954954
* </p>
955955
*
@@ -981,7 +981,7 @@ public CSVFormat getFormat() {
981981
* Default Informix CSV UNLOAD format used by the {@code UNLOAD TO file_name} operation (escaping is disabled.)
982982
*
983983
* <p>
984-
* This is a comma-delimited format with a LF character as the line separator. Values are not quoted and special characters are escaped with {@code '\'}.
984+
* This is a comma-delimited format with an LF character as the line separator. Values are not quoted and special characters are escaped with {@code '\'}.
985985
* The default NULL string is {@code "\\N"}.
986986
* </p>
987987
*
@@ -1084,7 +1084,7 @@ public CSVFormat getFormat() {
10841084
* Default MySQL format used by the {@code SELECT INTO OUTFILE} and {@code LOAD DATA INFILE} operations.
10851085
*
10861086
* <p>
1087-
* This is a tab-delimited format with a LF character as the line separator. Values are not quoted and special
1087+
* This is a tab-delimited format with an LF character as the line separator. Values are not quoted and special
10881088
* characters are escaped with {@code '\'}. The default NULL string is {@code "\\N"}.
10891089
* </p>
10901090
*
@@ -1121,7 +1121,7 @@ public CSVFormat getFormat() {
11211121
* Default Oracle format used by the SQL*Loader utility.
11221122
*
11231123
* <p>
1124-
* This is a comma-delimited format with the system line separator character as the record separator.Values are
1124+
* This is a comma-delimited format with the system line separator character as the record separator. Values are
11251125
* double quoted when needed and special characters are escaped with {@code '"'}. The default NULL string is
11261126
* {@code ""}. Values are trimmed.
11271127
* </p>
@@ -1161,7 +1161,7 @@ public CSVFormat getFormat() {
11611161
* Default PostgreSQL CSV format used by the {@code COPY} operation.
11621162
*
11631163
* <p>
1164-
* This is a comma-delimited format with a LF character as the line separator. Values are double quoted and special
1164+
* This is a comma-delimited format with an LF character as the line separator. Values are double quoted and special
11651165
* characters are not escaped. The default NULL string is {@code ""}.
11661166
* </p>
11671167
*
@@ -1199,7 +1199,7 @@ public CSVFormat getFormat() {
11991199
* Default PostgreSQL text format used by the {@code COPY} operation.
12001200
*
12011201
* <p>
1202-
* This is a tab-delimited format with a LF character as the line separator. Values are not quoted and special
1202+
* This is a tab-delimited format with an LF character as the line separator. Values are not quoted and special
12031203
* characters are escaped with {@code '\\'}. The default NULL string is {@code "\\N"}.
12041204
* </p>
12051205
*
@@ -1890,7 +1890,7 @@ private boolean isDelimiter(final char ch, final CharSequence charSeq, final int
18901890
}
18911891

18921892
/**
1893-
* Tests whether escape are being processed.
1893+
* Tests whether escapes are being processed.
18941894
*
18951895
* @return {@code true} if escapes are processed
18961896
*/
@@ -1899,7 +1899,7 @@ public boolean isEscapeCharacterSet() {
18991899
}
19001900

19011901
/**
1902-
* Tests whether a nullString has been defined.
1902+
* Tests whether a null string has been defined.
19031903
*
19041904
* @return {@code true} if a nullString is defined
19051905
*/
@@ -2009,7 +2009,7 @@ private synchronized void print(final Object object, final CharSequence value, f
20092009
if (object == null) {
20102010
out.append(value);
20112011
} else if (isQuoteCharacterSet()) {
2012-
// the original object is needed so can check for Number
2012+
// The original object is needed so can check for Number
20132013
printWithQuotes(object, value, out, newRecord);
20142014
} else if (isEscapeCharacterSet()) {
20152015
printWithEscapes(value, out);
@@ -2086,7 +2086,7 @@ public synchronized void println(final Appendable appendable) throws IOException
20862086
}
20872087

20882088
/**
2089-
* Prints the given {@code values} to {@code out} as a single record of delimiter separated values followed by the record separator.
2089+
* Prints the given {@code values} to {@code out} as a single record of delimiter-separated values followed by the record separator.
20902090
*
20912091
* <p>
20922092
* The values will be quoted if needed. Quotes and new-line characters will be escaped. This method adds the record separator to the output after printing
@@ -2241,7 +2241,7 @@ private void printWithQuotes(final Object object, final CharSequence charSeq, fi
22412241
return;
22422242
case MINIMAL:
22432243
if (len <= 0) {
2244-
// always quote an empty token that is the first
2244+
// Always quote an empty token that is the first
22452245
// on the line, as it may be the only thing on the
22462246
// line. If it were not quoted in that case,
22472247
// an empty line has no tokens.
@@ -2279,7 +2279,7 @@ private void printWithQuotes(final Object object, final CharSequence charSeq, fi
22792279
}
22802280

22812281
if (!quote) {
2282-
// no encapsulation needed - write out the original value
2282+
// No encapsulation needed - write out the original value
22832283
out.append(charSeq, start, len);
22842284
return;
22852285
}
@@ -2289,12 +2289,12 @@ private void printWithQuotes(final Object object, final CharSequence charSeq, fi
22892289
}
22902290

22912291
if (!quote) {
2292-
// no encapsulation needed - write out the original value
2292+
// No encapsulation needed - write out the original value
22932293
out.append(charSeq, start, len);
22942294
return;
22952295
}
22962296

2297-
// we hit something that needed encapsulation
2297+
// We hit something that needed encapsulation
22982298
out.append(quoteChar);
22992299

23002300
// Pick up where we left off: pos should be positioned on the first character that caused
@@ -2310,13 +2310,13 @@ private void printWithQuotes(final Object object, final CharSequence charSeq, fi
23102310
pos++;
23112311
}
23122312

2313-
// write the last segment
2313+
// Write the last segment
23142314
out.append(charSeq, start, pos);
23152315
out.append(quoteChar);
23162316
}
23172317

23182318
/**
2319-
* Always use quotes unless QuoteMode is NONE, so we not have to look ahead.
2319+
* Always use quotes unless QuoteMode is NONE, so we do not have to look ahead.
23202320
*
23212321
* @param reader What to print
23222322
* @param appendable Where to print it
@@ -2417,8 +2417,8 @@ String trim(final String value) {
24172417
/**
24182418
* Verifies the validity and consistency of the attributes, and throws an {@link IllegalArgumentException} if necessary.
24192419
* <p>
2420-
* Because an instance can be used for both writing an parsing, not all conditions can be tested here. For example allowMissingColumnNames is only used for
2421-
* parsing, so it cannot be used here.
2420+
* Because an instance can be used for both writing and parsing, not all conditions can be tested here. For example, allowMissingColumnNames is only used
2421+
* for parsing, so it cannot be used here.
24222422
* </p>
24232423
*
24242424
* @throws IllegalArgumentException Throw when any attribute is invalid or inconsistent with other attributes.
@@ -2570,7 +2570,7 @@ public CSVFormat withCommentMarker(final Character commentMarker) {
25702570
* Builds a new {@code CSVFormat} with the delimiter of the format set to the specified character.
25712571
*
25722572
* @param delimiter the delimiter character
2573-
* @return A new CSVFormat that is equal to this with the specified character as delimiter
2573+
* @return A new CSVFormat that is equal to this with the specified character as a delimiter
25742574
* @throws IllegalArgumentException thrown if the specified character is a line break
25752575
* @deprecated Use {@link Builder#setDelimiter(char)}
25762576
*/
@@ -2679,7 +2679,7 @@ public CSVFormat withHeader(final Class<? extends Enum<?>> headerEnum) {
26792679
* The header is also used by the {@link CSVPrinter}.
26802680
* </p>
26812681
*
2682-
* @param resultSet the resultSet for the header, {@code null} if disabled, empty if parsed automatically, user specified otherwise.
2682+
* @param resultSet the resultSet for the header, {@code null} if disabled, empty if parsed automatically, user-specified otherwise.
26832683
* @return A new CSVFormat that is equal to this but with the specified header
26842684
* @throws SQLException SQLException if a database access error occurs or this method is called on a closed result set.
26852685
* @since 1.1
@@ -2735,7 +2735,7 @@ public CSVFormat withHeader(final ResultSetMetaData resultSetMetaData) throws SQ
27352735
* The header is also used by the {@link CSVPrinter}.
27362736
* </p>
27372737
*
2738-
* @param header the header, {@code null} if disabled, empty if parsed automatically, user specified otherwise.
2738+
* @param header the header, {@code null} if disabled, empty if parsed automatically, user-specified otherwise.
27392739
* @return A new CSVFormat that is equal to this but with the specified header
27402740
* @see Builder#setSkipHeaderRecord(boolean)
27412741
* @deprecated Use {@link Builder#setHeader(String...)}
@@ -2793,7 +2793,7 @@ public CSVFormat withIgnoreEmptyLines(final boolean ignoreEmptyLines) {
27932793
/**
27942794
* Builds a new {@code CSVFormat} with the header ignore case behavior set to {@code true}.
27952795
*
2796-
* @return A new CSVFormat that will ignore case header name.
2796+
* @return A new CSVFormat that will ignore the new case header name behavior.
27972797
* @see Builder#setIgnoreHeaderCase(boolean)
27982798
* @since 1.3
27992799
* @deprecated Use {@link Builder#setIgnoreHeaderCase(boolean) Builder#setIgnoreHeaderCase(true)}

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
* Because CSV appears in many different dialects, the parser supports many formats by allowing the
5454
* specification of a {@link CSVFormat}.
5555
*
56-
* The parser works record wise. It is not possible to go back, once a record has been parsed from the input stream.
56+
* The parser works record-wise. It is not possible to go back, once a record has been parsed from the input stream.
5757
*
5858
* <h2>Creating instances</h2>
5959
* <p>
@@ -105,13 +105,13 @@
105105
* </pre>
106106
*
107107
* <p>
108-
* If the predefined formats don't match the format at hands, custom formats can be defined. More information about
109-
* customising CSVFormats is available in {@link CSVFormat CSVFormat Javadoc}.
108+
* If the predefined formats don't match the format at hand, custom formats can be defined. More information about
109+
* customizing CSVFormats is available in {@link CSVFormat CSVFormat Javadoc}.
110110
* </p>
111111
*
112112
* <h2>Parsing into memory</h2>
113113
* <p>
114-
* If parsing record wise is not desired, the contents of the input can be read completely into memory.
114+
* If parsing record-wise is not desired, the contents of the input can be read completely into memory.
115115
* </p>
116116
*
117117
* <pre>
@@ -126,14 +126,14 @@
126126
*
127127
* <ol>
128128
* <li>Parsing into memory starts at the current position of the parser. If you have already parsed records from
129-
* the input, those records will not end up in the in memory representation of your CSV data.</li>
130-
* <li>Parsing into memory may consume a lot of system resources depending on the input. For example if you're
129+
* the input, those records will not end up in the in-memory representation of your CSV data.</li>
130+
* <li>Parsing into memory may consume a lot of system resources depending on the input. For example, if you're
131131
* parsing a 150MB file of CSV data the contents will be read completely into memory.</li>
132132
* </ol>
133133
*
134134
* <h2>Notes</h2>
135135
* <p>
136-
* Internal parser state is completely covered by the format and the reader-state.
136+
* The internal parser state is completely covered by the format and the reader state.
137137
* </p>
138138
*
139139
* @see <a href="package-summary.html">package documentation for more details</a>
@@ -147,7 +147,7 @@ private CSVRecord getNextRecord() {
147147
try {
148148
return CSVParser.this.nextRecord();
149149
} catch (final IOException e) {
150-
throw new UncheckedIOException(e.getClass().getSimpleName() + " reading next record: " + e.toString(), e);
150+
throw new UncheckedIOException("Exception reading next record: " + e.toString(), e);
151151
}
152152
}
153153

@@ -304,8 +304,6 @@ public static CSVParser parse(final Reader reader, final CSVFormat format) throw
304304
return new CSVParser(reader, format);
305305
}
306306

307-
// the following objects are shared to reduce garbage
308-
309307
/**
310308
* Creates a parser for the given {@link String}.
311309
*
@@ -423,7 +421,7 @@ public CSVParser(final Reader reader, final CSVFormat format) throws IOException
423421
* @param recordNumber
424422
* The next record number to assign
425423
* @throws IllegalArgumentException
426-
* If the parameters of the format are inconsistent or if either reader or format are null.
424+
* If the parameters of the format are inconsistent or if either the reader or format is null.
427425
* @throws IOException
428426
* If there is a problem reading the header or skipping the first record
429427
* @since 1.1
@@ -702,11 +700,11 @@ public String getTrailerComment() {
702700
}
703701

704702
/**
705-
* Handle whether input is parsed as null
703+
* Handles whether the input is parsed as null
706704
*
707705
* @param input
708706
* the cell data to further processed
709-
* @return null if input is parsed as null, or input itself if input isn't parsed as null
707+
* @return null if input is parsed as null, or input itself if the input isn't parsed as null
710708
*/
711709
private String handleNull(final String input) {
712710
final boolean isQuoted = this.reusableToken.isQuoted;
@@ -773,7 +771,7 @@ private boolean isStrictQuoteMode() {
773771
* Returns the record iterator.
774772
*
775773
* <p>
776-
* An {@link IOException} caught during the iteration are re-thrown as an
774+
* An {@link IOException} caught during the iteration is re-thrown as an
777775
* {@link IllegalStateException}.
778776
* </p>
779777
* <p>

0 commit comments

Comments
 (0)