Source code: com/webobjects/woextensions/_EventComparator.java
1 /*
2 * _EventComparator.java
3 * © Copyright 2001 Apple Computer, Inc. All rights reserved.
4 * This a modified version.
5 * Original license: http://www.opensource.apple.com/apsl/
6 */
7
8 package com.webobjects.woextensions;
9
10 import com.webobjects.appserver.*;
11 import com.webobjects.foundation.*;
12 import com.webobjects.eocontrol.*;
13
14 public class _EventComparator extends NSComparator {
15 protected boolean _compareAscending;
16 protected WOEventDisplayPage _controller;
17
18 public _EventComparator(NSSelector comparator, WOEventDisplayPage ctrl) {
19 super();
20 _compareAscending = (comparator == EOSortOrdering.CompareAscending) ;
21 _controller = ctrl;
22 }
23
24 public int compare(Object e1, Object e2) throws NSComparator.ComparisonException {
25 if (!(e1 instanceof EOEvent) || !(e2 instanceof EOEvent) || (e1 == null) || (e2 == null))
26 throw new NSComparator.ComparisonException("<"+this.getClass().getName()+" Unable to compare EOEvents. Either one of the arguments is not a EOEvent or is null. Comparison was made with " + e1 + " and " + e2 + "." );
27
28 int result = ((EOEvent)e1)._compareDuration((EOEvent)e2);
29 return _compareAscending ? result : 0 - result;
30 }
31 }