/*
 *	EasyScout Boy Scouts of America tracking software.
 *	http://www.easyscout.org/
 *
 *	Copyright (C) 2000 Conan C. Albrecht
 *	conan@warp.cx
 *
 *	This program is released under the GNU license so tech-savvy
 *	Boy Scouts and others can enhance the program for the use
 *	of all.  Please e-mail changes to my address above so I can
 *	reintegrate into the main program at http://www.easyscout.org/.
 *	This way, all users mutually benefit one another in the spirit of
 *	scouting.
 *
 *	This program is free software; you can redistribute it and/or
 *	modify it under the terms of the GNU General Public License
 *	as published by the Free Software Foundation; either version 2
 *	of the License, or (at your option) any later version.
 *
 * 	Any and all changes to the program code must be documented with
 *  date, author name and e-mail, and a short description.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package cx.warp.scout;

import java.util.*;

/** Compares position objects */
public class PositionComparator implements Comparator{

	/** Compares one Activity to another, always sorting by date in decreasing order*/
	public int compare(Object o1, Object o2) {
		try {
			if (o1 instanceof Position && o2 instanceof Position) {
				Position a1 = (Position)o1;
				Position a2 = (Position)o2;
				return a2.getStartDate().compareTo(a1.getStartDate());
			}else{   // default to a consistent ordering by class name
				return o1.getClass().toString().compareTo(o2.getClass().toString());
			}//if
		}catch (Exception e) {
			e.printStackTrace();
			return -1;
		}//try
	}//compare
	
	/** Tests whether this comparator is equals to another comparator */
	public boolean equals(Object obj) {
		if (obj instanceof PositionComparator) {
			return true;
		}//if
		return false;
	}//equals


}//PositionComparator
