Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thospfuller/ba0f1461b782deea3422f88152b7f88d to your computer and use it in GitHub Desktop.
Save thospfuller/ba0f1461b782deea3422f88152b7f88d to your computer and use it in GitHub Desktop.
The JCopyBookConverter.readCopyBookAsJDataFrameBuilder method from the RCOBOLDI package with the JAMon monitor and log invocations removed for brevity.
private JDataFrameBuilder<String, String[]> readCopyBookAsJDataFrameBuilder(
AbstractLineReader reader,
LayoutDetail layout,
String font,
IUpdateFieldName updateFldName
) throws IOException {
JDataFrameBuilder<String, String[]> result =
new JDataFrameBuilder<String, String[]>(
new JDataFrame<String, String[]>(),
new RemoteAdapter<String, String[]>()
);
AbstractLine line;
RecordDetail rec = layout.getRecord(0);
for (int ctr = 1; ctr < rec.getFieldCount(); ctr++) {
var header = (updateFldName.updateName(rec.getField(ctr).getName()));
result.getDataFrame().addOrReturnExistingColumn(header);
}
int idx;
while ((line = reader.read()) != null) {
idx = line.getPreferredLayoutIdx();
if (0 <= idx) {
for (int ctr = 1; ctr < layout.getRecord(idx).getFieldCount(); ctr++) {
var header = rec.getField(ctr).getName();
var value = line.getFieldValue(idx, ctr);
var formattedValue = (String) null;
if (value != null && !(value.isSpaces() || value.isLowValues() || value.isHighValues()) && value.isFieldPresent())
formattedValue = value.asString();
result
.getDataFrame()
.addOrReturnExistingColumn(header)
.addValues(new String[]{formattedValue});
}
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment