/*
Copyright (C) 2000-2010  Ministere de la culture et de la communication (France), AJLSM
See LICENCE file
 */
package fr.gouv.culture.sdx.utils.save;

import java.util.Comparator;

/**
 * @author jlecren
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class StringComparator implements Comparator {

	/** Compare files names.
	 * "*.sar" > everything else --> sar files are at the end of the list  
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
	public int compare(Object arg0, Object arg1) {
		String s0 =(String)arg0;
		String s1 =(String)arg1;
		
		if(s0.endsWith(".sar"))
			if(s1.endsWith(".sar"))
				return s0.compareTo(s1);
			else
				return 1;
		else if(s1.endsWith(".sar"))
			return -1;
		else
			return s0.compareTo(s1);
	}

}
