1 package com.dotmarketing.comparators; 2 3 import java.util.Comparator ; 4 5 import com.dotmarketing.beans.WebAsset; 6 7 15 public class WebAssetModDateComparator implements Comparator { 16 17 private String orderType = ""; 18 19 public WebAssetModDateComparator () { 20 21 } 22 23 public WebAssetModDateComparator (String direction) { 24 orderType = direction; 25 } 26 27 public int compare(Object o1, Object o2) { 28 29 try { 30 31 int result; 32 33 WebAsset w1 = (WebAsset) o1; 34 WebAsset w2 = (WebAsset) o2; 35 36 result = (w1.getModDate().equals(w2.getModDate())) ? 0 : (w1.getModDate().before(w2.getModDate())) ? -1 : 1; 37 38 if (orderType.equals("asc")) 39 return -result; 40 else 41 return result; 42 43 } catch (ClassCastException e) { 44 } 45 return 0; 46 } 47 } 48 | Popular Tags |