Skip to content

Commit 19eb70c

Browse files
committed
Document explicit (un)boxing
1 parent 0e79eac commit 19eb70c

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ private static boolean isLineBreak(final char c) {
13711371
* @return true if {@code c} is a line break character (and not null).
13721372
*/
13731373
private static boolean isLineBreak(final Character c) {
1374-
return c != null && isLineBreak(c.charValue());
1374+
return c != null && isLineBreak(c.charValue()); // N.B. Explicit (un)boxing is intentional
13751375
}
13761376

13771377
/** Same test as in as {@link String#trim()}. */
@@ -1632,7 +1632,7 @@ public boolean equals(final Object obj) {
16321632
}
16331633

16341634
private void escape(final char c, final Appendable appendable) throws IOException {
1635-
append(escapeCharacter.charValue(), appendable);
1635+
append(escapeCharacter.charValue(), appendable); // N.B. Explicit (un)boxing is intentional
16361636
append(c, appendable);
16371637
}
16381638

@@ -1769,7 +1769,7 @@ public DuplicateHeaderMode getDuplicateHeaderMode() {
17691769
* @return the escape character, may be {@code 0}
17701770
*/
17711771
char getEscapeChar() {
1772-
return escapeCharacter != null ? escapeCharacter.charValue() : 0;
1772+
return escapeCharacter != null ? escapeCharacter.charValue() : 0; // N.B. Explicit (un)boxing is intentional
17731773
}
17741774

17751775
/**
@@ -2081,15 +2081,15 @@ private void print(final InputStream inputStream, final Appendable out, final bo
20812081
}
20822082
final boolean quoteCharacterSet = isQuoteCharacterSet();
20832083
if (quoteCharacterSet) {
2084-
append(getQuoteCharacter().charValue(), out);
2084+
append(getQuoteCharacter().charValue(), out); // N.B. Explicit (un)boxing is intentional
20852085
}
20862086
// Stream the input to the output without reading or holding the whole value in memory.
20872087
// AppendableOutputStream cannot "close" an Appendable.
20882088
try (OutputStream outputStream = new Base64OutputStream(new AppendableOutputStream<>(out))) {
20892089
IOUtils.copy(inputStream, outputStream);
20902090
}
20912091
if (quoteCharacterSet) {
2092-
append(getQuoteCharacter().charValue(), out);
2092+
append(getQuoteCharacter().charValue(), out); // N.B. Explicit (un)boxing is intentional
20932093
}
20942094
}
20952095

@@ -2338,7 +2338,7 @@ private void printWithQuotes(final Object object, final CharSequence charSeq, fi
23382338
final int len = charSeq.length();
23392339
final char[] delim = getDelimiterCharArray();
23402340
final int delimLength = delim.length;
2341-
final char quoteChar = getQuoteCharacter().charValue();
2341+
final char quoteChar = getQuoteCharacter().charValue(); // N.B. Explicit (un)boxing is intentional
23422342
// If escape char not specified, default to the quote char
23432343
// This avoids having to keep checking whether there is an escape character
23442344
// at the cost of checking against quote twice
@@ -2441,7 +2441,7 @@ private void printWithQuotes(final Reader reader, final Appendable appendable) t
24412441
printWithEscapes(reader, appendable);
24422442
return;
24432443
}
2444-
final char quote = getQuoteCharacter().charValue();
2444+
final char quote = getQuoteCharacter().charValue(); // N.B. Explicit (un)boxing is intentional
24452445
// (1) Append opening quote
24462446
append(quote, appendable);
24472447
// (2) Append Reader contents, doubling quotes
@@ -2522,13 +2522,13 @@ private void validate() throws IllegalArgumentException {
25222522
if (containsLineBreak(delimiter)) {
25232523
throw new IllegalArgumentException("The delimiter cannot be a line break");
25242524
}
2525-
if (quoteCharacter != null && contains(delimiter, quoteCharacter.charValue())) {
2525+
if (quoteCharacter != null && contains(delimiter, quoteCharacter.charValue())) { // N.B. Explicit (un)boxing is intentional
25262526
throw new IllegalArgumentException("The quoteChar character and the delimiter cannot be the same ('" + quoteCharacter + "')");
25272527
}
2528-
if (escapeCharacter != null && contains(delimiter, escapeCharacter.charValue())) {
2528+
if (escapeCharacter != null && contains(delimiter, escapeCharacter.charValue())) { // N.B. Explicit (un)boxing is intentional
25292529
throw new IllegalArgumentException("The escape character and the delimiter cannot be the same ('" + escapeCharacter + "')");
25302530
}
2531-
if (commentMarker != null && contains(delimiter, commentMarker.charValue())) {
2531+
if (commentMarker != null && contains(delimiter, commentMarker.charValue())) { // N.B. Explicit (un)boxing is intentional
25322532
throw new IllegalArgumentException("The comment start character and the delimiter cannot be the same ('" + commentMarker + "')");
25332533
}
25342534
if (quoteCharacter != null && quoteCharacter.equals(commentMarker)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ private Headers createHeaders() throws IOException {
515515
}
516516
observedMissing |= blankHeader;
517517
if (header != null) {
518-
hdrMap.put(header, Integer.valueOf(i));
518+
hdrMap.put(header, Integer.valueOf(i)); // N.B. Explicit (un)boxing is intentional
519519
if (headerNames == null) {
520520
headerNames = new ArrayList<>(headerRecord.length);
521521
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public synchronized void printComment(final String comment) throws IOException {
203203
if (!newRecord) {
204204
println();
205205
}
206-
appendable.append(format.getCommentMarker().charValue());
206+
appendable.append(format.getCommentMarker().charValue()); // N.B. Explicit (un)boxing is intentional
207207
appendable.append(SP);
208208
for (int i = 0; i < comment.length(); i++) {
209209
final char c = comment.charAt(i);
@@ -215,7 +215,7 @@ public synchronized void printComment(final String comment) throws IOException {
215215
//$FALL-THROUGH$ break intentionally excluded.
216216
case LF:
217217
println();
218-
appendable.append(format.getCommentMarker().charValue());
218+
appendable.append(format.getCommentMarker().charValue()); // N.B. Explicit (un)boxing is intentional
219219
appendable.append(SP);
220220
break;
221221
default:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ public String get(final String name) {
122122
headerMap.keySet()));
123123
}
124124
try {
125-
return values[index.intValue()];
125+
return values[index.intValue()]; // N.B. Explicit (un)boxing is intentional
126126
} catch (final ArrayIndexOutOfBoundsException e) {
127127
throw new IllegalArgumentException(String.format(
128128
"Index for header '%s' is %d but CSVRecord only has %d values!", name, index,
129-
Integer.valueOf(values.length)));
129+
Integer.valueOf(values.length))); // N.B. Explicit (un)boxing is intentional
130130
}
131131
}
132132

@@ -245,7 +245,7 @@ public boolean isSet(final int index) {
245245
* @return whether a given column is mapped and has a value
246246
*/
247247
public boolean isSet(final String name) {
248-
return isMapped(name) && getHeaderMapRaw().get(name).intValue() < values.length;
248+
return isMapped(name) && getHeaderMapRaw().get(name).intValue() < values.length; // N.B. Explicit (un)boxing is intentional
249249
}
250250

251251
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ boolean isStartOfLine(final int ch) {
198198
}
199199

200200
private char mapNullToDisabled(final Character c) {
201-
return c == null ? DISABLED : c.charValue();
201+
return c == null ? DISABLED : c.charValue(); // N.B. Explicit (un)boxing is intentional
202202
}
203203

204204
/**

0 commit comments

Comments
 (0)