Coverage Report - de.glossmaker.bib.datastructure.Book
 
Classes in this File Line Coverage Branch Coverage Complexity
Book
100%
22/22
80%
21/26
2,6
 
 1  
 package de.glossmaker.bib.datastructure;
 2  
 
 3  
 import de.glossmaker.gloss.datastructure.IItem;
 4  
 
 5  
 /**
 6  
  * <p>This class implements the BibTeX <code>BOOK</code> item.</p>
 7  
  * Required fields:
 8  
  * <ul>
 9  
  *   <li>author or editor,</li>
 10  
  *   <li>title,</li>
 11  
  *   <li>publisher,</li>
 12  
  *   <li>year.</li>
 13  
  *  </ul>
 14  
  *  Optional fields:
 15  
  *  <ul>
 16  
  *    <li>volume or number,</li>
 17  
  *    <li>series,</li>
 18  
  *    <li>address,</li>
 19  
  *    <li>edition,</li>
 20  
  *    <li>month,</li>
 21  
  *    <li>note,</li>
 22  
  *    <li>isbn</li>
 23  
  *  </ul>
 24  
  *  
 25  
  * @author Markus Flingelli
 26  
  *
 27  
  */
 28  
 public class Book extends ABibItem {
 29  
 
 30  
         Book(String key, EBibTeXReference reference) {
 31  50
                 super(key, reference);
 32  50
         }
 33  
         
 34  
         private Book(String key, String title, String publisher, String year) {
 35  10
                 super(key, EBibTeXReference.BOOK);
 36  10
                 setTitle(title);
 37  10
                 setPublisher(publisher);
 38  10
                 setYear(year);
 39  10
         }
 40  
         
 41  
         public Book(String key, EBookType bookType, String author, String title, String publisher, String year) {
 42  8
                 this(key, title, publisher, year);
 43  8
                 if (bookType == EBookType.AUTHOR) {
 44  6
                         setAuthor(author);
 45  2
                 } else if (bookType == EBookType.EDITOR) {
 46  1
                         setEditor(author);
 47  
                 }
 48  8
         }
 49  
         
 50  
 
 51  
         @Override
 52  
         public boolean isItemValid() {
 53  8
                 boolean result = getKey() != null && getKey().length() > 0;
 54  8
                 result &= (getAuthor() != null && getAuthor().length() > 0) || 
 55  
                         (getEditor() != null && getEditor().length() > 0);
 56  8
                 result &= getTitle() != null && getTitle().length() > 0;
 57  8
                 result &= getPublisher() != null && getPublisher().length() > 0;
 58  8
                 result &= getYear() != null;
 59  8
                 return result;
 60  
         }
 61  
         
 62  
         @Override
 63  
         public IItem cloneItem() {
 64  2
                 Book clone = new Book(getKey(), getTitle(), getPublisher(), getYear());
 65  2
                 clone.setItemValues(this);
 66  2
                 return clone;
 67  
         }
 68  
 }