01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/msgcntr/tags/sakai_2-4-1/messageforums-app/src/java/org/sakaiproject/tool/messageforums/GroupComparator.java $
03: * $Id: GroupComparator.java 21665 2007-02-16 15:54:44Z josrodri@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.tool.messageforums;
21:
22: import java.util.Comparator;
23:
24: import org.apache.commons.logging.Log;
25: import org.apache.commons.logging.LogFactory;
26: import org.sakaiproject.entity.api.EntityPropertyNotDefinedException;
27: import org.sakaiproject.entity.api.EntityPropertyTypeException;
28: import org.sakaiproject.site.api.Group;
29:
30: public class GroupComparator implements Comparator {
31:
32: private Log LOG = LogFactory.getLog(DiscussionForumTool.class);
33:
34: private String m_property = null;
35:
36: private boolean m_ascending = true;
37:
38: /**
39: * Construct.
40: *
41: * @param property
42: * The property name used for the sort.
43: * @param asc
44: * true if the sort is to be ascending (false for descending).
45: */
46: public GroupComparator(String property, boolean ascending) {
47: m_property = property;
48: m_ascending = ascending;
49:
50: } // GroupsComparator
51:
52: public int compare(Object o1, Object o2) {
53: int rv = 0;
54:
55: String t1 = ((Group) o1).getTitle();
56: String t2 = ((Group) o2).getTitle();
57:
58: rv = t1.compareTo(t2);
59:
60: if (!m_ascending)
61: rv = -rv;
62:
63: return rv;
64: }
65: }
|