KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > comparators > WebAssetModUserComparator


1 package com.dotmarketing.comparators;
2
3 import java.util.Comparator JavaDoc;
4
5 import com.dotmarketing.beans.WebAsset;
6
7 /**
8  * @author Maria
9  *
10  * To change this generated comment edit the template variable "typecomment":
11  * Window>Preferences>Java>Templates. To enable and disable the creation of type
12  * comments go to Window>Preferences>Java>Code Generation.
13  */

14 public class WebAssetModUserComparator implements Comparator JavaDoc {
15
16     private String JavaDoc orderType = "";
17
18     public WebAssetModUserComparator(String JavaDoc orderType) {
19         super();
20         this.orderType = orderType;
21     }
22
23     public int compare(Object JavaDoc o1, Object JavaDoc o2) {
24
25         try {
26             WebAsset w1 = (WebAsset) o1;
27             WebAsset w2 = (WebAsset) o2;
28
29             int ret = w1.getTitle().compareTo(w2.getTitle());
30
31             if (orderType.equals("asc")) {
32                 return ret;
33             }
34
35             return ret * -1;
36
37         } catch (ClassCastException JavaDoc e) {
38
39         }
40         return 0;
41     }
42 }
Free Books   Free Magazines  
Popular Tags