本文整理汇总了Java中nl.siegmann.epublib.domain.Author.getFirstname方法的典型用法代码示例。如果您正苦于以下问题:Java Author.getFirstname方法的具体用法?Java Author.getFirstname怎么用?Java Author.getFirstname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nl.siegmann.epublib.domain.Author
的用法示例。
在下文中一共展示了Author.getFirstname方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFirstAuthor
import nl.siegmann.epublib.domain.Author; //导入方法依赖的package包/类
/**
* Get the first non-empty author from the given {@link Book}.
* @param book Book.
* @return Author string as "FirstName LastName" (or just first or last name, if only one is filled in). If {@code
* book} is {@code null}, or has no authors, or author names are empty strings, returns {@code null}.
*/
public static String getFirstAuthor(Book book) {
if (book == null || book.getMetadata().getAuthors().isEmpty()) return null;
// Loop through authors to get first non-empty one.
for (Author author : book.getMetadata().getAuthors()) {
String fName = author.getFirstname();
String lName = author.getLastname();
// Skip this author now if it doesn't have a non-null, non-empty name.
if ((fName == null || fName.isEmpty()) && (lName == null || lName.isEmpty())) continue;
// Return the name, which might only use one of the strings.
if (fName == null || fName.isEmpty()) return lName;
if (lName == null || lName.isEmpty()) return fName;
return fName + " " + lName;
}
return null;
}
示例2: generateCoverPage
import nl.siegmann.epublib.domain.Author; //导入方法依赖的package包/类
private String generateCoverPage(Book book) {
String centerpiece;
//Else we construct a basic front page with title and author.
if ( book.getCoverImage() == null ) {
centerpiece = "<center><h1>" + (book.getTitle() != null ? book.getTitle(): "Book without a title") + "</h1>";
if ( ! book.getMetadata().getAuthors().isEmpty() ) {
for ( Author author: book.getMetadata().getAuthors() ) {
centerpiece += "<h3>" + author.getFirstname() + " " + author.getLastname() + "</h3>";
}
} else {
centerpiece += "<h3>Unknown author</h3>";
}
centerpiece += "</center>";
} else {
//If the book has a cover image, we display that
centerpiece = "<img src='" + book.getCoverImage().getHref() + "'>";
}
return "<html><body>" + centerpiece + "</body></html>";
}
示例3: getAuthor
import nl.siegmann.epublib.domain.Author; //导入方法依赖的package包/类
/**
* Get the ebook's author.
*
* @return The author in line-representation.
*/
private List<Line> getAuthor() {
List<Line> author = new ArrayList<Line>();
if (!ebook.getMetadata().getAuthors().isEmpty()) {
for (Author nameParts : ebook.getMetadata().getAuthors()) {
String authorName = nameParts.getFirstname() + " " + nameParts.getLastname() + ";";
author.add(new EpubModuleLine(authorName, false));
}
// remove ; from last author
String lastAuthor = author.get(author.size() - 1).getText();
author.get(author.size() - 1).setText(lastAuthor.substring(0, lastAuthor.length() - 1));
}
return author;
}