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

Commit 6d5611f

Browse files
committed
Use final.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1695167 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0e91bea commit 6d5611f

6 files changed

Lines changed: 35 additions & 35 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public CSVParser(final Reader reader, final CSVFormat format) throws IOException
273273
* If there is a problem reading the header or skipping the first record
274274
* @since 1.1
275275
*/
276-
public CSVParser(final Reader reader, final CSVFormat format, long characterOffset, long recordNumber)
276+
public CSVParser(final Reader reader, final CSVFormat format, final long characterOffset, final long recordNumber)
277277
throws IOException {
278278
Assertions.notNull(reader, "reader");
279279
Assertions.notNull(format, "format");
@@ -361,7 +361,7 @@ public long getRecordNumber() {
361361
*/
362362
public List<CSVRecord> getRecords() throws IOException {
363363
CSVRecord rec;
364-
List<CSVRecord> records = new ArrayList<CSVRecord>();
364+
final List<CSVRecord> records = new ArrayList<CSVRecord>();
365365
while ((rec = this.nextRecord()) != null) {
366366
records.add(rec);
367367
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public CSVPrinter(final Appendable out, final CSVFormat format) throws IOExcepti
6767
// TODO: Is it a good idea to do this here instead of on the first call to a print method?
6868
// It seems a pain to have to track whether the header has already been printed or not.
6969
if (format.getHeaderComments() != null) {
70-
for (String line : format.getHeaderComments()) {
70+
for (final String line : format.getHeaderComments()) {
7171
if (line != null) {
7272
this.printComment(line);
7373
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public final class CSVRecord implements Serializable, Iterable<String> {
5151
private final String[] values;
5252

5353
CSVRecord(final String[] values, final Map<String, Integer> mapping, final String comment, final long recordNumber,
54-
long characterPosition) {
54+
final long characterPosition) {
5555
this.recordNumber = recordNumber;
5656
this.values = values != null ? values : EMPTY_STRING_ARRAY;
5757
this.mapping = mapping;

src/test/java/org/apache/commons/csv/CSVBenchmark.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public class CSVBenchmark {
6161
*/
6262
@Setup
6363
public void init() throws IOException {
64-
File file = new File("src/test/resources/perf/worldcitiespop.txt.gz");
65-
InputStream in = new GZIPInputStream(new FileInputStream(file));
64+
final File file = new File("src/test/resources/perf/worldcitiespop.txt.gz");
65+
final InputStream in = new GZIPInputStream(new FileInputStream(file));
6666
this.data = IOUtils.toString(in, "ISO-8859-1");
6767
in.close();
6868
}
@@ -72,8 +72,8 @@ private BufferedReader getReader() throws IOException {
7272
}
7373

7474
@Benchmark
75-
public int read(Blackhole bh) throws Exception {
76-
BufferedReader in = getReader();
75+
public int read(final Blackhole bh) throws Exception {
76+
final BufferedReader in = getReader();
7777
int count = 0;
7878
String line;
7979
while ((line = in.readLine()) != null) {
@@ -86,12 +86,12 @@ public int read(Blackhole bh) throws Exception {
8686
}
8787

8888
@Benchmark
89-
public int split(Blackhole bh) throws Exception {
90-
BufferedReader in = getReader();
89+
public int split(final Blackhole bh) throws Exception {
90+
final BufferedReader in = getReader();
9191
int count = 0;
9292
String line;
9393
while ((line = in.readLine()) != null) {
94-
String[] values = StringUtils.split(line, ',');
94+
final String[] values = StringUtils.split(line, ',');
9595
count += values.length;
9696
}
9797

@@ -101,13 +101,13 @@ public int split(Blackhole bh) throws Exception {
101101
}
102102

103103
@Benchmark
104-
public int parseCommonsCSV(Blackhole bh) throws Exception {
105-
BufferedReader in = getReader();
104+
public int parseCommonsCSV(final Blackhole bh) throws Exception {
105+
final BufferedReader in = getReader();
106106

107-
CSVFormat format = CSVFormat.DEFAULT.withHeader();
107+
final CSVFormat format = CSVFormat.DEFAULT.withHeader();
108108

109109
int count = 0;
110-
for (CSVRecord record : format.parse(in)) {
110+
for (final CSVRecord record : format.parse(in)) {
111111
count++;
112112
}
113113

@@ -117,10 +117,10 @@ public int parseCommonsCSV(Blackhole bh) throws Exception {
117117
}
118118

119119
@Benchmark
120-
public int parseGenJavaCSV(Blackhole bh) throws Exception {
121-
BufferedReader in = getReader();
120+
public int parseGenJavaCSV(final Blackhole bh) throws Exception {
121+
final BufferedReader in = getReader();
122122

123-
CsvReader reader = new CsvReader(in);
123+
final CsvReader reader = new CsvReader(in);
124124
reader.setFieldDelimiter(',');
125125

126126
int count = 0;
@@ -135,10 +135,10 @@ public int parseGenJavaCSV(Blackhole bh) throws Exception {
135135
}
136136

137137
@Benchmark
138-
public int parseJavaCSV(Blackhole bh) throws Exception {
139-
BufferedReader in = getReader();
138+
public int parseJavaCSV(final Blackhole bh) throws Exception {
139+
final BufferedReader in = getReader();
140140

141-
com.csvreader.CsvReader reader = new com.csvreader.CsvReader(in, ',');
141+
final com.csvreader.CsvReader reader = new com.csvreader.CsvReader(in, ',');
142142
reader.setRecordDelimiter('\n');
143143

144144
int count = 0;
@@ -152,10 +152,10 @@ public int parseJavaCSV(Blackhole bh) throws Exception {
152152
}
153153

154154
@Benchmark
155-
public int parseOpenCSV(Blackhole bh) throws Exception {
156-
BufferedReader in = getReader();
155+
public int parseOpenCSV(final Blackhole bh) throws Exception {
156+
final BufferedReader in = getReader();
157157

158-
com.opencsv.CSVReader reader = new com.opencsv.CSVReader(in, ',');
158+
final com.opencsv.CSVReader reader = new com.opencsv.CSVReader(in, ',');
159159

160160
int count = 0;
161161
while (reader.readNext() != null) {
@@ -168,13 +168,13 @@ public int parseOpenCSV(Blackhole bh) throws Exception {
168168
}
169169

170170
@Benchmark
171-
public int parseSkifeCSV(Blackhole bh) throws Exception {
172-
BufferedReader in = getReader();
171+
public int parseSkifeCSV(final Blackhole bh) throws Exception {
172+
final BufferedReader in = getReader();
173173

174-
org.skife.csv.CSVReader reader = new org.skife.csv.SimpleReader();
174+
final org.skife.csv.CSVReader reader = new org.skife.csv.SimpleReader();
175175
reader.setSeperator(',');
176176

177-
CountingReaderCallback callback = new CountingReaderCallback();
177+
final CountingReaderCallback callback = new CountingReaderCallback();
178178
reader.parse(in, callback);
179179

180180
bh.consume(callback);
@@ -186,16 +186,16 @@ private static class CountingReaderCallback implements org.skife.csv.ReaderCallb
186186
public int count = 0;
187187

188188
@Override
189-
public void onRow(String[] fields) {
189+
public void onRow(final String[] fields) {
190190
count++;
191191
}
192192
}
193193

194194
@Benchmark
195-
public int parseSuperCSV(Blackhole bh) throws Exception {
196-
BufferedReader in = getReader();
195+
public int parseSuperCSV(final Blackhole bh) throws Exception {
196+
final BufferedReader in = getReader();
197197

198-
CsvListReader reader = new CsvListReader(in, CsvPreference.STANDARD_PREFERENCE);
198+
final CsvListReader reader = new CsvListReader(in, CsvPreference.STANDARD_PREFERENCE);
199199

200200
int count = 0;
201201
List<String> record = null;

src/test/java/org/apache/commons/csv/CSVParserTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public void testExcelHeaderCountLessThanData() throws Exception {
395395
final String code = "A,B,C,,\r\na,b,c,d,e\r\n";
396396
final CSVParser parser = CSVParser.parse(code, CSVFormat.EXCEL.withHeader());
397397
try {
398-
for (CSVRecord record : parser.getRecords()) {
398+
for (final CSVRecord record : parser.getRecords()) {
399399
Assert.assertEquals("a", record.get("A"));
400400
Assert.assertEquals("b", record.get("B"));
401401
Assert.assertEquals("c", record.get("C"));
@@ -917,7 +917,7 @@ private void validateRecordNumbers(final String lineSeparator) throws IOExceptio
917917
private void validateRecordPosition(final String lineSeparator) throws IOException {
918918
final String nl = lineSeparator; // used as linebreak in values for better distinction
919919

920-
String code = "a,b,c" + lineSeparator + "1,2,3" + lineSeparator +
920+
final String code = "a,b,c" + lineSeparator + "1,2,3" + lineSeparator +
921921
// to see if recordPosition correctly points to the enclosing quote
922922
"'A" + nl + "A','B" + nl + "B',CC" + lineSeparator +
923923
// unicode test... not very relevant while operating on strings instead of bytes, but for

src/test/java/org/apache/commons/csv/CSVPrinterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public void testJdbcPrinterWithResultSetMetaData() throws IOException, ClassNotF
281281
}
282282

283283
private void setUpTable(final Connection connection) throws SQLException {
284-
Statement statement = connection.createStatement();
284+
final Statement statement = connection.createStatement();
285285
try {
286286
statement.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
287287
statement.execute("insert into TEST values(1, 'r1')");

0 commit comments

Comments
 (0)