Skip to content

Commit

Permalink
Merge pull request #254 from imsweb/sas-value-too-long-251
Browse files Browse the repository at this point in the history
SAS value too long (#251)
  • Loading branch information
depryf committed Feb 9, 2024
2 parents 9676bfd + c17a609 commit c9ca011
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**Version 10.2**

- Changed data level errors from an exception to a validation error reported on the item.
- Fixed behavior of the reading SAS macro when it deals with fields that have a value too long in the XML file.

**Version 10.1**

Expand Down
24 changes: 15 additions & 9 deletions src/main/java/com/imsweb/naaccrxml/sas/SasXmlToFlat.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,17 +395,23 @@ protected boolean removeEldestEntry(Map.Entry<Integer, String> eldest) {
buf.append(paddedValue);
}
else {
int remainingLength = entry.getValue().getLength() - val.length();
if (remainingLength > 0) {
String remainingValue = cache2.get(remainingLength);
if (remainingValue == null) {
remainingValue = SasUtils.rightPadWithSpaces("", remainingLength);
cache2.put(remainingLength, remainingValue);
int defLength = entry.getValue().getLength();

if (val.length() > defLength)
buf.append(val.substring(0, defLength));
else {
int remainingLength = defLength - val.length();
if (remainingLength > 0) {
String remainingValue = cache2.get(remainingLength);
if (remainingValue == null) {
remainingValue = SasUtils.rightPadWithSpaces("", remainingLength);
cache2.put(remainingLength, remainingValue);
}
buf.append(val).append(remainingValue);
}
buf.append(val).append(remainingValue);
else
buf.append(val);
}
else
buf.append(val);
}
}
writer.write(buf.toString());
Expand Down

0 comments on commit c9ca011

Please sign in to comment.