org.norvelle.textcite.model
Class Book

java.lang.Object
  extended by org.norvelle.textcite.model.AbstractCitationContainer
      extended by org.norvelle.textcite.model.Book

public class Book
extends AbstractCitationContainer

Book: Represents a publication (book for short) in the CiteBook database. Maintains a bibliographic identifier that should match that which the user's bibliographic software assigns to the same publication (e.g BibTex identifier)

Author:
Erik Norvelle

Nested Class Summary
static class Book.BookConverter
          BookConverter is an inner class used for serializing Book objects via XStream.
 
Field Summary
 
Fields inherited from class org.norvelle.textcite.model.AbstractCitationContainer
citations, citationsIds
 
Constructor Summary
protected Book()
          A parameterless constructor, so that we can recreate a serialized Book from XML.
  Book(java.lang.String n)
          Construct a brand-new Book object from scratch.
  Book(java.lang.String n, Author a, java.lang.String yp, java.lang.String bid)
          Construct a brand-new Book object from scratch, but supplying an Author object.
 
Method Summary
 boolean authorHasBook()
          Test whether this book is present in its Author's list of books
 void destroy()
          This routine eliminates the Citations that belong to this Book, and unregisters the Book from its associated Author.
 Author getAuthor()
           
 java.lang.String getBibId()
           
 java.util.HashMap<java.lang.Integer,Citation> getCitations()
           
 int getId()
           
 java.lang.String getName()
           
 int getObjectCount()
           
 BookOutlineTree getOutline()
           
 java.lang.String getUniqueIdentifier()
          Returns a String that uniquely identifies this Book
 java.lang.String getUniqueName()
          Returns a name that includes that of the author, in order to distinguish the book from others with the same name but by other authors
 java.lang.String getYearPublished()
           
 boolean hasOutline()
           
 void registerCitation(Citation citation)
          Mark a Citation object as belong to this Book.
 void restoreCitationReferences()
          This method restores the citations HashMap, filling it with references to the Citations indicated in the citationIds Vector.
 void setAuthor(Author newAuthor)
           
 void setBibId(java.lang.String bid)
           
 void setName(java.lang.String n)
          Change the name of the book.
 void setName(java.lang.String n, boolean register)
          Used internally to update a book name when a book by the same name exists, but by a different author.
 void setOutline(BookOutlineTree o)
           
 void setYearPublished(java.lang.String yp)
           
 java.lang.String toString()
           
 void unregisterCitation(Citation citation)
          Dissasociate a given Citation from this Book.
 
Methods inherited from class org.norvelle.textcite.model.AbstractCitationContainer
saveCitationReferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Book

public Book(java.lang.String n)
     throws DuplicateRecordException
Construct a brand-new Book object from scratch.

Parameters:
n - The name of the book to be added
Throws:
DuplicateRecordException

Book

public Book(java.lang.String n,
            Author a,
            java.lang.String yp,
            java.lang.String bid)
     throws DuplicateRecordException
Construct a brand-new Book object from scratch, but supplying an Author object.

Parameters:
a - The Author object to be assigned to this Book.
n - The name of the Book to be created
yp - The year of publication
bid - The bibliographic ID code to be assigned.
Throws:
DuplicateRecordException

Book

protected Book()
A parameterless constructor, so that we can recreate a serialized Book from XML.

Method Detail

registerCitation

public void registerCitation(Citation citation)
Mark a Citation object as belong to this Book. Also marks the Citation as belonging to the Author of this Book.

Parameters:
citation - The Citation object to be added

unregisterCitation

public void unregisterCitation(Citation citation)
Dissasociate a given Citation from this Book.

Parameters:
citation -

destroy

public void destroy()
This routine eliminates the Citations that belong to this Book, and unregisters the Book from its associated Author.


getId

public int getId()

hasOutline

public boolean hasOutline()
Returns:
True if the user has added outline items to this Book's outline tree

getName

public java.lang.String getName()

getUniqueName

public java.lang.String getUniqueName()
Returns a name that includes that of the author, in order to distinguish the book from others with the same name but by other authors


setName

public void setName(java.lang.String n)
             throws DuplicateRecordException
Change the name of the book. Checks to make sure there are no duplicate names in the list before allowing the change.

Parameters:
n - The new name for the book
Throws:
DuplicateRecordException - Thrown in case of a name clash

setName

public void setName(java.lang.String n,
                    boolean register)
             throws DuplicateRecordException
Used internally to update a book name when a book by the same name exists, but by a different author.

Parameters:
n - The new name
register - False if we shouldn't call registerBook() in the AuthorCollection.
Throws:
DuplicateRecordException

getAuthor

public Author getAuthor()

getYearPublished

public java.lang.String getYearPublished()
Returns:
Returns the year published.

setYearPublished

public void setYearPublished(java.lang.String yp)
Parameters:
yp - The year published to set.

getBibId

public java.lang.String getBibId()
Returns:
Returns the bibliographic identifier.

setBibId

public void setBibId(java.lang.String bid)
Parameters:
bid - The bibId to set.

setAuthor

public void setAuthor(Author newAuthor)
               throws DuplicateRecordException
Throws:
DuplicateRecordException

getOutline

public BookOutlineTree getOutline()
Returns:
Returns the outline.

setOutline

public void setOutline(BookOutlineTree o)
Parameters:
o - The BookOutlineTree to set as the book's outline

getCitations

public java.util.HashMap<java.lang.Integer,Citation> getCitations()

authorHasBook

public boolean authorHasBook()
Test whether this book is present in its Author's list of books


getObjectCount

public int getObjectCount()
Returns:
Returns the total number of objects contained in this Book. Returns 1 (one Book) plus the number of objects in the BookOutlineTree associated with it.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

restoreCitationReferences

public void restoreCitationReferences()
This method restores the citations HashMap, filling it with references to the Citations indicated in the citationIds Vector. Also delegates to the BookOutline tree to do the same for all the BookOutlineItems

Overrides:
restoreCitationReferences in class AbstractCitationContainer

getUniqueIdentifier

public java.lang.String getUniqueIdentifier()
Returns a String that uniquely identifies this Book