001 /* PAVLOV -- Multiple Choice Study System
002 * Copyright (C) 2000 - 2004 T.J. Willis
003 *
004 * This program is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU General Public License
006 * as published by the Free Software Foundation; either version 2
007 * of the License, or (at your option) any later version.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, write to the Free Software
016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
017 *
018 * $Header: /cvsroot/pavlov/net/sourceforge/pavlov/library/AbstractLibrary.java,v 1.4 2004/05/29 02:29:59 tj_willis Exp $
019 */
020 package net.sourceforge.pavlov.library;
021
022 //import net.sourceforge.pavlov.event.BookAndChapterEvent;
023 import java.io.IOException;
024 import java.io.Writer;
025 import java.util.Collection;
026 import javax.swing.tree.DefaultMutableTreeNode;
027 import org.apache.log4j.*;
028
029 /**
030 * An interface to be implemented by classes that can act as a Pavlov Library,
031 * i.e. a set of AbstractBooks with AbstractChapters that can be accesses by
032 * name.
033 *
034 * @author <a href="mailto:tj_willis@users.sourceforge.net"></a>
035 * @version 1.0
036 * @has 1 Has 1..n net.sourceforge.pavlov.library.AbstractBook
037 */
038 public interface AbstractLibrary {
039
040 // /**
041 // * Returns a pair containing the named book and chapter
042 // * @param bkName a <code>String</code> value
043 // * @param cpName a <code>String</code> value
044 // * @return a <code>BookAndChapterEvent</code> value
045 // */
046 // BookAndChapterEvent getBookAndChapterSelectionEvent(String bkName, String cpName);
047
048 /**
049 * Returns the named Chapter from the named book. Null if either doesn't exist.
050 * @param bkName a <code>String</code> value
051 * @param cpName a <code>String</code> value
052 * @return a <code>Chapter</code> value
053 */
054 Chapter getChapter(String bkName, String cpName);
055
056 /**
057 * Returns all books as a Collection.
058 * @return a <code>Collection</code> value
059 * @deprecated
060 */
061 @Deprecated Collection<AbstractBook> getBookCollection();
062
063 /**
064 * Returns all books as a read-only Collection.
065 * @return a <code>Collection</code> value
066 */
067 Collection<AbstractBook> getBooksReadOnly();
068
069 /**
070 * Displays books and chapters as a tree.
071 * @param top a <code>DefaultMutableTreeNode</code> value
072 */
073 void populateTree(DefaultMutableTreeNode top);
074
075 // /**
076 // * Dumps the Library in XML format to the given writer.
077 // * Loops throught books, chapters, questions.
078 // * @param writer a <code>Writer</code> value
079 // * @exception IOException if an error occurs
080 // */
081 // void toXML(Writer writer) throws IOException;
082
083
084 /**
085 * Returns the named Book. Null if either doesn't exist.
086 * @param bkName a <code>String</code> value
087 * @return a <code>Book</code> value
088 */
089 AbstractBook getBook(String bkName);
090
091 /**
092 * Adds an AbstractBook to this library.
093 *
094 * @param b an <code>AbstractBook</code> value
095 */
096 void addBook(AbstractBook b);
097 /**
098 * Removes the named AbstractBook from this library.
099 *
100 * @param bookName a <code>String</code> value
101 */
102 void deleteBook(String bookName );
103 }