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