当前位置: 首页>>代码示例>>Java>>正文


Java Author.getLastname方法代码示例

本文整理汇总了Java中nl.siegmann.epublib.domain.Author.getLastname方法的典型用法代码示例。如果您正苦于以下问题:Java Author.getLastname方法的具体用法?Java Author.getLastname怎么用?Java Author.getLastname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nl.siegmann.epublib.domain.Author的用法示例。


在下文中一共展示了Author.getLastname方法的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;
}
 
开发者ID:bkromhout,项目名称:Minerva,代码行数:24,代码来源:DataUtils.java

示例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>";
}
 
开发者ID:benjamarle,项目名称:typhon,代码行数:26,代码来源:TyphonSpine.java

示例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;
}
 
开发者ID:vita-us,项目名称:ViTA,代码行数:19,代码来源:MetadataAnalyzerEpub.java


注:本文中的nl.siegmann.epublib.domain.Author.getLastname方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。