CobolIoProvider.getLineReader with InputStream instead of String filename?
Read Cobol data files in Java
Status: Beta
Brought to you by:
bruce_a_martin
I would find it quite helpful to have a CobolIoProvider.getLineReader() which took an InputStream instead of a file name, especially for the copybook, but also for the input data... it's much more flexible.
Anonymous
I will have look at doing this
I am little concerned at having similar methods with a lot of parameters. I was thinking a Builder type approach might be better:
It should lead to simpler clearer code !!!
Also at the moment, You can do:
I realize this is more long winded than the CobolIoProvider. CobolIoProvider was always intended handle just the simple cases, I would prefer not to complicate it to much
Thanks! I think the Builder approach would work well.
In general when designing library interfaces which are processing some stream of bytes(characters) I try to stay far away from String filenames, File objects, or anything else which implies a particular set of operations that need to be applied before you can read(write) the data. I figure that the caller knows their source/sink better than my library, so they can arrange to apply the operations to get it into an Input(Output)Stream before calling the library.
I agree with what you said, if I was writing JRecord now I would do things quite differently. Basically with JRecord
Please give me your thoughts on Builder approach. I am thinking of making it the standard way of accessing JRecord.
I do have thoughts of doing a complete rewrite of JRecord with all the, so please pass through any suggestions
In version 0.80.8 I have created a new IOBuilder classes which can be used like
The IOBuilder will accept either filenames or streams as input for Cobol-Copyybooks, Input-Files and Output-Files.
This has been implemented now
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Hi, I amusing jrecord 0.82 but could not find newIOBuilder. Iwant to process input streams
Please help
For a Cobol file you would start with JRecordInterface1
i.e.
or using the fully qualified class name
For a Fixed-Width file (no Cobol Copybook):
For a Csv File
etc
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Hi Thanks for ur quick response. I tried above option but getting JRecordInterface1 cannt be resolved. Iam ajava developer and want to validate cobol datafile againstcobol copybook fileand both are in inputstreams . Iam using jrecord0.82. please letme know ifabove thing can be achieved using this version.
The latest JRecord is 0.81.4:
Have a look in the Source/JRecord_IO_Builder_Examples this sub projects contains examples of using JRecord. In particular, src\net\sf\JRecord\zExamples\iob\cobol contains Cobol examples.
I will come back to this later
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Hi Bruce, Is there a way to validate data against the copybook schema. Now am able to parse the data but it does not seem to validate the datatypes and patterns. Please suggest
There is not anything builtin to
validatethe data. the Best option is to the CobolSchemaDetails class. You can use it like:This will return:
Cobol Tree+ JRecord Field definitions added in to it.The IItem has a lot of Cobol definitions (e.g. Cobol Picture, Display-Length, decimal etc). It can be cast back to Item for extra details (like Cobol 88 level details). If you do need more details from Item let me know I can update IItem if neen be. Alternalively take a copy of net.sf.JRecord.schema. There are not a huge number of classes and it is based on the cb2xml Jaxb example.
So you would need to write your own validation.
Note: you can use
to create an IOBuilder from a
layoutorschema.Last edit: Bruce Martin 2016-12-29