A ton of great new features :)
- 8 - Added locale support to ParseDate processor
- 9 - Readers can now skip comments (via the skipComments CsvPreference) and Writers can write comments (via the writeComment() method)
- 23 - Upgrade to Dozer 5.4.0
- 24 - Added a quoteMode preference that allows quoting to be enabled when it's normally not required, as well as adding a csvEncoder preference that allows complete control over how CSV is encoded for writing.
- 25 - Added Collector and IsElementOf cell processors, which can be combined to ensure referential integrity. Collector can also help during development - you could apply a Collector (with a Set) to a column to find out all of the unique values for that column!
- 27 - Added support for boolean getters (e.g. isX()) to CsvBeanWriter
- 31 - CsvListReader now supports cell processors for CSV files with a variable number of columns
- 38 - AbstractCsvWriter.escapeString() now increments the line count correctly for embedded newlines
- 39 - CsvDozerBeanReader now accepts hints when reading into Lists of beans using indexed mapping
- Resurrected the speed benchmark tests. There's now a full suite of benchmark tests for all the readers/writers.
Just a small bug fix release to restore Java 5 compatibility (should also be more compatible with older versions of Android as well).
- 36 - CsvBeanReader allows a nameMapping array of the wrong size when processors aren't used
- 37 - Restore Java 5 compatibility
This is the final release of version 2.0.0, which fixes a few minor bugs found in version 2.0.0-beta-1. Please refer to the 2.0.0-beta-1 release notes below for a full list of new features, bug fixes and upgrade notes.
- 33 - Added missing WEDNESDAY enum literal to custom cell processor example
- 34 - Added SLF4J API jar to distribution zip file
- 35 - CsvListReader now returns a new List for each read() operation
- 100% RFC 4180 compliance
- 3 - Super CSV now supports mapping nested properties (deep mapping and index-based mapping) with the new CsvDozerBeanReader and CsvDozerBeanWriter (included in the super-csv-dozer-extension project).
- 12 - CsvBeanReader now supports any compatible setter method (as long as the parameter type - interface or object - is compatible with the object being set). Previously, the parameter type had to be an exact match on the object's type.
- 17 - All Writers implement Flushable
- 18 - OSGi support
- 19 - All Readers and Writers now implement Closeable
- 20 - Maven support (see details on the download page)
- 21 - All Readers now have a getUntokenizedRow() method for retrieving the raw String of the row just read (before it's been tokenized). All Readers and Writers now have a getRowNumber() method for getting the number of CSV rows read/written (including the header). This is different from getLineNumber(), which returns the physical line number, as rows may span more than one line (the CSV format allows for multiline fields, as long as they're within double-quotes).
- 12 - Fixed NPE in CsvBeanReader when value to set is null
- 14 - AbstractCsvWriter now escapes for trailing spaces
- 16 - Refactored Readers/Writers so it's no longer possible to modify preferences
- 19 - Fixed NPE in SuperCsvException constructor
- 21 - New surroundingSpacesNeedQuotes preference allows the disabling of quoting for leading spaces
- 23 - CsvListWriter now allows all cell processors (not just String processors)
- 29 - Column numbers now start at 1 (instead of 0)
- 30 - All writers now allow null in the nameMapping array (except CsvDozerBeanWriter)
- Complete overhaul of javadoc
- Improved test coverage (now 100%!)
- More defensive programming (à la Josh Bloch's Effective Java). It's a lot harder to do silly stuff with the API now - for example CellProcessors will fail fast during construction if not set up correctly, instead of during execution.
- A new and improved maven site (please like/+1 us!)
- Removed dependency on the Spiffy library - Super CSV (excluding the new Dozer extension) is now completely standalone!
As this is a major release and it's been 4 years since the last release, there have been numerous changes that are not backwards-compatible with older versions. Here's an overview of things to be aware of when upgrading from version 1.52:
- General changes
- The treatment of spaces surrounding a cell has changed
- All spaces are now considered important (to conform to RFC 4180), and surrounding spaces won't be trimmed by default
- A new preference has been added to enable/disable this functionality (see the section on surroundingSpacesNeedQuotes on the preferences page).
- Line number, row number (a new property of both readers and writers) and column number all start from 1. This means:
- the get(int n) method of all Readers now expects the column number to begin at 1 (it was previously 0)
- the column number reported in Exceptions (via the CsvContext object) begins at 1
- the new row number property refers to one record of CSV (which may span multiple physical lines) - this number begins at 1 and includes the header
- line number refers to the physical line of CSV being read/written and begins at 1 (same as before).
- CsvPreference is now immutable, and must be constructed using its internal builder (see the preferences page)
- All classes with CSV in their name have been renamed to Csv. The new names are:
- Exceptions have been tidied up
- ClassCastInputCSVException and NullInputException have been removed (SuperCsvCellProcessorException is now used when an unexpected type or null input is encountered in a cell processor).
- SuperCsvException has been updated. It no longer contains the offending processor, as there's a new exception (SuperCsvCellProcessorException) for this.
- SuperCsvCellProcessorException has been added as a general exception for anything that goes wrong during cell processor execution.
- SuperCsvConstraintViolationException has been added. This exception is only thrown when the processor can accept the input (it's of the expected type and not null), but it doesn't satisfy the constraint. For example, if LMinMax encounters a Long value, but it is outside the required range then a SuperCsvConstraintViolationException will be thrown. If the LMinMax processor encounters a decimal value (e.g. 1.5), then a general SuperCsvCellProcessorException will be thrown.
- Changes related to reading
- The getCSVHeader() on all Readers has been renamed to getHeader() (to match writeHeader() on Writers)
- All Readers will now read empty columns (i.e. "") as null (previously they would be read as ""). The Optional processor has been updated to cater for this.
- All Readers now implement Closeable
- All Readers now have a getUntokenizedRow() method which returns the untokenized CSV row that was just read
- All Readers now have a getRowNumber() method which returns the number of the CSV row just read (essentially the number of records, including the header)
- CsvListReader now returns a List of Objects (not Strings) when CellProcessors are used
- CsvMapReader read() methods no longer have wildcards in their return type
- CsvBeanReader now allows any compatible setter method to be used (e.g. if the value to map to the bean is a Double, then a setter that expects a Number will now work - previously the setter would have to expect a Double as well).
- Changes related to writing
- All Writers will now write null columns as "" (previously this would have caused an Exception).
- All Writers now implement Closeable
- All Writers now implement Flushable - so you can flush the stream without closing.
- All Writers now have a getRowNumber() method which returns the number of the CSV row just written (essentially the number of records, including the header)
- Changes related to CellProcessors
- The Optional processor now matches on null instead of "". This means it can now be used for reading and writing.
- The Required, StrForbidden, and StrRegExReplace processors have been removed. Instead, you should use RequireHashCode, ForbidSubStr, and StrReplace respectively.
- The Trim processor now trims whitespace (i.e. String.trim()). The new Truncate processor contains the old Trim functionality.
- The min/max constants in DMinMax and LMinMax have all been renamed, and extra constants added to distinguish between signed/unsigned 8-bit min/max values.
- StrRegEx now uses Matcher.matches() instead of Matcher.find(), so the regular expression must match the whole field
- All processors have been updated to use the new exception classes SuperCsvCellProcessorException and SuperCsvConstraintViolationException
- Bug in CsvListWriter on null inputs
- Improved processors. Extended auto boxing types to include boolean, float and double.
Added the following cell processors
- Equals - test if all values are equals alone, or equals to a given constant
- FmtBool - format as a string any Boolean value
- HashMapper - to map encountered values with other objects/values
- IsIncludedIn - to ensure input value belongs to a specific set of given values
- NotNull - to ensure non-null values for columns
- ParseBigDecimal - parse a string to get a big decimal
- StrNotNullOrEmpty - to ensure non-null or empty values for columns
- StrReplace - for string manipulation
- StrRegExReplace - for string manipulation
Deprecated the following cell processors
- Required, re-implemented as RequiredHashCode
A new processor named Unique (based on equals()) has been created - the old definition based on hashCode() has been renamed to UniqueHashCode.
BeanReader and BeanWriter now supports method overloading of get/set methods.
Cell processors now only throw SuperCSVException
Added the following exceptions
- NullInputException: this exception is raised now for unexpected 'null' input value for processor. Numerous processors have been modified to use that exception class.
Better handling of lines without the expected number of columns
- The raised exception is now associated with a valid CSVContext object (previously, this object was 'null')
Better error messages, more context information in the exception and available to the programmer
- Just copy over the .jar file and notice the deprecated classes...
Improved integration and convenience
- BeanReader now accepts interface types to read into. The reader will create an implementation on-the-fly of the interface and use this.
- The ITokenizer interface has become public, making 3rd party extensions better integrated.
- The exception class now contains the file context in which it was thrown. And generally, all places exceptions are thrown have been cleaned up, streamlined and now passes the file context upon an exception.
- An overloaded read() has been removed entirely
- Added the following new cell processors: ParseBigDecimal
- A new exception SuperCSVReflectionException replaces annoying Java checked exceptions ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException
- More methods now use the var-args ("...") notation for easy use.
Improved processors and partial writing
- Added the ConvertNullTo cell processor which enables better support for writing partial objects, maps and lists.
- Changed method signatures to use the var-args ("...") notation to make the programming more natural. This has been done for:
- writeHeader() on all Writers
- ForbidSubStr, Required, and StrLen
- Small bugfix in processor StrLen
- More documentation on the web
Improved robustness and speed
- Made the CSV Encoder more robust (used when writing CSV files)
- Made the CSV encoder faster. Around 25% faster!
- Added a lot of tests.
- Set up an environment in dir slow_tests to enable future development to easily compare efficiency with older versions of the same functionality
Faster and better
- Introduced new cell processors ParseChar, ForbidSubStr, RequireSubStr
- Made the tokenizer 5% faster (the thing that reads and interprets the CSV files)! Reading files has never been faster!
- The framework now support plugging in new tokenizers onto readers. Feel free to author your own fast tokenizer
- Improved the Javadoc for some processors
- Added source branch specifically for tokenizer speed testing and comparison. It is now easy to experiment with various tokenizing strategies.
- Empty cells with value "" was mistakenly interpreted as an escaped quoted char rather than the empty line
- No longer removes trailing spaces inside quotes so " hello " is read as " hello " rather than " hello"
- Renamed the cell processor MagicToken to Token
- TABs are not regarded as whitespace anymore
- Inherited properties are now supported by the bean reader/writer
- JAR file is now compiled for JDK 5.