When adding an address to the IndividualAttribute, e.g. RESIdence, then the address appears twice in the resulting file.
The reason seems to be that the EventEmitter used to print the IndividualAttribute includes the AddressEmitter as well as the IndividualEmitter#emitIndividualAttributes
Extract from EventEmitter
protected void emit() throws GedcomWriterException {
emitTagIfValueNotNull(startLevel, "TYPE", writeFrom.getSubType());
emitTagIfValueNotNull(startLevel, "DATE", writeFrom.getDate());
new PlaceEmitter(baseWriter, startLevel, writeFrom.getPlace()).emit();
new AddressEmitter(baseWriter, startLevel, writeFrom.getAddress()).emit(); // <--- Here the address is already emitted
emitTagIfValueNotNull(startLevel, "AGE", writeFrom.getAge());
emitTagIfValueNotNull(startLevel, "AGNC", writeFrom.getRespAgency());
emitTagIfValueNotNull(startLevel, "CAUS", writeFrom.getCause());
emitTagIfValueNotNull(startLevel, "RELI", writeFrom.getReligiousAffiliation());
emitTagIfValueNotNull(startLevel, "RESN", writeFrom.getRestrictionNotice());
new CitationEmitter(baseWriter, startLevel, writeFrom.getCitations()).emit();
new MultimediaLinksEmitter(baseWriter, startLevel, writeFrom.getMultimedia()).emit();
new NoteStructureEmitter(baseWriter, startLevel, writeFrom.getNoteStructures()).emit();
emitCustomFacts(startLevel, writeFrom.getCustomFacts());
}
Extract from IndividualEmitter
private void emitIndividualAttributes(int level, List<IndividualAttribute> attributes) throws GedcomWriterException {
if (attributes != null) {
for (IndividualAttribute a : attributes) {
emitTagWithOptionalValueAndCustomSubtags(level, a.getType().getTag(), a.getDescription());
new EventEmitter(baseWriter, level + 1, a).emit();
new AddressEmitter(baseWriter, level + 1, a.getAddress()).emit(); // <--- here it is emitted again
emitStringsWithCustomFacts(level + 1, a.getPhoneNumbers(), "PHON");
emitStringsWithCustomFacts(level + 1, a.getWwwUrls(), "WWW");
emitStringsWithCustomFacts(level + 1, a.getFaxNumbers(), "FAX");
emitStringsWithCustomFacts(level + 1, a.getEmails(), "EMAIL");
}
}
}
When adding an address to the
IndividualAttribute
, e.g. RESIdence, then the address appears twice in the resulting file.The reason seems to be that the
EventEmitter
used to print theIndividualAttribute
includes theAddressEmitter
as well as theIndividualEmitter#emitIndividualAttributes
Extract from
EventEmitter
Extract from
IndividualEmitter