You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2015/08/10 23:08:58 UTC

svn commit: r1695167 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/ test/java/org/apache/commons/csv/

Author: ggregory
Date: Mon Aug 10 21:08:58 2015
New Revision: 1695167

URL: http://svn.apache.org/r1695167
Log:
Use final.

Modified:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVBenchmark.java
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java

Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java?rev=1695167&r1=1695166&r2=1695167&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java Mon Aug 10 21:08:58 2015
@@ -273,7 +273,7 @@ public final class CSVParser implements
      *             If there is a problem reading the header or skipping the first record
      * @since 1.1
      */
-    public CSVParser(final Reader reader, final CSVFormat format, long characterOffset, long recordNumber)
+    public CSVParser(final Reader reader, final CSVFormat format, final long characterOffset, final long recordNumber)
             throws IOException {
         Assertions.notNull(reader, "reader");
         Assertions.notNull(format, "format");
@@ -361,7 +361,7 @@ public final class CSVParser implements
      */
     public List<CSVRecord> getRecords() throws IOException {
         CSVRecord rec;
-        List<CSVRecord> records = new ArrayList<CSVRecord>();
+        final List<CSVRecord> records = new ArrayList<CSVRecord>();
         while ((rec = this.nextRecord()) != null) {
             records.add(rec);
         }

Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java?rev=1695167&r1=1695166&r2=1695167&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java Mon Aug 10 21:08:58 2015
@@ -67,7 +67,7 @@ public final class CSVPrinter implements
         // TODO: Is it a good idea to do this here instead of on the first call to a print method?
         // It seems a pain to have to track whether the header has already been printed or not.
         if (format.getHeaderComments() != null) {
-            for (String line : format.getHeaderComments()) {
+            for (final String line : format.getHeaderComments()) {
                 if (line != null) {
                     this.printComment(line);
                 }

Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java?rev=1695167&r1=1695166&r2=1695167&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java Mon Aug 10 21:08:58 2015
@@ -51,7 +51,7 @@ public final class CSVRecord implements
     private final String[] values;
 
     CSVRecord(final String[] values, final Map<String, Integer> mapping, final String comment, final long recordNumber,
-            long characterPosition) {
+            final long characterPosition) {
         this.recordNumber = recordNumber;
         this.values = values != null ? values : EMPTY_STRING_ARRAY;
         this.mapping = mapping;

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVBenchmark.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVBenchmark.java?rev=1695167&r1=1695166&r2=1695167&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVBenchmark.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVBenchmark.java Mon Aug 10 21:08:58 2015
@@ -61,8 +61,8 @@ public class CSVBenchmark {
      */
     @Setup
     public void init() throws IOException {
-        File file = new File("src/test/resources/perf/worldcitiespop.txt.gz");
-        InputStream in = new GZIPInputStream(new FileInputStream(file));
+        final File file = new File("src/test/resources/perf/worldcitiespop.txt.gz");
+        final InputStream in = new GZIPInputStream(new FileInputStream(file));
         this.data = IOUtils.toString(in, "ISO-8859-1");
         in.close();
     }
@@ -72,8 +72,8 @@ public class CSVBenchmark {
     }
 
     @Benchmark
-    public int read(Blackhole bh) throws Exception {
-        BufferedReader in = getReader();
+    public int read(final Blackhole bh) throws Exception {
+        final BufferedReader in = getReader();
         int count = 0;
         String line;
         while ((line = in.readLine()) != null) {
@@ -86,12 +86,12 @@ public class CSVBenchmark {
     }
 
     @Benchmark
-    public int split(Blackhole bh) throws Exception {
-        BufferedReader in = getReader();
+    public int split(final Blackhole bh) throws Exception {
+        final BufferedReader in = getReader();
         int count = 0;
         String line;
         while ((line = in.readLine()) != null) {
-            String[] values = StringUtils.split(line, ',');
+            final String[] values = StringUtils.split(line, ',');
             count += values.length;
         }
         
@@ -101,13 +101,13 @@ public class CSVBenchmark {
     }
 
     @Benchmark
-    public int parseCommonsCSV(Blackhole bh) throws Exception {
-        BufferedReader in = getReader();
+    public int parseCommonsCSV(final Blackhole bh) throws Exception {
+        final BufferedReader in = getReader();
         
-        CSVFormat format = CSVFormat.DEFAULT.withHeader();
+        final CSVFormat format = CSVFormat.DEFAULT.withHeader();
 
         int count = 0;
-        for (CSVRecord record : format.parse(in)) {
+        for (final CSVRecord record : format.parse(in)) {
             count++;
         }
 
@@ -117,10 +117,10 @@ public class CSVBenchmark {
     }
 
     @Benchmark
-    public int parseGenJavaCSV(Blackhole bh) throws Exception {
-        BufferedReader in = getReader();
+    public int parseGenJavaCSV(final Blackhole bh) throws Exception {
+        final BufferedReader in = getReader();
         
-        CsvReader reader = new CsvReader(in);
+        final CsvReader reader = new CsvReader(in);
         reader.setFieldDelimiter(',');
 
         int count = 0;
@@ -135,10 +135,10 @@ public class CSVBenchmark {
     }
 
     @Benchmark
-    public int parseJavaCSV(Blackhole bh) throws Exception {
-        BufferedReader in = getReader();
+    public int parseJavaCSV(final Blackhole bh) throws Exception {
+        final BufferedReader in = getReader();
         
-        com.csvreader.CsvReader reader = new com.csvreader.CsvReader(in, ',');
+        final com.csvreader.CsvReader reader = new com.csvreader.CsvReader(in, ',');
         reader.setRecordDelimiter('\n');
 
         int count = 0;
@@ -152,10 +152,10 @@ public class CSVBenchmark {
     }
 
     @Benchmark
-    public int parseOpenCSV(Blackhole bh) throws Exception {
-        BufferedReader in = getReader();
+    public int parseOpenCSV(final Blackhole bh) throws Exception {
+        final BufferedReader in = getReader();
         
-        com.opencsv.CSVReader reader = new com.opencsv.CSVReader(in, ',');
+        final com.opencsv.CSVReader reader = new com.opencsv.CSVReader(in, ',');
 
         int count = 0;
         while (reader.readNext() != null) {
@@ -168,13 +168,13 @@ public class CSVBenchmark {
     }
 
     @Benchmark
-    public int parseSkifeCSV(Blackhole bh) throws Exception {
-        BufferedReader in = getReader();
+    public int parseSkifeCSV(final Blackhole bh) throws Exception {
+        final BufferedReader in = getReader();
         
-        org.skife.csv.CSVReader reader = new org.skife.csv.SimpleReader();
+        final org.skife.csv.CSVReader reader = new org.skife.csv.SimpleReader();
         reader.setSeperator(',');
         
-        CountingReaderCallback callback = new CountingReaderCallback();
+        final CountingReaderCallback callback = new CountingReaderCallback();
         reader.parse(in, callback);
 
         bh.consume(callback);
@@ -186,16 +186,16 @@ public class CSVBenchmark {
         public int count = 0;
 
         @Override
-        public void onRow(String[] fields) {
+        public void onRow(final String[] fields) {
             count++;
         }
     }
 
     @Benchmark
-    public int parseSuperCSV(Blackhole bh) throws Exception {
-        BufferedReader in = getReader();
+    public int parseSuperCSV(final Blackhole bh) throws Exception {
+        final BufferedReader in = getReader();
         
-        CsvListReader reader = new CsvListReader(in, CsvPreference.STANDARD_PREFERENCE);
+        final CsvListReader reader = new CsvListReader(in, CsvPreference.STANDARD_PREFERENCE);
 
         int count = 0;
         List<String> record = null;

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java?rev=1695167&r1=1695166&r2=1695167&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java Mon Aug 10 21:08:58 2015
@@ -395,7 +395,7 @@ public class CSVParserTest {
         final String code = "A,B,C,,\r\na,b,c,d,e\r\n";
         final CSVParser parser = CSVParser.parse(code, CSVFormat.EXCEL.withHeader());
         try {
-            for (CSVRecord record : parser.getRecords()) {
+            for (final CSVRecord record : parser.getRecords()) {
                 Assert.assertEquals("a", record.get("A"));
                 Assert.assertEquals("b", record.get("B"));
                 Assert.assertEquals("c", record.get("C"));
@@ -917,7 +917,7 @@ public class CSVParserTest {
     private void validateRecordPosition(final String lineSeparator) throws IOException {
         final String nl = lineSeparator; // used as linebreak in values for better distinction
 
-        String code = "a,b,c" + lineSeparator + "1,2,3" + lineSeparator +
+        final String code = "a,b,c" + lineSeparator + "1,2,3" + lineSeparator +
         // to see if recordPosition correctly points to the enclosing quote
                 "'A" + nl + "A','B" + nl + "B',CC" + lineSeparator +
                 // unicode test... not very relevant while operating on strings instead of bytes, but for

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java?rev=1695167&r1=1695166&r2=1695167&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java Mon Aug 10 21:08:58 2015
@@ -281,7 +281,7 @@ public class CSVPrinterTest {
     }
 
     private void setUpTable(final Connection connection) throws SQLException {
-        Statement statement = connection.createStatement();
+        final Statement statement = connection.createStatement();
         try {
             statement.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
             statement.execute("insert into TEST values(1, 'r1')");