package org.esupportail.webdavserver.store.uPortal;
import java.util.Comparator;

import org.apache.commons.lang.StringUtils;

/**
 * @author Thomas Bellembois
 * @version
 * 
 * Creation date : 20 juil. 2006
 * Last modification :
 */

public class GroupsComparator_bySize implements Comparator {

public int compare(Object o1, Object o2) {
		
		String groupA = (String)o1;
		String groupB = (String)o2;
		
		groupA = StringUtils.removeStart(StringUtils.removeEnd(groupA, "/"), "/");
		groupB = StringUtils.removeStart(StringUtils.removeEnd(groupB, "/"), "/");
		
		if (StringUtils.countMatches(groupA, "/") == StringUtils.countMatches(groupB, "/"))	{
			return groupA.compareTo(groupB);
		}
		else if (StringUtils.countMatches(groupA, "/") > StringUtils.countMatches(groupB, "/")) return -1;
		else return 1;
		
	}

}
