net.sourceforge.pavlov.library
Class Library

java.lang.Object
  extended by net.sourceforge.pavlov.library.Library
All Implemented Interfaces:
AbstractLibrary

public final class Library
extends Object
implements AbstractLibrary

Describes a Library, which is a collection of Books.

See Also:
Book, Chapter, Question

Constructor Summary
Library()
          Creates an empty library.
 
Method Summary
 void addBook(AbstractBook c)
          Adds the book to the library , keyed on Book.getName().
 void addBook(Book c)
          Adds the book to the library , keyed on Book.getName().
 void deleteBook(String bkName)
          Removes the named book from this library.
 AbstractBook getBook(String bkName)
          Returns the named book.
 Collection<AbstractBook> getBookCollection()
          Deprecated. Use getBooks()
 Collection<AbstractBook> getBooks()
          Returns all books as a Collection.
 Collection<AbstractBook> getBooksReadOnly()
          Returns all books as a read-only Collection.
 Chapter getChapter(String bkName, String cpName)
          Returns the named Chapter from the named book.
 File getDirectory()
          Describe getDirectory method here.
 void populateTree(DefaultMutableTreeNode top)
          Displays books and chapters as a tree.
 void save()
          Asks each book to save itself in its cannonical filename in my directory.
 void saveBook(Book b)
          Saves the given book in its cannonical filename in my directory.
 void setDirectory(File dir)
          Describe setDirectory method here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Library

public Library()
Creates an empty library.

Method Detail

setDirectory

public void setDirectory(File dir)
Describe setDirectory method here.

Parameters:
dir - a File value

getDirectory

public File getDirectory()
Describe getDirectory method here.

Returns:
a File value

getBookCollection

@Deprecated
public Collection<AbstractBook> getBookCollection()
Deprecated. Use getBooks()

Returns all books as a Collection.

Specified by:
getBookCollection in interface AbstractLibrary
Returns:
a Collection value

getBooksReadOnly

public Collection<AbstractBook> getBooksReadOnly()
Returns all books as a read-only Collection.

Specified by:
getBooksReadOnly in interface AbstractLibrary
Returns:
a Collection value

getBooks

public Collection<AbstractBook> getBooks()
Returns all books as a Collection.

Returns:
a Collection value

addBook

public void addBook(Book c)
Adds the book to the library , keyed on Book.getName().

Parameters:
c - a Book value

addBook

public void addBook(AbstractBook c)
Adds the book to the library , keyed on Book.getName().

Specified by:
addBook in interface AbstractLibrary
Parameters:
c - an AbstractBook value

save

public void save()
          throws IOException
Asks each book to save itself in its cannonical filename in my directory.

Throws:
IOException

saveBook

public void saveBook(Book b)
              throws IOException
Saves the given book in its cannonical filename in my directory.

Parameters:
b - a Book value
Throws:
IOException

populateTree

public void populateTree(DefaultMutableTreeNode top)
Displays books and chapters as a tree.

Specified by:
populateTree in interface AbstractLibrary
Parameters:
top - a DefaultMutableTreeNode value

getChapter

public Chapter getChapter(String bkName,
                          String cpName)
Returns the named Chapter from the named book. Null if either doesn't exist.

Specified by:
getChapter in interface AbstractLibrary
Parameters:
bkName - a String value
cpName - a String value
Returns:
a Chapter value

getBook

public AbstractBook getBook(String bkName)
Returns the named book.

Specified by:
getBook in interface AbstractLibrary
Parameters:
bkName - a String value
Returns:
a Book value

deleteBook

public void deleteBook(String bkName)
Removes the named book from this library.

Specified by:
deleteBook in interface AbstractLibrary
Parameters:
bkName - a String value