01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/msgcntr/tags/sakai_2-4-1/messageforums-app/src/java/org/sakaiproject/tool/messageforums/AuthzGroupComparator.java $
03: * $Id: AuthzGroupComparator.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.authz.api.Role;
27:
28: public class AuthzGroupComparator implements Comparator {
29:
30: private Log LOG = LogFactory.getLog(DiscussionForumTool.class);
31:
32: private String m_property = null;
33:
34: private boolean m_ascending = true;
35:
36: /**
37: * Construct.
38: *
39: * @param property
40: * The property name used for the sort.
41: * @param asc
42: * true if the sort is to be ascending (false for descending).
43: */
44: public AuthzGroupComparator(String property, boolean ascending) {
45: m_property = property;
46: m_ascending = ascending;
47:
48: } // AComparator
49:
50: public int compare(Object o1, Object o2) {
51: int rv = 0;
52:
53: String t1 = ((Role) o1).getId();
54: String t2 = ((Role) o2).getId();
55:
56: rv = t1.compareTo(t2);
57:
58: if (!m_ascending)
59: rv = -rv;
60:
61: return rv;
62: }
63: }
|