Skip to content

Commit

Permalink
Merge branch 'internalFieldNames' of https://github.com/hbz/rpb into …
Browse files Browse the repository at this point in the history
…main

See #31
  • Loading branch information
fsteeg committed Jun 13, 2023
2 parents 73a6d50 + 0a33a50 commit 5f60664
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 130 deletions.
12 changes: 8 additions & 4 deletions app/rpb/Decode.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,21 @@ private void processFields(final String[] vals) {
} else if(inMultiVolumeRecord && "#01 ".equals(k)) {
if(volumeCounter == 0) {
// we're still in the main (multi volume) record, so we mark that here:
getReceiver().literal("#36t", "MultiVolumeBook");
getReceiver().literal(fieldName("#36t"), "MultiVolumeBook");
}
getReceiver().endRecord(); // first time, we end main record, then each volume
volumeCounter++;
final String fullRecordId = recordId + "b" + volumeCounter;
getReceiver().startRecord(fullRecordId);
getReceiver().literal("#00 ", fullRecordId);
getReceiver().literal("#20ü", recordTitle);
getReceiver().literal(fieldName("#00 "), fullRecordId);
getReceiver().literal(fieldName("#20ü"), recordTitle);
}
getReceiver().literal(k, v);
getReceiver().literal(fieldName(k), v);
}
}

private String fieldName(final String f) { // `#00 ` --> `f00_`
return f.replaceAll("#([^ ]{2}) ", "f$1_").replaceAll("#([^ ]{3})", "f$1");
}

}
Loading

0 comments on commit 5f60664

Please sign in to comment.