Author: ggregory Date: Wed Nov 14 21:58:09 2012 New Revision: 1409464 URL: http://svn.apache.org/viewvc?rev=1409464&view=rev Log: Use the final keyword where possible.
Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.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/main/java/org/apache/commons/csv/Lexer.java commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.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/perf/PerformanceTest.java Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java?rev=1409464&r1=1409463&r2=1409464&view=diff ============================================================================== --- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java (original) +++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java Wed Nov 14 21:58:09 2012 @@ -130,7 +130,7 @@ public class CSVFormat implements Serial * the char used for value separation, must not be a line break character * @throws IllegalArgumentException if the delimiter is a line break character */ - public static CSVFormatBuilder newBuilder(char delimiter) { + public static CSVFormatBuilder newBuilder(final char delimiter) { return new CSVFormatBuilder(delimiter); } @@ -430,7 +430,7 @@ public class CSVFormat implements Serial * the char used for value separation, must not be a line break character * @throws IllegalArgumentException if the delimiter is a line break character */ - private CSVFormatBuilder(char delimiter){ + private CSVFormatBuilder(final char delimiter){ this(delimiter, null, null, null, null, false, false, null, null); } 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=1409464&r1=1409463&r2=1409464&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 Wed Nov 14 21:58:09 2012 @@ -152,7 +152,7 @@ public class CSVPrinter implements Flush println(); } - private void print(Object object, final CharSequence value, final int offset, final int len) throws IOException { + private void print(final Object object, final CharSequence value, final int offset, final int len) throws IOException { if (format.isQuoting()) { printAndQuote(object, value, offset, len); } else if (format.isEscaping()) { @@ -215,7 +215,7 @@ public class CSVPrinter implements Flush /* * Note: must only be called if quoting is enabled, otherwise will generate NPE */ - void printAndQuote(Object object, final CharSequence value, final int offset, final int len) throws IOException { + void printAndQuote(final Object object, final CharSequence value, final int offset, final int len) throws IOException { final boolean first = newLine; // is this the first value on this line? boolean quote = false; int start = offset; @@ -344,8 +344,8 @@ public class CSVPrinter implements Flush * @throws IOException * If an I/O error occurs */ - public void printRecords(Object[] values) throws IOException { - for (Object value : values) { + public void printRecords(final Object[] values) throws IOException { + for (final Object value : values) { if (value instanceof Object[]) { this.printRecord((Object[]) value); } else if (value instanceof Iterable) { @@ -364,8 +364,8 @@ public class CSVPrinter implements Flush * @throws IOException * If an I/O error occurs */ - public void printRecords(Iterable<?> values) throws IOException { - for (Object value : values) { + public void printRecords(final Iterable<?> values) throws IOException { + for (final Object value : values) { if (value instanceof Object[]) { this.printRecord((Object[]) value); } else if (value instanceof Iterable) { @@ -384,8 +384,8 @@ public class CSVPrinter implements Flush * @throws IOException * If an I/O error occurs */ - public void printRecords(ResultSet resultSet) throws SQLException, IOException { - int columnCount = resultSet.getMetaData().getColumnCount(); + public void printRecords(final ResultSet resultSet) throws SQLException, IOException { + final int columnCount = resultSet.getMetaData().getColumnCount(); while (resultSet.next()) { for (int i = 1; i <= columnCount; i++) { print(resultSet.getString(i)); 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=1409464&r1=1409463&r2=1409464&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 Wed Nov 14 21:58:09 2012 @@ -45,7 +45,7 @@ public class CSVRecord implements Serial /** The record number. */ private final long recordNumber; - CSVRecord(final String[] values, final Map<String, Integer> mapping, final String comment, long recordNumber) { + CSVRecord(final String[] values, final Map<String, Integer> mapping, final String comment, final long recordNumber) { this.recordNumber = recordNumber; this.values = values != null ? values : EMPTY_STRING_ARRAY; this.mapping = mapping; Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java?rev=1409464&r1=1409463&r2=1409464&view=diff ============================================================================== --- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java (original) +++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java Wed Nov 14 21:58:09 2012 @@ -65,7 +65,7 @@ abstract class Lexer { this.ignoreEmptyLines = format.getIgnoreEmptyLines(); } - private final char mapNullToDisabled(Character c) { + private final char mapNullToDisabled(final Character c) { return c == null ? DISABLED : c.charValue(); } Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java?rev=1409464&r1=1409463&r2=1409464&view=diff ============================================================================== --- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java (original) +++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java Wed Nov 14 21:58:09 2012 @@ -90,7 +90,7 @@ public class CSVFileParserTest { assertTrue(testName+" require 1 param", split.length >= 1); // first line starts with csv data file name final BufferedReader csvFile = new BufferedReader(new FileReader(new File(BASE, split[0]))); - CSVFormatBuilder builder = CSVFormat.newBuilder(',').withQuoteChar('"'); + final CSVFormatBuilder builder = CSVFormat.newBuilder(',').withQuoteChar('"'); CSVFormat fmt = builder.build(); boolean checkComments = false; for(int i=1; i < split.length; i++) { 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=1409464&r1=1409463&r2=1409464&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 Wed Nov 14 21:58:09 2012 @@ -440,8 +440,8 @@ public class CSVParserTest { @Test public void testRoundtrip() throws Exception { - StringWriter out = new StringWriter(); - CSVPrinter printer = new CSVPrinter(out, CSVFormat.DEFAULT); + final StringWriter out = new StringWriter(); + final CSVPrinter printer = new CSVPrinter(out, CSVFormat.DEFAULT); final String input = "a,b,c\r\n1,2,3\r\nx,y,z\r\n"; for (final CSVRecord record : CSVFormat.DEFAULT.parse(new StringReader(input))) { printer.printRecord(record); @@ -653,7 +653,7 @@ public class CSVParserTest { validateRecordNumbers(String.valueOf(CR)); } - private void validateRecordNumbers(String lineSeparator) throws IOException { + private void validateRecordNumbers(final String lineSeparator) throws IOException { final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.newBuilder().withRecordSeparator(lineSeparator).build()); CSVRecord record; assertEquals(0, parser.getRecordNumber()); @@ -670,7 +670,7 @@ public class CSVParserTest { assertEquals(3, parser.getRecordNumber()); } - private void validateLineNumbers(String lineSeparator) throws IOException { + private void validateLineNumbers(final String lineSeparator) throws IOException { final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.newBuilder().withRecordSeparator(lineSeparator).build()); assertEquals(0, parser.getLineNumber()); assertNotNull(parser.nextRecord()); Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java?rev=1409464&r1=1409463&r2=1409464&view=diff ============================================================================== --- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java (original) +++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/perf/PerformanceTest.java Wed Nov 14 21:58:09 2012 @@ -65,13 +65,13 @@ public class PerformanceTest { return new BufferedReader(new FileReader(BIG_FILE)); } - private long parse(final Reader in, boolean traverseColumns) throws IOException { + private long parse(final Reader in, final boolean traverseColumns) throws IOException { final CSVFormat format = CSVFormat.newBuilder().withIgnoreSurroundingSpaces(false).build(); long recordCount = 0; for (final CSVRecord record : format.parse(in)) { recordCount++; if (traverseColumns) { - for (String value : record) { + for (final String value : record) { // do nothing for now } } @@ -91,7 +91,7 @@ public class PerformanceTest { return count; } - public long testParseBigFile(boolean traverseColumns) throws Exception { + public long testParseBigFile(final boolean traverseColumns) throws Exception { final long startMillis = System.currentTimeMillis(); final long count = this.parse(this.getBufferedReader(), traverseColumns); final long totalMillis = System.currentTimeMillis() - startMillis;