01: package clime.messadmin.admin;
02:
03: import java.io.Serializable;
04: import java.util.Comparator;
05:
06: import javax.servlet.http.HttpSession;
07:
08: /**
09: * Comparator which permits to compare on a session's content
10: * @author Cédrik LIME
11: */
12: abstract class BaseSessionComparator implements Comparator,
13: Serializable {
14:
15: /**
16: *
17: */
18: public BaseSessionComparator() {
19: super ();
20: }
21:
22: public abstract Comparable getComparableObject(HttpSession session);
23:
24: /** {@inheritDoc} */
25: public final int compare(Object o1, Object o2) {
26: HttpSession s1 = (HttpSession) o1;
27: HttpSession s2 = (HttpSession) o2;
28: Comparable c1 = getComparableObject(s1);
29: Comparable c2 = getComparableObject(s2);
30: return c1 == null ? (c2 == null ? 0 : -1) : (c2 == null ? 1
31: : c1.compareTo(c2));
32: }
33: }
|