001    /* BEE - Book Editing Environment for PAVLOV
002     * Copyright (C) 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/bee/QuestionRightAnswerComparator.java,v 1.2 2004/05/10 14:46:07 tj_willis Exp $
019     */
020    package net.sourceforge.bee;
021    
022    import java.util.Comparator;
023    import net.sourceforge.pavlov.library.*;
024    
025    
026    /**
027     * Compares two questions alphabetically by their correct answer text.
028      * FIXME: move to pavlov.library.
029    *
030     * @author <a href="mailto:"></a>
031     * @version 1.0
032     */
033    public class QuestionRightAnswerComparator
034    implements Comparator
035    {
036    
037        /**
038         * Describe <code>compare</code> method here.
039         *
040         * @param o1 an <code>Object</code> value
041         * @param o2 an <code>Object</code> value
042         * @return an <code>int</code> value
043         */
044        public int compare(Object o1, Object o2) 
045     {
046        Question q1 = null;
047        Question q2 = null;
048        try {
049           q1 = (Question)o1;
050           q2 = (Question)o2;
051        } catch (Exception e) {}
052        if(q1==null) return -1;
053        if(q2==null) return 1;
054        String id1, id2;
055        id1 = q1.getRightAnswer();
056        id2 = q2.getRightAnswer();
057        if(id1==null) return -1;
058        if(id2==null) return 1;
059        return id1.compareTo(id2); 
060     }
061        /**
062         * Describe <code>equals</code> method here.
063         *
064         * @param obj an <code>Object</code> value
065         * @return a <code>boolean</code> value
066         */
067        public boolean equals(Object obj) { return false; }
068    }