• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Author类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Author类属于nl.siegmann.epublib.domain包,在下文中一共展示了Author类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: emptyAuthorBookThrows

import nl.siegmann.epublib.domain.Author; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void emptyAuthorBookThrows() {
    String title = "Book with empty author";
    Book book = new Book();
    book.getMetadata().addTitle(new DcmesElement(title));
    book.getMetadata().addAuthor(new Author(""));
    new SuperBook(book, "fake", title.getBytes());
}
 
开发者ID:bkromhout,项目名称:Minerva,代码行数:9,代码来源:SuperBookTest.java


示例4: noPathBookThrows

import nl.siegmann.epublib.domain.Author; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void noPathBookThrows() {
    String title = "Book without path";
    Book book = new Book();
    book.getMetadata().addTitle(new DcmesElement(title));
    book.getMetadata().addAuthor(new Author("Book", "Author"));
    new SuperBook(book, null, title.getBytes());
}
 
开发者ID:bkromhout,项目名称:Minerva,代码行数:9,代码来源:SuperBookTest.java


示例5: emptyPathBookThrows

import nl.siegmann.epublib.domain.Author; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void emptyPathBookThrows() {
    String title = "Book with empty path";
    Book book = new Book();
    book.getMetadata().addTitle(new DcmesElement(title));
    book.getMetadata().addAuthor(new Author("Book", "Author"));
    new SuperBook(book, "", title.getBytes());
}
 
开发者ID:bkromhout,项目名称:Minerva,代码行数:9,代码来源:SuperBookTest.java


示例6: bookOpened

import nl.siegmann.epublib.domain.Author; //导入依赖的package包/类
@Override
public void bookOpened(final Book book) {

    AppCompatActivity activity = (AppCompatActivity) getActivity();

    if (activity == null) {
        return;
    }

    this.language = this.bookView.getBook().getMetadata().getLanguage();
    LOG.debug("Got language for book: " + language);

    this.bookTitle = book.getTitle();

    this.config.setLastReadTitle(this.bookTitle);

    this.titleBase = this.bookTitle;
    activity.setTitle(titleBase);
    this.titleBar.setText(titleBase);

    activity.supportInvalidateOptionsMenu();

    if (book.getMetadata() != null
            && !book.getMetadata().getAuthors().isEmpty()) {
        Author author = book.getMetadata().getAuthors().get(0);
        this.authorField.setText(author.getFirstname() + " "
                + author.getLastname());
    }

    backgroundHandler.post(() -> {
        try {
            libraryService.storeBook(fileName, book, true,
                    config.getCopyToLibraryOnScan());
        } catch (Exception io) {
            LOG.error("Copy to library failed.", io);
        }
    });

    updateFromPrefs();
}
 
开发者ID:benjamarle,项目名称:typhon,代码行数:41,代码来源:ReadingFragment.java


示例7: readAuthors

import nl.siegmann.epublib.domain.Author; //导入依赖的package包/类
private static List<Author> readAuthors(String authorTag, Element metadataElement) {
	NodeList elements = metadataElement.getElementsByTagNameNS(NAMESPACE_DUBLIN_CORE, authorTag);
	List<Author> result = new ArrayList<Author>(elements.getLength());
	for(int i = 0; i < elements.getLength(); i++) {
		Element authorElement = (Element) elements.item(i);
		Author author = createAuthor(authorElement);
		if (author != null) {
			result.add(author);
		}
	}
	return result;
	
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:14,代码来源:PackageDocumentMetadataReader.java


示例8: createNCXResource

import nl.siegmann.epublib.domain.Author; //导入依赖的package包/类
public static Resource createNCXResource(List<Identifier> identifiers, String title, List<Author> authors, TableOfContents tableOfContents) throws IllegalArgumentException, IllegalStateException, IOException {
	ByteArrayOutputStream data = new ByteArrayOutputStream();
	XmlSerializer out = EpubProcessorSupport.createXmlSerializer(data);
	write(out, identifiers, title, authors, tableOfContents);
	Resource resource = new Resource(NCX_ITEM_ID, data.toByteArray(), DEFAULT_NCX_HREF, MediatypeService.NCX);
	return resource;
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:8,代码来源:NCXDocument.java


示例9: 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


示例10: readCreators

import nl.siegmann.epublib.domain.Author; //导入依赖的package包/类
private static List<Author> readCreators(Element metadataElement) {
	return readAuthors(DCTags.creator, metadataElement);
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:4,代码来源:PackageDocumentMetadataReader.java


示例11: readContributors

import nl.siegmann.epublib.domain.Author; //导入依赖的package包/类
private static List<Author> readContributors(Element metadataElement) {
	return readAuthors(DCTags.contributor, metadataElement);
}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:4,代码来源:PackageDocumentMetadataReader.java


示例12: write

import nl.siegmann.epublib.domain.Author; //导入依赖的package包/类
public static void write(XmlSerializer serializer, List<Identifier> identifiers, String title, List<Author> authors, TableOfContents tableOfContents) throws IllegalArgumentException, IllegalStateException, IOException {
		serializer.startDocument(Constants.CHARACTER_ENCODING, false);
		serializer.setPrefix(EpubWriter.EMPTY_NAMESPACE_PREFIX, NAMESPACE_NCX);
		serializer.startTag(NAMESPACE_NCX, NCXTags.ncx);
//		serializer.writeNamespace("ncx", NAMESPACE_NCX);
//		serializer.attribute("xmlns", NAMESPACE_NCX);
		serializer.attribute(EpubWriter.EMPTY_NAMESPACE_PREFIX, NCXAttributes.version, NCXAttributeValues.version);
		serializer.startTag(NAMESPACE_NCX, NCXTags.head);

		for(Identifier identifier: identifiers) {
			writeMetaElement(identifier.getScheme(), identifier.getValue(), serializer);
		}
		
		writeMetaElement("generator", Constants.EPUBLIB_GENERATOR_NAME, serializer);
		writeMetaElement("depth", String.valueOf(tableOfContents.calculateDepth()), serializer);
		writeMetaElement("totalPageCount", "0", serializer);
		writeMetaElement("maxPageNumber", "0", serializer);

		serializer.endTag(NAMESPACE_NCX, "head");
		
		serializer.startTag(NAMESPACE_NCX, NCXTags.docTitle);
		serializer.startTag(NAMESPACE_NCX, NCXTags.text);
		// write the first title
		serializer.text(StringUtil.defaultIfNull(title));
		serializer.endTag(NAMESPACE_NCX, NCXTags.text);
		serializer.endTag(NAMESPACE_NCX, NCXTags.docTitle);
		
		for(Author author: authors) {
			serializer.startTag(NAMESPACE_NCX, NCXTags.docAuthor);
			serializer.startTag(NAMESPACE_NCX, NCXTags.text);
			serializer.text(author.getLastname() + ", " + author.getFirstname());
			serializer.endTag(NAMESPACE_NCX, NCXTags.text);
			serializer.endTag(NAMESPACE_NCX, NCXTags.docAuthor);
		}
		
		serializer.startTag(NAMESPACE_NCX, NCXTags.navMap);
		writeNavPoints(tableOfContents.getTocReferences(), 1, serializer);
		serializer.endTag(NAMESPACE_NCX, NCXTags.navMap);
		
		serializer.endTag(NAMESPACE_NCX, "ncx");
		serializer.endDocument();
	}
 
开发者ID:DASAR,项目名称:epublib-android,代码行数:43,代码来源:NCXDocument.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JiveProperties类代码示例发布时间:2022-05-23
下一篇:
Java PartitionAware类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap