use of org.jabref.model.entry.AuthorList in project jabref by JabRef.
the class CrossRef method toAuthors.
private String toAuthors(JSONArray authors) {
if (authors == null) {
return "";
}
// input: list of {"given":"A.","family":"Riel","affiliation":[]}
AuthorList authorsParsed = new AuthorList();
for (int i = 0; i < authors.length(); i++) {
JSONObject author = authors.getJSONObject(i);
authorsParsed.addAuthor(author.optString("given", ""), "", "", author.optString("family", ""), "");
}
return authorsParsed.getAsFirstLastNamesWithAnd();
}
use of org.jabref.model.entry.AuthorList in project jabref by JabRef.
the class NormalizeNamesFormatter method format.
@Override
public String format(String nameList) {
Objects.requireNonNull(nameList);
AuthorList authorList = AuthorList.parse(nameList);
return authorList.getAsLastFirstNamesWithAnd(false);
}
use of org.jabref.model.entry.AuthorList in project jabref by JabRef.
the class Authors method format.
@Override
public String format(String fieldText) {
if (fieldText == null) {
return "";
}
StringBuilder sb = new StringBuilder();
AuthorList al = AuthorList.parse(fieldText);
if ((maxAuthors < 0) || (al.getNumberOfAuthors() <= maxAuthors)) {
for (int i = 0; i < al.getNumberOfAuthors(); i++) {
Author a = al.getAuthor(i);
addSingleName(sb, a, (flMode == Authors.FIRST_FIRST) || ((flMode == Authors.LF_FF) && (i > 0)));
if (i < (al.getNumberOfAuthors() - 2)) {
sb.append(separator);
} else if (i < (al.getNumberOfAuthors() - 1)) {
sb.append(lastSeparator);
}
}
} else {
for (int i = 0; i < Math.min(al.getNumberOfAuthors() - 1, authorNumberEtAl); i++) {
if (i > 0) {
sb.append(separator);
}
addSingleName(sb, al.getAuthor(i), flMode == Authors.FIRST_FIRST);
}
sb.append(etAlString);
}
return sb.toString();
}
use of org.jabref.model.entry.AuthorList in project jabref by JabRef.
the class CreateDocBookAuthors method addBody.
public void addBody(StringBuilder sb, AuthorList al, String tagName) {
for (int i = 0; i < al.getNumberOfAuthors(); i++) {
sb.append('<').append(tagName).append('>');
Author a = al.getAuthor(i);
a.getFirst().filter(first -> !first.isEmpty()).ifPresent(first -> sb.append("<firstname>").append(CreateDocBookAuthors.XML_CHARS.format(first)).append("</firstname>"));
a.getVon().filter(von -> !von.isEmpty()).ifPresent(von -> sb.append("<othername>").append(CreateDocBookAuthors.XML_CHARS.format(von)).append("</othername>"));
a.getLast().filter(last -> !last.isEmpty()).ifPresent(last -> {
sb.append("<surname>").append(CreateDocBookAuthors.XML_CHARS.format(last));
a.getJr().filter(jr -> !jr.isEmpty()).ifPresent(jr -> sb.append(' ').append(CreateDocBookAuthors.XML_CHARS.format(jr)));
sb.append("</surname>");
});
if (i < (al.getNumberOfAuthors() - 1)) {
sb.append("</").append(tagName).append(">\n ");
} else {
sb.append("</").append(tagName).append('>');
}
}
}
use of org.jabref.model.entry.AuthorList in project jabref by JabRef.
the class CreateDocBookAuthors method format.
@Override
public String format(String fieldText) {
StringBuilder sb = new StringBuilder(100);
AuthorList al = AuthorList.parse(fieldText);
addBody(sb, al, FieldName.AUTHOR);
return sb.toString();
}
Aggregations