Package nl.siegmann.epublib.domain

Examples of nl.siegmann.epublib.domain.Identifier


      String schemeName = identifierElement.getAttributeNS(NAMESPACE_OPF, DCAttributes.scheme);
      String identifierValue = DOMUtil.getTextChildrenContent(identifierElement);
      if (StringUtil.isBlank(identifierValue)) {
        continue;
      }
      Identifier identifier = new Identifier(schemeName, identifierValue);
      if(identifierElement.getAttribute("id").equals(bookIdId) ) {
        identifier.setBookId(true);
      }
      result.add(identifier);
    }
    return result;
  }
View Full Code Here


  public void test_empty_book() {
    Book book = new Book();
    FixIdentifierBookProcessor fixIdentifierBookProcessor = new FixIdentifierBookProcessor();
    Book resultBook = fixIdentifierBookProcessor.processBook(book);
    assertEquals(1, resultBook.getMetadata().getIdentifiers().size());
    Identifier identifier = CollectionUtil.first(resultBook.getMetadata().getIdentifiers());
    assertEquals(Identifier.Scheme.UUID, identifier.getScheme());
  }
View Full Code Here

    assertEquals(Identifier.Scheme.UUID, identifier.getScheme());
  }

  public void test_single_identifier() {
    Book book = new Book();
    Identifier identifier = new Identifier(Identifier.Scheme.ISBN, "1234");
    book.getMetadata().addIdentifier(identifier);
    FixIdentifierBookProcessor fixIdentifierBookProcessor = new FixIdentifierBookProcessor();
    Book resultBook = fixIdentifierBookProcessor.processBook(book);
    assertEquals(1, resultBook.getMetadata().getIdentifiers().size());
    Identifier actualIdentifier = CollectionUtil.first(resultBook.getMetadata().getIdentifiers());
    assertEquals(identifier, actualIdentifier);
  }
View Full Code Here

   * @throws IllegalStateException
   * @throws IllegalArgumentException
   * @
   */
  private static void writeIdentifiers(List<Identifier> identifiers, XmlSerializer serializer) throws IllegalArgumentException, IllegalStateException, IOException  {
    Identifier bookIdIdentifier = Identifier.getBookIdIdentifier(identifiers);
    if(bookIdIdentifier == null) {
      return;
    }
   
    serializer.startTag(NAMESPACE_DUBLIN_CORE, DCTags.identifier);
    serializer.attribute(EpubWriter.EMPTY_NAMESPACE_PREFIX, DCAttributes.id, BOOK_ID_ID);
    serializer.attribute(NAMESPACE_OPF, OPFAttributes.scheme, bookIdIdentifier.getScheme());
    serializer.text(bookIdIdentifier.getValue());
    serializer.endTag(NAMESPACE_DUBLIN_CORE, DCTags.identifier);

    for(Identifier identifier: identifiers.subList(1, identifiers.size())) {
      if(identifier == bookIdIdentifier) {
        continue;
View Full Code Here

public class FixIdentifierBookProcessor implements BookProcessor {

  @Override
  public Book processBook(Book book) {
    if(book.getMetadata().getIdentifiers().isEmpty()) {
      book.getMetadata().addIdentifier(new Identifier());
    }
    return book;
  }
View Full Code Here

      titles.add(title);
      book.getMetadata().setTitles(titles);
    }
   
    if(StringUtils.isNotBlank(isbn)) {
      book.getMetadata().addIdentifier(new Identifier(Identifier.Scheme.ISBN, isbn));
    }
   
    initAuthors(authorNames, book);
   
    OutputStream result;
View Full Code Here

    Book book = new Book();
   
    book.getMetadata().addTitle("Epublib test book 1");
    book.getMetadata().addTitle("test2");
   
    book.getMetadata().addIdentifier(new Identifier(Identifier.Scheme.ISBN, "987654321"));
    book.getMetadata().addAuthor(new Author("Joe", "Tester"));
    book.setCoverPage(new Resource(this.getClass().getResourceAsStream("/book1/cover.html"), "cover.html"));
    book.setCoverImage(new Resource(this.getClass().getResourceAsStream("/book1/cover.png"), "cover.png"));
    book.addSection("Chapter 1", new Resource(this.getClass().getResourceAsStream("/book1/chapter1.html"), "chapter1.html"));
    book.addResource(new Resource(this.getClass().getResourceAsStream("/book1/book1.css"), "book1.css"));
View Full Code Here

      Assert.assertEquals("Three Men in a Boat", metadata.getFirstTitle());

      // test identifier
      Assert.assertNotNull(metadata.getIdentifiers());
      Assert.assertEquals(1, metadata.getIdentifiers().size());
      Identifier identifier = metadata.getIdentifiers().get(0);
      Assert.assertEquals("URI", identifier.getScheme());
      Assert.assertEquals("zelda@mobileread.com:2010040720", identifier.getValue());
     
      Assert.assertEquals("8", metadata.getMetaAttribute("calibre:rating"));
      Assert.assertEquals("cover_pic", metadata.getMetaAttribute("cover"));
    }
View Full Code Here

TOP

Related Classes of nl.siegmann.epublib.domain.Identifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.