use of org.jabref.logic.importer.fileformat.mods.NameDefinition in project jabref by JabRef.
the class ModsExportFormat method addAffiliation.
private void addAffiliation(ModsDefinition mods, String value) {
NameDefinition nameDefinition = new NameDefinition();
StringPlusLanguage affiliation = new StringPlusLanguage();
affiliation.setValue(value);
JAXBElement<StringPlusLanguage> element = new JAXBElement<>(new QName(MODS_NAMESPACE_URI, "affiliation"), StringPlusLanguage.class, affiliation);
nameDefinition.getAffiliationOrRoleOrDescription().add(element);
mods.getModsGroup().add(nameDefinition);
}
use of org.jabref.logic.importer.fileformat.mods.NameDefinition in project jabref by JabRef.
the class ModsExportFormat method handleAuthors.
private void handleAuthors(ModsDefinition mods, String value) {
String[] authors = value.split("and");
for (String author : authors) {
NameDefinition name = new NameDefinition();
name.setAtType("personal");
NamePartDefinition namePart = new NamePartDefinition();
if (author.contains(",")) {
//if author contains "," then this indicates that the author has a forename and family name
int commaIndex = author.indexOf(',');
String familyName = author.substring(0, commaIndex);
namePart.setAtType("family");
namePart.setValue(familyName);
JAXBElement<NamePartDefinition> element = new JAXBElement<>(new QName(MODS_NAMESPACE_URI, "namePart"), NamePartDefinition.class, namePart);
name.getNamePartOrDisplayFormOrAffiliation().add(element);
//now take care of the forenames
String forename = author.substring(commaIndex + 1, author.length());
String[] forenames = forename.split(" ");
for (String given : forenames) {
if (!given.isEmpty()) {
NamePartDefinition namePartDefinition = new NamePartDefinition();
namePartDefinition.setAtType("given");
namePartDefinition.setValue(given);
element = new JAXBElement<>(new QName(MODS_NAMESPACE_URI, "namePart"), NamePartDefinition.class, namePartDefinition);
name.getNamePartOrDisplayFormOrAffiliation().add(element);
}
}
mods.getModsGroup().add(name);
} else {
//no "," indicates that there should only be a family name
namePart.setAtType("family");
namePart.setValue(author);
JAXBElement<NamePartDefinition> element = new JAXBElement<>(new QName(MODS_NAMESPACE_URI, "namePart"), NamePartDefinition.class, namePart);
name.getNamePartOrDisplayFormOrAffiliation().add(element);
mods.getModsGroup().add(name);
}
}
}
Aggregations