use of org.jabref.model.entry.Author 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.Author 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.Author in project jabref by JabRef.
the class OOBibStyle method getAuthorLastName.
/**
* Look up the nth author and return the proper last name for citation markers.
*
* @param al The author list.
* @param number The number of the author to return.
* @return The author name, or an empty String if inapplicable.
*/
private String getAuthorLastName(AuthorList al, int number) {
StringBuilder sb = new StringBuilder();
if (al.getNumberOfAuthors() > number) {
Author a = al.getAuthor(number);
a.getVon().filter(von -> !von.isEmpty()).ifPresent(von -> sb.append(von).append(' '));
sb.append(a.getLast().orElse(""));
}
return sb.toString();
}
Aggregations