JRecord
The JRecord is for reading
- Binary Files
- Fixed field width files
- CSV (Delimited) files
- XML (via a StAX parser).
- Supports non-standard file Structures (i.e. Mainframe VB and Fixed Length).
JRecord also provides great flexibility in
- JRecord supports several non standard file structure (Fixed-Length Lines / Length-Based lines).
It can also be extended to support other File Structures.
- JRecord currently supports Cobol and its own Xml Record Layouts. It could be extended to support
be extended to support other Record-Layouts.
Important packages in JRecord:
- Details - Holds File & line definition classes. Important Interfaces / classes
- IO - Record Oriented IO routines. Important classes
- AbstractLineReader Abstract Class for reading AbstractLine's from a file.
All Reader's extend this class.
- AbstractLineReader Abstract Class for writing AbstractLine's to a file.
All Writer's extend this class.
- CobolIOProvider - Will create / provide a class's to read / write a Cobol file.
- LineIOProvider provide classes to read write files of a specified structure.
- External - Classes to read, write and convert File Definitions (Copybooks or Record Layouts).
- ExternalRecord Record Layout interchange format. It can be read/written from external
files and converted to the internal format LayoutDetail.
- ToRecordLayout Convert a ExternalRecord class to an LayoutDetail class.
- ToExternalRecord Convert a LayoutDetail class to an ExternalRecord class.
- RecordEditorXmlLoader Loads a RecordEditor-Xml Layout as ExternalRecord
- RecordEditorXmlWrite Writes ExternalRecord to a file in the RecordEditor-Xml format
- CopybookLoaderFactory The method getLayoutRecordEditXml which will load a RecordEditor-Xml file as
a RecordLayout.
- Type - Classes to convert a field from the External Representation
to the Internal format.
- ByteIO - Low level IO routines, most user should not need to look at this package
Following is an example of reading & writing a file using a RecordEditor-XML record-layout
LayoutDetail layout = CopybookLoaderFactory.getInstance().getLayoutRecordEditXml(copybookName, null);
int fileStructure = layout.getFileStructure();
AbstractLineReader reader = LineIOProvider.getInstance().getLineReader(fileStructure);
AbstractLineWriter writer = LineIOProvider.getInstance().getLineWriter(fileStructure);
reader.open(salesFile, layout);
writer.open(salesFileOut);
while ((saleRecord = reader.read()) != null) {
AbstractFieldValue salePrice = saleRecord.getFieldValue("SALE-PRICE");
salePrice.set(salePrice.asDouble() / GST_CONVERSION);
writer.write(saleRecord);
}
reader.close();
writer.close();
RecordEditor Interface
The following classes are used by the RecordEditor as interfaces to JRecord. You can extend the
RecordEditor by changing the appropriate interface class.
- CopybookWriterManager - tells the RecordEditor what File base RecordLayouts can be loaded.
- CopybookLoaderFactory - tells the RecordEditor what File base RecordLayouts can be written.
- LineIOProvider - tells the RecordEditor what file structures are supported.
- TypeManager - tells the RecordEditor what Types are supported. Note: the RecordEditor extends this class
- ConversionManager - tells the RecordEditor what Cobol numeric versions are available - ie how
to translate Cobol numbers to RecordEditot / JRecord types.