Releases: uniVocity/univocity-parsers
Releasing Java 9 compatible version
This is the first Java 9 compatible version
DO NOT use any previous release with Java 9 as it will blow up.
-
string.getChars
used to throw ArrayIndexOutOfBoundsException (tested on JDK 6-8) but now it throwsStringIndexOutOfBoundsException
. This version was updated to catchIndexOutOfBoundsException
instead so it can work with all JDKs (tested from 6 to 9). -
SimpleDateFormat
- Changes in the locales "broke" previously working date formats. If the default locale is "en_AU" then the following won't work with JDK 9:new SimpleDateFormat("yyyy-MMM-dd").parse("2015-DEC-25")
Classes with annotations for dates now allow users to provide a locale. For example:
@Parsed
@Format(formats = "dd-MMM-yyyy", options = "locale=en_US_WIN")
private Date myDate;
//if you are in Australia, MMM will translate to the abbreviated format followed by period,
//i.e. "October" becomes "Oct.". The formatter won't work to parse dates such as "2015-Oct-20"
//Use "locale=en" to make it behave as it always did in Java 8 or earlier.
@Parsed
@Format(formats = "dd-MMM-yyyy", options = "locale=en")
private Date australianDay;
Also fixed a bug on the TrimConversion
introduced in version 2.5.5 - it would break processing blank or empty strings.
Critical bug fix for regression introduced in 2.5.0
Fixed concurrency issue processing File
or InputStream
with no explicit character encoding provided, when setReadInputOnSeparateThread=true
(the default). The issue could make the parser discard the first character of the input.
More details in: #186 and #187
** Other adjustments **
-
Improved CSV format detection
-
Fixed
TrimConversion
to remove trailing whitespaces when input is truncated to a maximum length.
More bugfixes
BUGFIXES
Invalid values being produced when column selection is defined, reordering is disabled and number of headers is less than number of selected columns. (#183)
ParsingContext of *Routines returns information of the following row instead of the current (#184)
currentParsedContent
returns a first-char-repeated string from ByteArrayInputStream
with setReadInputOnSeparateThread
disabled (#185)
Fixed issues handling values with unescaped quotes at the end of the input, and in combination with the keepQuotes
flag - commit.
ENHANCEMENTS
Allowing the same column to feed data into multiple fields of a java bean and its nested fields. Validation kicks in only if writing.
Further bug fixes
Bug fixes
-
CsvParserSettings.setDelimiterDetectionEnabled() not working with input file/stream when the character encoding is not explicitly provided. (#178)
-
CSV format autodetection thrown off by fields with single or double quote in the middle of the value (also in #178)
-
Fixed-width header extraction fails (#182)
-
Failure to extract header row with FixedWidthParser + annotations (#180)
Enhancements
- Custom conversion classes can now be defined without a
String[] args
constructor (#181) if no parameters are used.
Fixed bug in CSV parser
Fixed bug in CSV parser - line ending following escaped quote was handled was end of the record (Issue #177)
Fixing performance issue found in 2.5.0
The introduction of support for BOM marker handling created an unwanted side effect when the user does not provide the character encoding of the file being processed: performance is reduced significantly
This version fixes the problem and the performance should be equivalent of previous versions, regardless of the user providing a character encoding explicitly, or the input having a BOM marker.
Relevant issue: #176
"Massive" minor release with heaps of updates
ENHANCEMENTS
- Added methods to the parser that return Iterable<String[]> or Iterable(#151)
Rows can now be iterated like this:
for (String[] row : parser.iterate(input, "UTF-8")) {
//do stuff
}
And records:
for (Record row : parser.iterateRecords(new FileInputStream(input), "UTF-8")) {
//do stuff
}
- Support multiple header names in
field
attribute of@Parsed
annotation (#150)
You can now use the same POJO to parse different files with different headers.
- Adding a
HeaderTransformer
to the@Nested
annotation (#159)
This allows one to nest the same class inside a parent multiple times, by changing the names assigned to the nested properties. Example for a car with 4 wheels:
public static class Wheel {
@Parsed
String brand;
@Parsed
int miles;
}
public static class Car {
@Nested
Wheel frontLeft;
@Nested
Wheel frontRight;
@Nested
Wheel rearLeft;
@Nested
Wheel rearRight;
}
To parse an input with organized like this: frontLeftWheelBrand,frontLeftWheelMiles,frontRightWheelBrand,frontRightWheelMiles,rearLeftWheelBrand,rearLeftWheelMiles,rearRightWheelBrand,rearRightWheelMiles
, we need to apply a transformation to the property names of each Wheel
instance. This can be done with something like this:
public static class NameTransformer extends HeaderTransformer {
private String prefix;
public NameTransformer(String... args) {
prefix = args[0];
}
@Override
public String transformName(Field field, String name) {
return prefix + Character.toUpperCase(name.charAt(0)) + name.substring(1);
}
}
Now we can change the Nested
annotations to be:
public static class Car {
@Nested(headerTransformer = NameTransformer.class, args = "frontLeftWheel")
Wheel frontLeft;
@Nested(headerTransformer = NameTransformer.class, args = "frontRightWheel")
Wheel frontRight;
@Nested(headerTransformer = NameTransformer.class, args = "rearLeftWheel")
Wheel rearLeft;
@Nested(headerTransformer = NameTransformer.class, args = "rearRightWheel")
Wheel rearRight;
}
And parse the input with:
List<Car> cars = new CsvRoutines(settings).parseAll(Car.class, input);
- added support for annotations in methods (#160)
@Parsed
or @Nested
annotations now work on individual methods. Modifying the Car
example above to use a List<Wheel>
, one can do the followng:
public static class Car {
List<Wheel> wheels = new ArrayList<Wheel>();
@Nested(headerTransformer = NameTransformer.class, args = "frontLeftWheel")
private void setWheel1(Wheel wheel) { //bad method name created on purpose. Also private.
wheels.add(wheel);
}
@Nested(headerTransformer = NameTransformer.class, args = "frontRightWheel")
private void setWheel2(Wheel wheel) { //bad method name created on purpose. Also private.
wheels.add(wheel);
}
@Nested(headerTransformer = NameTransformer.class, args = "rearLeftWheel")
private void setWheel3(Wheel wheel) { //bad method name created on purpose. Also private.
wheels.add(wheel);
}
@Nested(headerTransformer = NameTransformer.class, args = "rearRightWheel")
private void setWheel4(Wheel wheel) { //bad method name created on purpose. Also private.
wheels.add(wheel);
}
}
-
added support and automatic handling of files with a BOM marker (#154)
-
Introduced properties
from
andto
to the@FixedWidth
annotation, along withFixedWidthFields.addField(int startPosition, int endPosition)
to allow declaring field ranges instead of fixed lengths (#166) -
enabled column reordering in CSV, TSV and Fixed-Width writers. This allows users to select which columns of their input should be written and prevents generating empty columns. Just use
selectFields
withsetColumnReorderingEnabled(true)
(#167) -
added a
keepResourcesOpen
property in CsvRoutines, TsvRoutines and FixedWidthRoutines to control whether or not to close theWriter
after writing data to the output. Also controls whether theResultSet
will closed when dumping data from it. (#172)
BUGS FIXED
-
CSV format auto-detection thrown off by seemingly regular CSV (#161)
-
Can't provide custom headers when dumping a ResultSet (#157)
-
ParsingContext.currentParsedContent returns null when input is single length string (#165)
-
NullValue and EmptyValue are both applied (#158)
-
NumberFormatException when using
record.getDate("field")
in a concurrent environment (#156) -
AutomaticConfiguration does not work with MultiBeanListProcessor (#149)
Maintenance version 2.4.1
This release includes:
-
a fix for concurrency issues processing annotations: #146
-
internal adjustments for exception handling and generation of error messages.
Next minor version 2.4.0
Enhancements
- Added support for nested objects with the newly introduced
@Nested
annotation: #139 CsvRoutines
and other routine classes provide aParsingContext
object: #136
Bugfixes:
- Fixed incorrect escape of CSV when writing a quote escape character with
setQuoteEscapingEnabled=true
before writing any other character that would prompt the writer to enclose the field in quotes: #143 - Fixed handling of unquoted values where two consecutive unescaped quotes appeared in the input:
#143 - IndexOutOfBoundsException when processing index-based annotations: 33a099c
- Fixed width writing from
ResultSet
should respect user provided field length instead of using the resultset length - #135 - Parser did not throw error in case input fails to be read (e.g. in case of socket timeouts, etc) and would just silently stop. #140