| 1 | |
package de.glossmaker.bib.datastructure; |
| 2 | |
|
| 3 | |
import de.glossmaker.gloss.datastructure.IItem; |
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 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 | |
} |