Skip to content

Let FlatFileItemReader comment detection logic be customizable #1134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jan 29, 2016 · 1 comment
Closed

Comments

@spring-projects-issues
Copy link
Collaborator

Ville Virtanen opened BATCH-2468 and commented

We have a complex file format where there are lines that are comments and should not be read, but the format of these comments can't be determined using simple startsWith comparisons.

It would be great if the FlatFileItemReader could take a class instance in a setter that implements interface, let's say CommentDetector (and provide the current functionality by default) so that we could supply our own CommentDetector instance. The interface would be like

public interface CommentDetector {
    isComment(String line, String[] comments);
}

where the line parameter is, well the line that should be determined if it is a comment or not and comments array containing the comment line prefixes that the reader already has.

Does not affect backwards compatibility, makes it possible to implement custom detection logic without extending. (Which currently is hard/impossible because the methods that contain the detection logic are private.)


No further details from BATCH-2468

@fmbenhassine
Copy link
Contributor

Which currently is hard/impossible because the methods that contain the detection logic are private

I don't think we need to introduce a new concept for this use case (trying to avoid API bloat). I suggest to change the visibility of the FlatFileItemReader#isComment method and the FlatFileItemReader.comments field to protected. With that, it should be possible to override the method and customize the comment detection logic as needed.

@fmbenhassine fmbenhassine removed the status: waiting-for-triage Issues that we did not analyse yet label Feb 5, 2020
@fmbenhassine fmbenhassine added this to the 4.3.0 milestone Feb 5, 2020
@fmbenhassine fmbenhassine self-assigned this May 28, 2020
@fmbenhassine fmbenhassine changed the title Let FlatFileItemReader comment detection logic be customizable [BATCH-2468] Let FlatFileItemReader comment detection logic be customizable Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants