Created
March 30, 2021 01:57
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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