Thanks for your quick response. See my comments market with %%
%% I see your point-of-view here, but somehow this makes me disappointed because I now need more than one Reader to accomplish this. It CAN be done the way you describe here, but then again: why should I read the input more than twice, when there is no need for it to read it twice? Your solution solves the problem, but also creates a speed gap: reading the lines twice just to figure out if the EOF was reached. Why not let BeanIO handle that by configuring an EOF character setting?
%% This is also true for situations when BeanIO discovers undefined lines in the stream that are not defined within the mapping: it gives an UnidentifiedRecordException as a result.
%% Now you would think: well, that is logically correct. Yep, true that is, BUT what if I know what kind of records there are within the file/stream that I don't want to read but still can be found within that file/stream? Normally BeanIO will throw an UnidentifiedRecordException. Well maybe it isn't an unidentified record, and maybe it isn't an error after all. Maybe I just want BeanIO to skip/ignore these kind of records/lines (suppress them) and just carry on reading the rest of the file/stream?
That can also be said about the EOF character, that can be interpreted as a special record that needs to be ignored by BeanIO. That way BeanIO doesn't throw an UnidentifiedRecordException and I don't need to use more that one Reader class for reading in the files/streams. That saves me a lot of extra work and provides faster speeds (FYI: reading 10.000 files twice gives an unnecessary delay).
%% So I was thinking about these options:
1. possibility for the user to define special characters in BeanIO, like an EOF character/line,
2. possibility for the user to define records in a stream that can be detected by BeanIO but are fully skipped/ignored by BeanIO.
3. catch an UnidentifiedRecordException by the user and ignore the record/line.
4. read all lines and filter out lines that don't need to be in the stream before feeding the "leftover" lines into BeanIO, so that no UnidentifiedRecordExceptions are thrown. This is the solution your wrote here.
%% To be honest, options 1 and 2 are IMHO better looking solutions then options 3 and 4. When you look closer to solution number 4, you will see that what the user has to do, is write its own mini-parser in order to suppress BeanIO exceptions.
I think that the power of BeanIO should be to let the user give complete control over how the file/stream is being parsed without creating the need for the user to write it's own mini-parser as a (sort of) pass-through filter. That is somewhat overkill to me.
%% I think BeanIO should handle the parsing completely and not a combination of BeanIO+some handwritten glue code to make it work with BeanIO :-(
%% BTW: There is no option in BeanIO to fully ignore a defined record. This could be handy in case records need to be skipped and to let BeanIO NOT throw an exception. I don't need to handle an exception when I know beforehand that these records exist within the stream and that I know I want to ignore them.
%% I hope that I have convinced you to implement these features in BeanIO? They will be helpful for a lot of people I think.
%% Anyways, thanks for your help and quick responses!
%% Cheers,
%% JD