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/ChapterReference.java,v 1.2 2004/05/29 02:29:59 tj_willis Exp $
019     */ 
020    package net.sourceforge.pavlov.library;
021    import java.util.*;
022    import java.io.*;
023    import org.apache.log4j.*;
024    
025    /**
026     * Locates a chapter.
027     *
028     * @author <a href="mailto:tj_willis@users.sourceforge.net"></a>
029     * @version 1.0
030     * @see Question  
031     * @see Book
032     * @see Library
033     * @has 1 Has 1..n net.sourceforge.pavlov.library.Chapter
034     */
035    public class ChapterReference extends BookReference {
036       
037        // FIXME: add to CVS
038        //private String bkName;
039        protected String cpName;
040        //private AbstractLibrary lib;
041    
042        public ChapterReference(AbstractLibrary library,String bookName, String chapterName)
043        {
044            super(library,bookName);
045            //lib = library;
046            //bkName = bookName;
047            cpName = chapterName;
048        }
049    
050        public String getChapterName()
051        {
052            return cpName;
053        }
054    
055        public boolean isAChapter()
056        {
057            if(getChapter()==null) return false;
058            return true;
059        }
060    
061        public boolean isABook()
062        {
063            if(getChapter()!=null) return false;
064            if(getBook()==null) return false;
065            return true;
066        }
067    
068        public Chapter getChapter()
069        {
070            return lib.getChapter(bkName, cpName);
071        }
072    
073    }
074