1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.util.comparator;
16  
17  import com.liferay.portal.kernel.language.LanguageUtil;
18  import com.liferay.portal.model.PortletCategory;
19  
20  import java.io.Serializable;
21  
22  import java.util.Comparator;
23  import java.util.Locale;
24  
25  /**
26   * <a href="PortletCategoryComparator.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class PortletCategoryComparator
31      implements Comparator<PortletCategory>, Serializable {
32  
33      public PortletCategoryComparator(Locale locale) {
34          _locale = locale;
35      }
36  
37      /**
38       * @deprecated
39       */
40      public PortletCategoryComparator(long companyId, Locale locale) {
41          this(locale);
42      }
43  
44      public int compare(
45          PortletCategory portletCategory1, PortletCategory portletCategory2) {
46  
47          String name1 = LanguageUtil.get(_locale, portletCategory1.getName());
48  
49          String name2 = LanguageUtil.get(_locale, portletCategory2.getName());
50  
51          return name1.compareTo(name2);
52      }
53  
54      private Locale _locale;
55  
56  }